Update install.sh file

Changed various QOL functions and some punctuation
This commit is contained in:
Admin 2024-04-12 08:54:57 -04:00
parent 646aeb8bbc
commit 79980d5e6a
1 changed files with 48 additions and 44 deletions

View File

@ -21,6 +21,7 @@
green='\033[0;32m' green='\033[0;32m'
yellow='\033[1;33m' yellow='\033[1;33m'
red='\033[0;31m' red='\033[0;31m'
cyan='\033[0;36m'
brown='\033[0;33m' brown='\033[0;33m'
reset='\033[0m' # No Color reset='\033[0m' # No Color
@ -43,8 +44,9 @@ app_prereq="curl sqlite3 wget"
app_umask="0002" app_umask="0002"
branch="main" branch="main"
### CONSTANTS ### Constants
### Update these variables as required for your specific instance
# Update these variables as required for your specific instance
installdir="/opt" # {Update me if needed} Install Location installdir="/opt" # {Update me if needed} Install Location
bindir="${installdir}/${app^}" # Full Path to Install Location bindir="${installdir}/${app^}" # Full Path to Install Location
datadir="/var/lib/$app/" # {Update me if needed} AppData directory to use datadir="/var/lib/$app/" # {Update me if needed} AppData directory to use
@ -66,9 +68,9 @@ case "$ARCH" in
;; ;;
esac esac
## Title Splash! ### Title Splash!
echo -e "" ${brown} echo -e "" ${cyan}
echo -e " _____ ____ _ _ _____ _____ " echo -e " _____ ____ _ _ _____ _____ "
echo -e " / ____|/ __ \| \ | | /\ | __ \| __ \ " echo -e " / ____|/ __ \| \ | | /\ | __ \| __ \ "
echo -e " | (___ | | | | \| | / \ | |__) | |__) | " echo -e " | (___ | | | | \| | / \ | |__) | |__) | "
@ -99,7 +101,7 @@ fi
# User warning about permission conflicts # User warning about permission conflicts
echo "" echo ""
echo -e ${red}" WARNING! WARNING! WARNING!"${reset} echo -e ${red}" WARNING!"${reset}
echo "" echo ""
echo -e " It is ${red}CRITICAL${reset} that the ${brown}User${reset} and ${brown}Group${reset} you select" echo -e " It is ${red}CRITICAL${reset} that the ${brown}User${reset} and ${brown}Group${reset} you select"
echo -e " to run ${brown}[${app^}]${reset} will have both ${red}READ${reset} and ${red}WRITE${reset} access" echo -e " to run ${brown}[${app^}]${reset} will have both ${red}READ${reset} and ${red}WRITE${reset} access"
@ -123,30 +125,33 @@ echo -e "${brown}[${app^}]${reset} will be installed to ${brown}[$bindir]${reset
echo "" echo ""
echo -e " ${brown}${app^}${reset} will run as the user ${brown}[$app_uid]${reset} and group ${brown}[$app_guid]${reset}." echo -e " ${brown}${app^}${reset} will run as the user ${brown}[$app_uid]${reset} and group ${brown}[$app_guid]${reset}."
echo "" echo ""
<<<<<<< HEAD
echo -e " By continuing, you ${red}CONFIRM${reset} that user ${brown}[$app_uid]${reset} and group ${brown}[$app_guid]${reset}" echo -e " By continuing, you ${red}CONFIRM${reset} that user ${brown}[$app_uid]${reset} and group ${brown}[$app_guid]${reset}"
echo -e " will have both ${red}READ${reset} and ${red}WRITE${reset} access to all required directories." echo -e " will have both ${red}READ${reset} and ${red}WRITE${reset} access to all required directories."
=======
echo -e " By continuing, you ${red}CONFIRM${reset} that that ${brown}[$app_uid]${reset} and ${brown}[$app_guid]${reset}"
echo -e " will have both ${red}READ${reset} and ${red}WRITE${reset} access to all required directories."
>>>>>>> c641c11bf (Update install.sh file)
# User confirmation for installation to continue. # User confirmation for installation to continue.
echo "" echo ""
while true; do while true; do
read -r -p "Please type 'yes' to continue with the installation: " response read -r -p " Do you want to continue with the installation? [y/N]: " response
response_lowercase=$(echo "$response" | tr '[:upper:]' '[:lower:]') response_lowercase=$(echo "$response" | tr '[:upper:]' '[:lower:]')
if [[ $response_lowercase == "yes" ]]; then if [[ $response_lowercase == "y" ]]; then
break break
elif [[ $response_lowercase == "y" ]]; then elif [[ $response_lowercase == "n" ]]; then
echo "" echo ""
echo "You must type in 'y e s' to continue with installation." echo " Installation canceled."
echo "" echo " Exiting script."
continue exit 0
else else
echo "" echo ""
echo "Invalid response! Operation is canceled!" echo " Invalid response. Please enter 'y' to continue or 'n' to cancel."
echo "Exiting script!" echo ""
exit 0
fi fi
done done
# Create User / Group as needed # Create User / Group as needed
if [ "$app_guid" != "$app_uid" ]; then if [ "$app_guid" != "$app_uid" ]; then
if ! getent group "$app_guid" >/dev/null; then if ! getent group "$app_guid" >/dev/null; then
@ -179,12 +184,12 @@ if service --status-all | grep -Fq "$app"; then
fi fi
sleep 1 sleep 1
# Create Appdata Directories # Create Appdata Directory
mkdir -p "$datadir" mkdir -p "$datadir"
chown -R "$app_uid":"$app_guid" "$datadir" chown -R "$app_uid":"$app_guid" "$datadir"
chmod 775 "$datadir" chmod 775 "$datadir"
echo "" echo ""
echo -e "${yellow}$datadir${reset} was successfully created!" echo -e "${yellow}$datadir${reset} was successfully created."
sleep 1 sleep 1
# Download and install the App # Download and install the App
@ -213,25 +218,25 @@ fi
# Remove old tarballs, then download and install sonarr tarball for installation # Remove old tarballs, then download and install sonarr tarball for installation
echo "" echo ""
echo -e ${yellow}"Removing tarballs..."${reset} echo -e ${yellow}"Removing previous installation files..."${reset}
sleep 3 sleep 2
# -f to Force so we do not fail if it doesn't exist # -f to Force so we do not fail if it doesn't exist
rm -f "${app^}".*.tar.gz rm -f "${app^}".*.tar.gz
echo "" echo ""
echo -e ${yellow}"Downloading required files..."${reset} echo -e ${yellow}"Downloading required installation files..."${reset}
echo "" echo ""
wget --content-disposition "$DLURL" wget --content-disposition "$DLURL"
echo "" echo ""
echo -e ${yellow}"Download complete!"${reset} echo -e ${yellow}"Download complete!"${reset}
echo "" echo ""
echo -e ${yellow}"Extracting tarball!"${reset} echo -e ${yellow}"Extracting installation files..."${reset}
tar -xvzf "${app^}".*.tar.gz >/dev/null 2>&1 tar -xvzf "${app^}".*.tar.gz >/dev/null 2>&1
echo "" echo ""
echo -e ${yellow}"Installation files downloaded and extracted!"${reset} echo -e ${yellow}"Installation files downloaded and extracted."${reset}
# Remove existing installs # Remove existing installs
echo "" echo ""
echo -e "Removing existing installation files from ${brown}[$bindir]"${reset} echo -e "Removing existing installation files from ${brown}[$bindir]..."${reset}
rm -rf "$bindir" rm -rf "$bindir"
sleep 2 sleep 2
echo "" echo ""
@ -244,7 +249,7 @@ chmod 775 "$bindir"
touch "$datadir"/update_required touch "$datadir"/update_required
chown "$app_uid":"$app_guid" "$datadir"/update_required chown "$app_uid":"$app_guid" "$datadir"/update_required
echo "" echo ""
echo -e "Successfully installed ${brown}[${app^}]${reset}!!" echo -e "Successfully installed ${cyan}[${app^}]${reset}!!"
rm -rf "${app^}.*.tar.gz" rm -rf "${app^}.*.tar.gz"
sleep 2 sleep 2
@ -277,7 +282,7 @@ WantedBy=multi-user.target
EOF EOF
sleep 2 sleep 2
echo "" echo ""
echo -e "New service file created!" echo -e "New service file has been created."
# Start the App # Start the App
echo "" echo ""
@ -290,7 +295,7 @@ sleep 3
echo "" echo ""
echo "Checking if the service is up and running... again this might take a few seconds" echo "Checking if the service is up and running... again this might take a few seconds"
# Loop to wait until the service is active # Loop to wait until the service is active
timeout=60 timeout=30
start_time=$(date +%s) #current time in seconds start_time=$(date +%s) #current time in seconds
while ! systemctl is-active --quiet "$app"; do while ! systemctl is-active --quiet "$app"; do
current_time=$(date +%s) current_time=$(date +%s)
@ -300,7 +305,6 @@ while ! systemctl is-active --quiet "$app"; do
echo -e "${red} EXITING SCRIPT!" echo -e "${red} EXITING SCRIPT!"
break break
fi fi
done done
echo "" echo ""
echo -e "${brown}[${app^}]${reset} installation and service start up is complete!" echo -e "${brown}[${app^}]${reset} installation and service start up is complete!"