added colored echos to all executable scripts

This commit is contained in:
Seaswimmer 2023-10-31 14:29:50 -04:00
parent 2b35e75e98
commit d08868f370
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE
3 changed files with 40 additions and 26 deletions

View file

@ -1,43 +1,49 @@
# Credit to this blog post for this script: # Credit to this blog post for this script:
# https://blog.entrostat.com/install-byobu-on-any-linux-distro/ # 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 BYOBU_VERSION=5.133
set -e set -e
echo "Please make sure you have the following dependencies installed:" echo -e "${GREEN}Please make sure you have the following dependencies installed:"
echo " [+] tar" echo -e " ${BLUE}[+] tar"
echo " [+] screen" echo -e " ${BLUE}[+] screen"
echo " [+] tmux" echo -e " ${BLUE}[+] tmux"
echo " [+] make" echo -e " ${BLUE}[+] make"
which tar which tar
which screen which screen
which tmux which tmux
which make 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) UNIQUE_FOLDER=$(date +%s)
cd /tmp cd /tmp
mkdir /tmp/${UNIQUE_FOLDER} mkdir /tmp/${UNIQUE_FOLDER}
cd /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" 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" tar -xvf "byobu_${BYOBU_VERSION}.orig.tar.gz"
BYOBU_FOLDER_NAME=$(ls | grep byobu | grep -v .tar.gz) BYOBU_FOLDER_NAME=$(ls | grep byobu | grep -v .tar.gz)
cd "byobu-${BYOBU_VERSION}" cd "byobu-${BYOBU_VERSION}"
echo "Configuring and building..." echo -e "{$GREEN}Configuring and building..."
./configure ./configure
sudo make install sudo make install
byobu-select-backend tmux byobu-select-backend tmux
byobu-ctrl-a screen byobu-ctrl-a screen
echo "" echo ""
echo "You're ready to go! Just type:" echo -e "${GREEN}You're ready to go! Just type:"
echo "byobu" echo -e "{$BLUE}byobu"

View file

@ -1,5 +1,12 @@
#!/usr/bin/env bash #!/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. # Retrieves the script's directory and cd's into it.
script_dir="$(cd "$(dirname "$0")" && pwd)" script_dir="$(cd "$(dirname "$0")" && pwd)"
cd ${script_dir} cd ${script_dir}
@ -7,46 +14,46 @@ cd ${script_dir}
# Check if the current directory is inside a Git repository. # 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 if [ -d .git ] || git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
# Pull updated scripts from CoastalCommits. # Pull updated scripts from CoastalCommits.
echo "Updating scripts..." echo -e "${GREEN}Updating scripts..."
git pull git pull
echo "Scripts updated!" echo -e "${GREEN}Scripts updated!"
echo "Server must be restarted for script updates to take effect." echo -e "${GREEN}Server must be restarted for script updates to take effect."
else 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 fi
# If config.sh exists, fetch variables from it # If config.sh exists, fetch variables from it
if [ -f "config.sh" ]; then if [ -f "config.sh" ]; then
source config.sh source config.sh
configpath="config.sh" configpath="config.sh"
echo "Loaded configuration from config.sh" echo -e "${GREEN}Loaded configuration from config.sh"
else else
# If config.sh doesn't exist, check if config.sh.example exists # If config.sh doesn't exist, check if config.sh.example exists
if [ -f "config.sh.example" ]; then if [ -f "config.sh.example" ]; then
# Fetch variables from config.sh.example # 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 source config.sh.example
configpath="config.sh.example" configpath="config.sh.example"
echo "Loaded configuration from config.sh.example" echo -e "${YELLOW}Loaded configuration from config.sh.example"
else else
# Handle the scenario when both files are missing # 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 exit 1
fi fi
fi fi
# This handles automatically updating the Factorio binary. # 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 wget "https://factorio.com/get-download/${version}/headless/linux64" -O factorio_headless.tar.xz
if [ $? -ne 0 ]; then 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 -e "${RED}FATAL: There is not a headless linux64 build available for the version you've selected in your ${YELLOW}${configpath} ${RED}file."
echo "FATAL: See this website for a list of all Factorio versions: https://factorio.com/download/archive/" echo -e "${RED}See this website for a list of all Factorio versions: https://factorio.com/download/archive/"
rm -f factorio_headless.tar.xz rm -f factorio_headless.tar.xz
exit 1 exit 1
fi fi
echo "Extracting Factorio binary..." echo -e "${GREEN}Extracting Factorio binary..."
tar -xf factorio_headless.tar.xz --strip-components=1 --overwrite 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 rm -f factorio_headless.tar.xz
# This checks if the ./saves/$save_name.zip save file exists or not... # This checks if the ./saves/$save_name.zip save file exists or not...

View file

@ -1,3 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
YELLOW='\033[0;33m'
byobu send-keys -t factorio /quit C-m byobu send-keys -t factorio /quit C-m
echo "Server stopped!" echo -e "${YELLOW}Server stopped!"