diff --git a/install_byobu.sh b/install_byobu.sh index 5ed6622..a09a353 100755 --- a/install_byobu.sh +++ b/install_byobu.sh @@ -1,43 +1,49 @@ # Credit to this blog post for this script: # https://blog.entrostat.com/install-byobu-on-any-linux-distro/ +# Define color variables +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +RESET='\033[0m' + BYOBU_VERSION=5.133 set -e -echo "Please make sure you have the following dependencies installed:" -echo " [+] tar" -echo " [+] screen" -echo " [+] tmux" -echo " [+] make" +echo -e "${GREEN}Please make sure you have the following dependencies installed:" +echo -e " ${BLUE}[+] tar" +echo -e " ${BLUE}[+] screen" +echo -e " ${BLUE}[+] tmux" +echo -e " ${BLUE}[+] make" which tar which screen which tmux which make -echo "Downloading byobu version ${BYOBU_VERSION}..." +echo -e "${GREEN}Downloading ${BLUE}byobu version ${YELLOW}${BYOBU_VERSION}..." -echo "Setting up a temporary folder..." +echo -e "${GREEN}Setting up a temporary folder..." UNIQUE_FOLDER=$(date +%s) cd /tmp mkdir /tmp/${UNIQUE_FOLDER} cd /tmp/${UNIQUE_FOLDER} -echo "Downloading source package..." +echo -e "{$GREEN}Downloading source package..." wget "https://launchpad.net/byobu/trunk/${BYOBU_VERSION}/+download/byobu_${BYOBU_VERSION}.orig.tar.gz" -echo "Extracting the source files..." +echo -e "${GREEN}Extracting the source files..." tar -xvf "byobu_${BYOBU_VERSION}.orig.tar.gz" BYOBU_FOLDER_NAME=$(ls | grep byobu | grep -v .tar.gz) cd "byobu-${BYOBU_VERSION}" -echo "Configuring and building..." +echo -e "{$GREEN}Configuring and building..." ./configure sudo make install byobu-select-backend tmux byobu-ctrl-a screen echo "" -echo "You're ready to go! Just type:" -echo "byobu" +echo -e "${GREEN}You're ready to go! Just type:" +echo -e "{$BLUE}byobu" diff --git a/start_server.sh b/start_server.sh index d6b9358..56c607c 100755 --- a/start_server.sh +++ b/start_server.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash +# Define color variables +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +RESET='\033[0m' + # Retrieves the script's directory and cd's into it. script_dir="$(cd "$(dirname "$0")" && pwd)" cd ${script_dir} @@ -7,46 +14,46 @@ cd ${script_dir} # Check if the current directory is inside a Git repository. if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then # Pull updated scripts from CoastalCommits. - echo "Updating scripts..." + echo -e "${GREEN}Updating scripts..." git pull - echo "Scripts updated!" - echo "Server must be restarted for script updates to take effect." + echo -e "${GREEN}Scripts updated!" + echo -e "${GREEN}Server must be restarted for script updates to take effect." else - echo "WARNING: This directory is not a Git repository. Script updates will not be automatically fetched." + echo -e "${RED}WARNING: This directory is not a Git repository. Script updates will not be automatically fetched." fi # If config.sh exists, fetch variables from it if [ -f "config.sh" ]; then source config.sh configpath="config.sh" - echo "Loaded configuration from config.sh" + echo -e "${GREEN}Loaded configuration from config.sh" else # If config.sh doesn't exist, check if config.sh.example exists if [ -f "config.sh.example" ]; then # Fetch variables from config.sh.example - echo "WARNING: config.sh file does not exist, falling back on default configuration." + echo -e "${RED}WARNING: config.sh file does not exist, falling back on default configuration." source config.sh.example configpath="config.sh.example" - echo "Loaded configuration from config.sh.example" + echo -e "${YELLOW}Loaded configuration from config.sh.example" else # Handle the scenario when both files are missing - echo "FATAL: Configuration files are missing! Cannot start the Factorio server." + echo -e "${RED}FATAL: Configuration files are missing! Cannot start the Factorio server." exit 1 fi fi # This handles automatically updating the Factorio binary. -echo "Fetching Factorio binary..." +echo -e "${GREEN}Fetching Factorio binary..." wget "https://factorio.com/get-download/${version}/headless/linux64" -O factorio_headless.tar.xz if [ $? -ne 0 ]; then - echo "FATAL: There is not a headless linux64 build available for the version you've selected in your ${configpath} file." - echo "FATAL: See this website for a list of all Factorio versions: https://factorio.com/download/archive/" + echo -e "${RED}FATAL: There is not a headless linux64 build available for the version you've selected in your ${YELLOW}${configpath} ${RED}file." + echo -e "${RED}See this website for a list of all Factorio versions: https://factorio.com/download/archive/" rm -f factorio_headless.tar.xz exit 1 fi -echo "Extracting Factorio binary..." +echo -e "${GREEN}Extracting Factorio binary..." tar -xf factorio_headless.tar.xz --strip-components=1 --overwrite -echo "Factorio binary updated!" +echo -e "${GREEN}Factorio binary updated!" rm -f factorio_headless.tar.xz # This checks if the ./saves/$save_name.zip save file exists or not... diff --git a/stop_server.sh b/stop_server.sh index d1070ca..2c99af3 100755 --- a/stop_server.sh +++ b/stop_server.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash +YELLOW='\033[0;33m' byobu send-keys -t factorio /quit C-m -echo "Server stopped!" +echo -e "${YELLOW}Server stopped!"