Last active
April 25, 2021 14:56
-
-
Save Interfiber/c42790f19bbbcac3e1a17ef86810853e to your computer and use it in GitHub Desktop.
Lua Yum: A Quick start script to get you rolling with lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Copyright Interfiber 2020-2021" | |
echo "Lua quickstart script." | |
echo "This script will download, and compile lua from source" | |
echo "Lua is very lightweight so this should not take that long" | |
echo "" | |
echo "" | |
echo "" | |
echo "stage: downloading lua..." | |
curl -#L https://www.lua.org/ftp/lua-5.4.2.tar.gz -o LUA_STAGE_DOWNLOAD.tar.gz | |
if ! test -f LUA_STAGE_DOWNLOAD.tar.gz; then | |
echo "fail: failed to download lua. if you are using a proxy disable it." | |
echo "fail: also check your internet connection" | |
echo "exit: 1" | |
exit 1 | |
fi | |
echo "stage: check hashes..." | |
file_hash=$(shasum -a 1 LUA_STAGE_DOWNLOAD.tar.gz) | |
expected_hash="96d4a21393c94bed286b8dc0568f4bdde8730b22" | |
if [[ "$file_has" == *"$expected_has"* ]]; then | |
echo "check: hashes match!" | |
else | |
echo "fail: hashes dont match." | |
echo "expected: $expected_hash" | |
echo "found: $file_hash" | |
echo "stage: remove files..." | |
rm LUA_STAGE_DOWNLOAD.tar.gz | |
echo "exit: 1" | |
exit 1 | |
fi | |
echo "stage: extract files..." | |
mkdir /tmp/yum_lua | |
tar -xf LUA_STAGE_DOWNLOAD.tar.gz -C /tmp/yum_lua | |
echo "stage: delete tar file..." | |
rm LUA_STAGE_DOWNLOAD.tar.gz | |
echo "stage: chdir into /tmp/yum_lua..." | |
cd /tmp/yum_lua/lua-5.4.2 | |
echo "stage: build lua..." | |
make | |
echo "stage: install lua..." | |
mkdir $HOME/.yum_lua | |
make install INSTALL_TOP=$HOME/.yum_lua | |
echo "stage: add profile data..." | |
PROFILE_STRING_POSIX="export PATH=$HOME/.yum_lua/bin:$PATH" | |
PROFILE_STRING_FISH="set -gx PATH $HOME/.yum_lua/bin $PATH" | |
# Fish Shell | |
if [[ "$SHELL" == *"fish"* ]]; then | |
echo "info: profile is ~/.config/fish/config.fish" | |
mkdir -p ~/.config/fish | |
if ! test -f "$HOME/.config/fish/config.fish"; then | |
touch ~/.config/fish/config.fish | |
fi | |
echo $PROFILE_STRING_FISH >> ~/.config/fish/config.fish | |
fi | |
# Bash Shell | |
if [[ "$SHELL" == *"bash"* ]]; then | |
echo "info: profile is ~/.bash_profile" | |
if ! test -f "$HOME/.bash_profile"; then | |
touch ~/.bash_profile | |
fi | |
echo $PROFILE_STRING_POSIX >> ~/.bash_profile | |
fi | |
# ZSH Shell | |
if [[ "$SHELL" == *"zsh"* ]]; then | |
echo "info: profile is ~/.zshrc" | |
if ! test -f "$HOME/.zshrc"; then | |
touch ~/.zshrc | |
fi | |
echo $PROFILE_STRING_POSIX >> ~/.zshrc | |
fi | |
echo "stage: cleaning up..." | |
cd $HOME | |
rm -rf /tmp/yum_lua | |
echo "stage: complete" | |
echo "Congrats lua was installed! To use lua you will need to" | |
echo "restart your terminal! Then lua will be avalible" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -L https://git.io/JqtHe | bash
Will get your started