From adfbaa49f3ebf542dfe8c435de35d2c63208d7b4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 03:11:53 +0100 Subject: [PATCH 001/195] updated fn_scriptlog to fn_script_log Bringing in line with other function names --- functions/command_update_functions.sh | 6 +-- lgsm/functions/alert.sh | 16 +++--- lgsm/functions/alert_email.sh | 4 +- lgsm/functions/alert_pushbullet.sh | 4 +- lgsm/functions/check_config.sh | 4 +- lgsm/functions/check_deps.sh | 4 +- lgsm/functions/check_root.sh | 2 +- lgsm/functions/check_steamcmd.sh | 6 +-- lgsm/functions/check_system_dir.sh | 2 +- lgsm/functions/check_tmux.sh | 2 +- lgsm/functions/command_backup.sh | 4 +- lgsm/functions/command_console.sh | 4 +- lgsm/functions/command_debug.sh | 6 +-- lgsm/functions/command_fastdl.sh | 58 ++++++++++---------- lgsm/functions/command_monitor.sh | 20 +++---- lgsm/functions/command_start.sh | 40 +++++++------- lgsm/functions/command_stop.sh | 44 +++++++-------- lgsm/functions/command_ts3_server_pass.sh | 6 +-- lgsm/functions/command_update_functions.sh | 6 +-- lgsm/functions/command_validate.sh | 4 +- lgsm/functions/core_dl.sh | 24 ++++----- lgsm/functions/core_functions.sh | 2 +- lgsm/functions/fix.sh | 6 +-- lgsm/functions/fn_update_functions | 6 +-- lgsm/functions/install_complete.sh | 2 +- lgsm/functions/install_gslt.sh | 10 ++-- lgsm/functions/install_logs.sh | 2 +- lgsm/functions/install_server_files.sh | 4 +- lgsm/functions/install_ut2k4_key.sh | 2 +- lgsm/functions/logs.sh | 8 +-- lgsm/functions/monitor_gsquery.sh | 10 ++-- lgsm/functions/update_check.sh | 62 +++++++++++----------- lgsm/functions/update_dl.sh | 16 +++--- 33 files changed, 198 insertions(+), 198 deletions(-) diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index 44610e2ca..d97bdc4e8 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -9,7 +9,7 @@ lgsm_version="210516" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" -fn_scriptlog "Updating functions" +fn_script_log "Updating functions" sleep 1 echo -ne "\n" @@ -30,9 +30,9 @@ fi if [ "${exitcode}" == "0" ]; then fn_print_ok "Updating functions" - fn_scriptlog "Success! Updating functions" + fn_script_log "Success! Updating functions" else fn_print_fail "Updating functions" - fn_scriptlog "Failure! Updating functions" + fn_script_log "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 4cf16244f..d231a90ce 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -7,25 +7,25 @@ lgsm_version="210516" # Description: Overall function for managing alerts. fn_alert_test(){ - fn_scriptlog "Sending test alert" + fn_script_log "Sending test alert" alertsubject="LGSM - Test Alert - ${servername}" alertbody="LGSM test alert, how you read?" } fn_alert_restart(){ - fn_scriptlog "Sending restart alert: ${executable} process not running" + fn_script_log "Sending restart alert: ${executable} process not running" alertsubject="LGSM - Restarted - ${servername}" alertbody="${servicename} ${executable} process not running" } fn_alert_restart_query(){ - fn_scriptlog "Sending restart alert: ${gsquerycmd}" + fn_script_log "Sending restart alert: ${gsquerycmd}" alertsubject="LGSM - Restarted - ${servername}" alertbody="gsquery.py failed to query: ${gsquerycmd}" } fn_alert_update(){ - fn_scriptlog "Sending update alert" + fn_script_log "Sending update alert" alertsubject="LGSM - Updated - ${servername}" alertbody="${servicename} recieved update" } @@ -44,18 +44,18 @@ if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${emai alert_email.sh elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Email alerts not enabled" - fn_scriptlog "Email alerts not enabled" + fn_script_log "Email alerts not enabled" elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Email not set" - fn_scriptlog "Email not set" + fn_script_log "Email not set" fi if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Pushbullet alerts not enabled" - fn_scriptlog "Pushbullet alerts not enabled" + fn_script_log "Pushbullet alerts not enabled" elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Pushbullet token not set" - fn_scriptlog "Pushbullet token not set" + fn_script_log "Pushbullet token not set" fi \ No newline at end of file diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 6bfea3fdd..3f29219e1 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -234,8 +234,8 @@ mail -s "${alertsubject}" "${email}" < "${emaillog}" exitcode=$? if [ "${exitcode}" == "0" ]; then fn_print_ok_nl "Sending alert to ${email}" - fn_scriptlog "Success! Sending alert to ${email}" + fn_script_log "Success! Sending alert to ${email}" else fn_print_fail_nl "Sending alert to ${email}" - fn_scriptlog "Failure! Sending alert to ${email}" + fn_script_log "Failure! Sending alert to ${email}" fi \ No newline at end of file diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 1ab99093b..10a704190 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -15,8 +15,8 @@ pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d bo if [ "${pushbulletsend}" == "invalid_access_token" ]; then fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token" - fn_scriptlog "Failure! Sending Pushbullet alert: invalid_access_token" + fn_script_log "Failure! Sending Pushbullet alert: invalid_access_token" else fn_print_ok_nl "Sending Pushbullet alert" - fn_scriptlog "Complete! Sent Pushbullet alert" + fn_script_log "Complete! Sent Pushbullet alert" fi \ No newline at end of file diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index eebb14714..b379f8079 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -10,8 +10,8 @@ if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then fn_print_warn_nl "Config file missing!" echo "${servercfgfullpath}" - fn_scriptlog "Configuration file missing!" - fn_scriptlog "${servercfgfullpath}" + fn_script_log "Configuration file missing!" + fn_script_log "${servercfgfullpath}" sleep 2 fi fi \ No newline at end of file diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index fc366354f..0b7d3393c 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -65,7 +65,7 @@ fn_found_missing_deps(){ fn_print_dots "Checking dependencies" sleep 2 fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" - fn_scriptlog "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_script_log "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" sleep 1 echo -e "" sudo -n true > /dev/null 2>&1 @@ -86,7 +86,7 @@ fn_found_missing_deps(){ else echo "" fn_print_infomation_nl "$(whoami) does not have sudo access. Please manually install dependencies" - fn_scriptlog "$(whoami) does not have sudo access. Please manually install dependencies" + fn_script_log "$(whoami) does not have sudo access. Please manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index 0ffb7b9d7..3c16ed073 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -7,7 +7,7 @@ lgsm_version="210516" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "${selfname} attempted to run as root." + fn_script_log "${selfname} attempted to run as root." fi exit 1 fi diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index a2978252d..56d30a22b 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -23,7 +23,7 @@ fn_check_steamcmd_user(){ fn_print_fail_nl "Steam login not set. Update steamuser." echo " * Change steamuser=\"username\" to a valid steam login." if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login." + fn_script_log "edit ${selfname}. change steamuser=\"username\" to a valid steam login." exit 1 fi fi @@ -31,7 +31,7 @@ fn_check_steamcmd_user(){ if [ -z "${steamuser}" ]; then fn_print_warn_nl "Steam login not set. Using anonymous login." if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "Steam login not set. Using anonymous login." + fn_script_log "Steam login not set. Using anonymous login." fi steamuser="anonymous" steampass="" @@ -48,7 +48,7 @@ fn_check_steamcmd_sh(){ fn_install_steamcmd else fn_print_warn_nl "SteamCMD is missing" - fn_scriptlog "SteamCMD is missing" + fn_script_log "SteamCMD is missing" sleep 1 fn_install_steamcmd fi diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index 6814563f9..2c8ab795b 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -7,7 +7,7 @@ lgsm_version="210516" if [ ! -d "${systemdir}" ]; then fn_print_fail_nl "Cannot access ${systemdir}: No such directory" if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "Cannot access ${systemdir}: No such directory." + fn_script_log "Cannot access ${systemdir}: No such directory." fi exit 1 fi diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index a2287e375..2493d0987 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -11,7 +11,7 @@ if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin else fn_print_fail_nl "Tmux not installed" sleep 1 - fn_scriptlog "Tmux is not installed" + fn_script_log "Tmux is not installed" echo " * Tmux is required to run this server." # Suitable passive agressive message echo " * Please see the the following link." diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index f5c517129..904e76ba4 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -38,7 +38,7 @@ if [ "${status}" != "0" ]; then esac done fi -fn_scriptlog "Started backup" +fn_script_log "Started backup" fn_print_dots "Backup in progress, please wait..." sleep 2 if [ ! -d "${backupdir}" ]; then @@ -46,6 +46,6 @@ if [ ! -d "${backupdir}" ]; then fi tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" -fn_scriptlog "Complete, Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" +fn_script_log "Complete, Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" sleep 1 echo "" \ No newline at end of file diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 966b886b5..0eb8e1a93 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -30,12 +30,12 @@ sleep 1 check_status.sh if [ "${status}" != "0" ]; then fn_print_ok_nl "Starting" - fn_scriptlog "accessed" + fn_script_log "accessed" sleep 1 tmux attach-session -t ${servicename} else fn_print_fail_nl "Server not running" - fn_scriptlog "Failed to access: Server not running" + fn_script_log "Failed to access: Server not running" sleep 1 while true; do read -p "Do you want to start the server? [y/N]" yn diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 4710050f2..c55acae21 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -41,15 +41,15 @@ while true; do * ) echo "Please answer yes or no.";; esac done -fn_scriptlog "Starting debug" +fn_script_log "Starting debug" fn_print_info_nl "Stopping any running servers" -fn_scriptlog "Stopping any running servers" +fn_script_log "Stopping any running servers" sleep 1 command_stop.sh fn_print_dots "Starting debug" sleep 1 fn_print_ok_nl "Starting debug" -fn_scriptlog "Started debug" +fn_script_log "Started debug" cd "${executabledir}" fix.sh if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index b52ca4b0c..2a11050c4 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -26,7 +26,7 @@ fn_check_bzip2(){ if [ -z "$(command -v bzip2)" ]; then bzip2installed="0" fn_print_info "bzip2 is not installed !" - fn_scriptlog "bzip2 is not installed" + fn_script_log "bzip2 is not installed" echo -en "\n" sleep 1 echo "We advise using it" @@ -42,7 +42,7 @@ fn_fastdl_init(){ fn_print_ok "Welcome to LGSM's FastDL generator" sleep 1 echo -en "\n" - fn_scriptlog "Started FastDL creation" + fn_script_log "Started FastDL creation" while true; do read -e -i "y" -p "Continue? [Y/n]" yn case $yn in @@ -51,7 +51,7 @@ fn_fastdl_init(){ * ) echo "Please answer yes or no.";; esac done - fn_scriptlog "Initiating FastDL creation" + fn_script_log "Initiating FastDL creation" # Check and create folders if [ ! -d "${webdir}" ]; then @@ -63,7 +63,7 @@ fn_fastdl_init(){ sleep 0.5 mkdir "${webdir}" fn_print_ok "Created www directory" - fn_scriptlog "FastDL created www directory" + fn_script_log "FastDL created www directory" sleep 1 echo -en "\n" fi @@ -74,7 +74,7 @@ fn_fastdl_init(){ sleep 0.5 mkdir "${fastdldir}" fn_print_ok "Created fastdl directory" - fn_scriptlog "FastDL created fastdl directory" + fn_script_log "FastDL created fastdl directory" sleep 1 echo -en "\n" clearoldfastdl="off" # Nothing to clear @@ -86,7 +86,7 @@ fn_fastdl_init(){ fn_fastdl_config(){ # Global settings for FastDL creation fn_print_info "Entering configuration" - fn_scriptlog "Configuration" + fn_script_log "Configuration" sleep 2 echo -en "\n" # Prompt for clearing old files if folder was already here @@ -95,8 +95,8 @@ fn_fastdl_config(){ while true; do read -e -i "y" -p "Clear old FastDL files? [Y/n]" yn case $yn in - [Yy]* ) clearoldfastdl="on"; fn_scriptlog "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;; - [Nn]* ) clearoldfastdl="off"; fn_scriptlog "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;; + [Yy]* ) clearoldfastdl="on"; fn_script_log "clearoldfastdl enabled"; fn_print_ok "Clearing Enabled"; break;; + [Nn]* ) clearoldfastdl="off"; fn_script_log "clearoldfastdl disabled"; fn_print_ok "Clearing Disabled"; break;; * ) echo "Please answer yes or no.";; esac done @@ -108,8 +108,8 @@ fn_fastdl_config(){ while true; do read -e -i "y" -p "Enable file compression using bzip2? [Y/n]" yn case $yn in - [Yy]* ) bzip2enable="on"; fn_scriptlog "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;; - [Nn]* ) bzip2enable="off"; fn_scriptlog "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;; + [Yy]* ) bzip2enable="on"; fn_script_log "bzip2 enabled"; fn_print_ok "bzip2 Enabled"; break;; + [Nn]* ) bzip2enable="off"; fn_script_log "bzip2 disabled"; fn_print_ok "bzip2 Disabled"; break;; * ) echo "Please answer yes or no.";; esac done @@ -123,8 +123,8 @@ fn_fastdl_gmod_config(){ while true; do read -e -i "y" -p "Use client download enforcer? [Y/n]" yn case $yn in - [Yy]* ) luaressource="on"; fn_scriptlog "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;; - [Nn]* ) luaressource="off"; fn_scriptlog "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;; + [Yy]* ) luaressource="on"; fn_script_log "DL enforcer Enabled"; fn_print_ok "Enforcer Enabled"; break;; + [Nn]* ) luaressource="off"; fn_script_log "DL enforcer Disabled"; fn_print_ok "Enforcer Disabled"; break;; * ) echo "Please answer yes or no.";; esac done @@ -135,11 +135,11 @@ fn_clear_old_fastdl(){ # Clearing old FastDL if user answered yes if [ "${clearoldfastdl}" == "on" ]; then fn_print_info "Clearing existing FastDL folder" - fn_scriptlog "Clearing existing FastDL folder" + fn_script_log "Clearing existing FastDL folder" sleep 0.5 rm -R "${fastdldir:?}"/* fn_print_ok "Old FastDL folder cleared" - fn_scriptlog "Old FastDL folder cleared" + fn_script_log "Old FastDL folder cleared" sleep 1 echo -en "\n" fi @@ -149,7 +149,7 @@ fn_gmod_fastdl(){ # Copy all needed files for FastDL echo "" fn_print_dots "Starting gathering all needed files" - fn_scriptlog "Starting gathering all needed files" + fn_script_log "Starting gathering all needed files" sleep 1 echo -en "\n" @@ -158,7 +158,7 @@ fn_gmod_fastdl(){ # Map Files fn_print_dots "Copying map files..." - fn_scriptlog "Copying map files" + fn_script_log "Copying map files" sleep 0.5 find . -name '*.bsp' | cpio --quiet -updm "${fastdldir}" fn_print_ok "Map files copied" @@ -167,7 +167,7 @@ fn_gmod_fastdl(){ # Materials fn_print_dots "Copying materials..." - fn_scriptlog "Copying materials" + fn_script_log "Copying materials" sleep 0.5 find . -name '*.vtf' | cpio --quiet -updm "${fastdldir}" find . -name '*.vmt' | cpio --quiet -updm "${fastdldir}" @@ -177,7 +177,7 @@ fn_gmod_fastdl(){ # Models fn_print_dots "Copying models..." - fn_scriptlog "Copying models" + fn_script_log "Copying models" sleep 1 find . -name '*.vtx' | cpio --quiet -updm "${fastdldir}" find . -name '*.vvd' | cpio --quiet -updm "${fastdldir}" @@ -189,7 +189,7 @@ fn_gmod_fastdl(){ # Particles fn_print_dots "Copying particles..." - fn_scriptlog "Copying particles" + fn_script_log "Copying particles" sleep 0.5 find . -name '*.pcf' | cpio --quiet -updm "${fastdldir}" fn_print_ok "Particles copied" @@ -198,7 +198,7 @@ fn_gmod_fastdl(){ # Sounds fn_print_dots "Copying sounds..." - fn_scriptlog "Copying sounds" + fn_script_log "Copying sounds" sleep 0.5 find . -name '*.wav' | cpio --quiet -updm "${fastdldir}" find . -name '*.mp3' | cpio --quiet -updm "${fastdldir}" @@ -209,7 +209,7 @@ fn_gmod_fastdl(){ # Resources (mostly fonts) fn_print_dots "Copying fonts and png..." - fn_scriptlog "Copying fonts and png" + fn_script_log "Copying fonts and png" sleep 1 find . -name '*.otf' | cpio --quiet -updm "${fastdldir}" find . -name '*.ttf' | cpio --quiet -updm "${fastdldir}" @@ -224,7 +224,7 @@ fn_gmod_fastdl(){ # Correct addons folder structure for FastDL if [ -d "${fastdldir}/addons" ]; then fn_print_info "Adjusting addons' file structure" - fn_scriptlog "Adjusting addon's file structure" + fn_script_log "Adjusting addon's file structure" sleep 1 cp -Rf "${fastdldir}"/addons/*/* "${fastdldir}" #Don't remove yet rm -R "${fastdldir:?}/addons" @@ -254,7 +254,7 @@ fn_lua_fastdl(){ sleep 1 rm -R "${luafastdlfullpath:?}" fn_print_ok "Removed download enforcer" - fn_scriptlog "Removed old download inforcer" + fn_script_log "Removed old download inforcer" echo -en "\n" sleep 2 fi @@ -266,19 +266,19 @@ fn_lua_fastdl(){ sleep 1 rm "${luafastdlfullpath}" fn_print_ok "Removed old download enforcer" - fn_scriptlog "Removed old download enforcer" + fn_script_log "Removed old download enforcer" echo -en "\n" sleep 1 fi fn_print_dots "Generating new download enforcer" - fn_scriptlog "Generating new download enforcer" + fn_script_log "Generating new download enforcer" sleep 1 # Read all filenames and put them into a lua file at the right path find "${fastdldir}" \( -type f ! -name "*.bz2" \) -printf '%P\n' | while read line; do echo "resource.AddFile( "\""${line}"\"" )" >> ${luafastdlfullpath} done fn_print_ok "Download enforcer generated" - fn_scriptlog "Download enforcer generated" + fn_script_log "Download enforcer generated" echo -en "\n" echo "" sleep 2 @@ -293,11 +293,11 @@ fn_fastdl_bzip2(){ echo -en "\n" echo "" fn_print_dots "Compressing files using bzip2..." - fn_scriptlog "Compressing files using bzip2..." + fn_script_log "Compressing files using bzip2..." # bzip2 all files that are not already compressed (keeping original files) find "${fastdldir}" \( -type f ! -name "*.bz2" \) -exec bzip2 -qk \{\} \; fn_print_ok "bzip2 compression done" - fn_scriptlog "bzip2 compression done" + fn_script_log "bzip2 compression done" sleep 1 echo -en "\n" fi @@ -307,7 +307,7 @@ fn_fastdl_completed(){ # Finished message echo "" fn_print_ok "Congratulations, it's done !" - fn_scriptlog "FastDL job done" + fn_script_log "FastDL job done" sleep 2 echo -en "\n" echo "" diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 89e78578b..325388789 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -14,7 +14,7 @@ fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_print_info_nl "Disabled: No lock file found" - fn_scriptlog "Disabled: No lock file found" + fn_script_log "Disabled: No lock file found" echo " * To enable monitor run ./${selfname} start" exit 1 fi @@ -24,7 +24,7 @@ fn_monitor_check_update(){ # Monitor will not check if update is running. if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then fn_print_info_nl "SteamCMD is currently checking for updates" - fn_scriptlog "SteamCMD is currently checking for updates" + fn_script_log "SteamCMD is currently checking for updates" sleep 1 exit fi @@ -33,7 +33,7 @@ fn_monitor_check_update(){ fn_monitor_msg_checking(){ fn_print_dots "Checking session: " fn_print_checking_eol - fn_scriptlog "Checking session: CHECKING" + fn_script_log "Checking session: CHECKING" sleep 1 } @@ -41,17 +41,17 @@ fn_monitor_teamspeak3(){ if [ "${status}" != "0" ]; then fn_print_ok "Checking session: " fn_print_ok_eol_nl - fn_scriptlog "Checking session: OK" + fn_script_log "Checking session: OK" exit else fn_print_fail "Checking session: ${ts3error}: " fn_print_fail_eol_nl - fn_scriptlog "Checking session: ${ts3error}: FAIL" + fn_script_log "Checking session: ${ts3error}: FAIL" failurereason="${ts3error}" alert="restart" alert.sh fi - fn_scriptlog "Monitor is starting ${servername}" + fn_script_log "Monitor is starting ${servername}" sleep 1 fn_restart } @@ -61,7 +61,7 @@ fn_monitor_tmux(){ if [ "${status}" != "0" ]; then fn_print_ok "Checking session: " fn_print_ok_eol_nl - fn_scriptlog "Checking session: OK" + fn_script_log "Checking session: OK" # runs gsquery check on game with specific engines. local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 ) for allowed_engine in "${allowed_engines_array[@]}" @@ -74,10 +74,10 @@ fn_monitor_tmux(){ else fn_print_fail "Checking session: " fn_print_fail_eol_nl - fn_scriptlog "Checking session: FAIL" + fn_script_log "Checking session: FAIL" alert="restart" alert.sh - fn_scriptlog "Monitor is starting ${servername}" + fn_script_log "Monitor is starting ${servername}" sleep 1 command_start.sh fi @@ -87,7 +87,7 @@ check.sh logs.sh info_config.sh fn_print_dots "${servername}" -fn_scriptlog "${servername}" +fn_script_log "${servername}" sleep 1 fn_monitor_check_lockfile fn_monitor_check_update diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 31e8232c5..5ffec928b 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -12,26 +12,26 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ if [ ! -e "${servercfgfullpath}" ]; then fn_print_warn_nl "${servercfgfullpath} is missing" - fn_scriptlog "${servercfgfullpath} is missing" + fn_script_log "${servercfgfullpath} is missing" echo " * Creating blank ${servercfg}" - fn_scriptlog "Creating blank ${servercfg}" + fn_script_log "Creating blank ${servercfg}" sleep 2 echo " * ${servercfg} can remain blank by default." - fn_scriptlog "${servercfgfullpath} can remain blank by default." + fn_script_log "${servercfgfullpath} can remain blank by default." sleep 2 echo " * ${servercfg} is located in ${servercfgfullpath}." - fn_scriptlog "${servercfg} is located in ${servercfgfullpath}." + fn_script_log "${servercfg} is located in ${servercfgfullpath}." sleep 5 touch "${servercfgfullpath}" fi fn_print_dots "${servername}" - fn_scriptlog "${servername}" + fn_script_log "${servername}" sleep 1 check_status.sh if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" - fn_scriptlog "${servername} is already running" + fn_script_log "${servername} is already running" exit fi @@ -48,25 +48,25 @@ fn_start_teamspeak3(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_fail_nl "Unable to start ${servername}" - fn_scriptlog "Unable to start ${servername}" + fn_script_log "Unable to start ${servername}" echo -e " Check log files: ${rootdir}/log" exit 1 else fn_print_ok_nl "${servername}" - fn_scriptlog "Started ${servername}" + fn_script_log "Started ${servername}" fi } fn_start_tmux(){ fn_parms fn_print_dots "${servername}" - fn_scriptlog "${servername}" + fn_script_log "${servername}" sleep 1 # Log rotation check_status.sh if [ "${status}" == "0" ]; then - fn_scriptlog "Rotating log files" + fn_script_log "Rotating log files" if [ "${engine}" == "unreal2" ]; then if [ -f "${gamelog}" ]; then mv "${gamelog}" "${gamelogdate}" @@ -80,7 +80,7 @@ fn_start_tmux(){ check_status.sh if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" - fn_scriptlog "${servername} is already running" + fn_script_log "${servername} is already running" exit fi @@ -110,7 +110,7 @@ fn_start_tmux(){ elif [ "${consolelogging}" == "off" ]; then touch "${consolelog}" cat "Console logging disabled by user" >> "{consolelog}" - fn_scriptlog "Console logging disabled by user" + fn_script_log "Console logging disabled by user" fi sleep 1 @@ -118,11 +118,11 @@ fn_start_tmux(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_fail_nl "Unable to start ${servername}" - fn_scriptlog "Unable to start ${servername}" + fn_script_log "Unable to start ${servername}" sleep 1 if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then fn_print_fail_nl "Unable to start ${servername}: Tmux error:" - fn_scriptlog "Tmux error" + fn_script_log "Tmux error" echo "" echo "Command" echo "=================================" @@ -139,30 +139,30 @@ fn_start_tmux(){ echo "=================================" if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then echo "$(whoami) is not part of the tty group." - fn_scriptlog "$(whoami) is not part of the tty group." + fn_script_log "$(whoami) is not part of the tty group." group=$(grep tty /etc/group) echo "" echo " ${group}" - fn_scriptlog "${group}" + fn_script_log "${group}" echo "" echo "Run the following command with root privileges." echo "" echo " usermod -G tty $(whoami)" echo "" echo "https://gameservermanagers.com/tmux-op-perm" - fn_scriptlog "https://gameservermanagers.com/tmux-op-perm" + fn_script_log "https://gameservermanagers.com/tmux-op-perm" else echo "No known fix currently. Please log an issue." - fn_scriptlog "No known fix currently. Please log an issue." + fn_script_log "No known fix currently. Please log an issue." echo "https://gameservermanagers.com/issues" - fn_scriptlog "https://gameservermanagers.com/issues" + fn_script_log "https://gameservermanagers.com/issues" fi fi fi exit 1 else fn_print_ok "${servername}" - fn_scriptlog "Started ${servername}" + fn_script_log "Started ${servername}" fi rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" echo -en "\n" diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 254620915..b88272899 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -12,7 +12,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ fn_print_dots "Graceful: rcon quit" - fn_scriptlog "Graceful: rcon quit" + fn_script_log "Graceful: rcon quit" # sends quit tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 # waits up to 30 seconds giving the server time to shutdown gracefuly @@ -21,7 +21,7 @@ fn_stop_graceful_source(){ if [ "${status}" == "0" ]; then fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok_eol_nl - fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" + fn_script_log "Graceful: rcon quit: OK: ${seconds} seconds" break fi sleep 1 @@ -31,7 +31,7 @@ fn_stop_graceful_source(){ if [ "${status}" != "0" ]; then fn_print_fail "Graceful: rcon quit: " fn_print_fail_eol_nl - fn_scriptlog "Graceful: rcon quit: FAIL" + fn_script_log "Graceful: rcon quit: FAIL" fi sleep 1 fn_stop_tmux @@ -43,7 +43,7 @@ fn_stop_graceful_source(){ # preventing the server from coming back online. fn_stop_graceful_goldsource(){ fn_print_dots "Graceful: rcon quit" - fn_scriptlog "Graceful: rcon quit" + fn_script_log "Graceful: rcon quit" # sends quit tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 # waits 3 seconds as goldsource servers restart with the quit command @@ -53,7 +53,7 @@ fn_stop_graceful_goldsource(){ done fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok_eol_nl - fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds" + fn_script_log "Graceful: rcon quit: OK: ${seconds} seconds" sleep 1 fn_stop_tmux } @@ -82,7 +82,7 @@ fn_stop_telnet_sdtd(){ fn_stop_graceful_sdtd(){ fn_print_dots "Graceful: telnet" - fn_scriptlog "Graceful: telnet" + fn_script_log "Graceful: telnet" sleep 1 if [ "${telnetenabled}" == "false" ]; then fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}" @@ -90,7 +90,7 @@ fn_stop_graceful_sdtd(){ # Tries to shutdown with both localhost and server IP. for telnetip in 127.0.0.1 ${ip}; do fn_print_dots "Graceful: telnet: ${telnetip}" - fn_scriptlog "Graceful: telnet: ${telnetip}" + fn_script_log "Graceful: telnet: ${telnetip}" sleep 1 fn_stop_telnet_sdtd completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.") @@ -98,7 +98,7 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_warn "Graceful: telnet: ${telnetip}: " fn_print_fail_eol_nl - fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log "Graceful: telnet: ${telnetip}: FAIL" sleep 1 elif [ -n "${completed}" ]; then break @@ -114,7 +114,7 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_ok "Graceful: telnet: ${telnetip}: " fn_print_ok_eol_nl - fn_scriptlog "Graceful: telnet: ${telnetip}: ${seconds} seconds" + fn_script_log "Graceful: telnet: ${telnetip}: ${seconds} seconds" break fi sleep 1 @@ -126,10 +126,10 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_fail "Graceful: telnet: " fn_print_fail_eol_nl - fn_scriptlog "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log "Graceful: telnet: ${telnetip}: FAIL" else fn_print_fail_nl "Graceful: telnet: Unknown error" - fn_scriptlog "Graceful: telnet: Unknown error" + fn_script_log "Graceful: telnet: Unknown error" fi echo -en "\n" | tee -a "${scriptlog}" echo -en "Telnet output:" | tee -a "${scriptlog}" @@ -138,10 +138,10 @@ fn_stop_graceful_sdtd(){ fi else fn_print_dots "Graceful: telnet: " - fn_scriptlog "Graceful: telnet: " + fn_script_log "Graceful: telnet: " fn_print_fail "Graceful: telnet: expect not installed: " fn_print_fail_eol_nl - fn_scriptlog "Graceful: telnet: expect not installed: FAIL" + fn_script_log "Graceful: telnet: expect not installed: FAIL" fi sleep 1 fn_stop_tmux @@ -200,7 +200,7 @@ fn_stop_ark(){ fn_stop_teamspeak3(){ fn_print_dots "${servername}" - fn_scriptlog "${servername}" + fn_script_log "${servername}" sleep 1 ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 check_status.sh @@ -208,16 +208,16 @@ fn_stop_teamspeak3(){ # Remove lock file rm -f "${rootdir}/${lockselfname}" fn_print_ok_nl "${servername}" - fn_scriptlog "Stopped ${servername}" + fn_script_log "Stopped ${servername}" else fn_print_fail_nl "Unable to stop${servername}" - fn_scriptlog "Unable to stop${servername}" + fn_script_log "Unable to stop${servername}" fi } fn_stop_tmux(){ fn_print_dots "${servername}" - fn_scriptlog "tmux kill-session: ${servername}" + fn_script_log "tmux kill-session: ${servername}" sleep 1 # Kill tmux session tmux kill-session -t "${servicename}" > /dev/null 2>&1 @@ -233,10 +233,10 @@ fn_stop_tmux(){ echo -en "\n" fi fn_print_ok_nl "${servername}" - fn_scriptlog "Stopped ${servername}" + fn_script_log "Stopped ${servername}" else fn_print_fail_nl "Unable to stop${servername}" - fn_scriptlog "Unable to stop${servername}" + fn_script_log "Unable to stop${servername}" fi } @@ -246,7 +246,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" + fn_script_log "${servername} is already stopped" else fn_stop_teamspeak3 fi @@ -254,7 +254,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_scriptlog "${servername} is already stopped" + fn_script_log "${servername} is already stopped" else fn_stop_graceful_select fi @@ -264,6 +264,6 @@ fn_stop_pre_check(){ check.sh info_config.sh fn_print_dots "${servername}" -fn_scriptlog "${servername}" +fn_script_log "${servername}" sleep 1 fn_stop_pre_check diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 982bc53ba..26883b7a7 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -28,14 +28,14 @@ fn_serveradmin_password_prompt(){ * ) echo "Please answer yes or no.";; esac done - fn_scriptlog "Initiating ${gamename} ServerAdmin password change" + fn_script_log "Initiating ${gamename} ServerAdmin password change" read -p "Enter new password : " newpassword } fn_serveradmin_password_set(){ fn_print_info_nl "Applying new password" - fn_scriptlog "Applying new password" + fn_script_log "Applying new password" sleep 1 # Stop any running server command_stop.sh @@ -47,7 +47,7 @@ fn_serveradmin_password_prompt(){ command_stop.sh ts3serverpass="0" fn_print_ok_nl "Password applied" - fn_scriptlog "New ServerAdmin password applied" + fn_script_log "New ServerAdmin password applied" sleep 1 } diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 44610e2ca..d97bdc4e8 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -9,7 +9,7 @@ lgsm_version="210516" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" -fn_scriptlog "Updating functions" +fn_script_log "Updating functions" sleep 1 echo -ne "\n" @@ -30,9 +30,9 @@ fi if [ "${exitcode}" == "0" ]; then fn_print_ok "Updating functions" - fn_scriptlog "Success! Updating functions" + fn_script_log "Success! Updating functions" else fn_print_fail "Updating functions" - fn_scriptlog "Failure! Updating functions" + fn_script_log "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index d31154ec3..7d917f002 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -17,7 +17,7 @@ fn_validation(){ fn_print_dots "Checking server files" sleep 1 fn_print_ok "Checking server files" - fn_scriptlog "Checking server files" + fn_script_log "Checking server files" sleep 1 cd "${rootdir}/steamcmd" @@ -35,7 +35,7 @@ fn_validation(){ fi fix.sh - fn_scriptlog "Checking complete" + fn_script_log "Checking complete" } check_status.sh diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index b87c04891..5b0489c51 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -28,15 +28,15 @@ fn_dl_md5(){ fn_print_fail_eol_nl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" - fn_scriptlog "verifying ${filename} with MD5: FAIL" - fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_scriptlog "expected MD5 checksum: ${md5}" + fn_script_log "verifying ${filename} with MD5: FAIL" + fn_script_log "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_script_log "expected MD5 checksum: ${md5}" exit 1 else fn_print_ok_eol_nl - fn_scriptlog "verifying ${filename} with MD5: OK" - fn_scriptlog "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_scriptlog "expected MD5 checksum: ${md5}" + fn_script_log "verifying ${filename} with MD5: OK" + fn_script_log "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_script_log "expected MD5 checksum: ${md5}" fi fi } @@ -51,7 +51,7 @@ fn_dl_extract(){ extractdir="${3}" # extracts archives echo -ne "extracting ${filename}..." - fn_scriptlog "extracting download" + fn_script_log "extracting download" mime=$(file -b --mime-type "${filedir}/${filename}") if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then @@ -62,7 +62,7 @@ fn_dl_extract(){ local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl - fn_scriptlog "extracting download: FAIL" + fn_script_log "extracting download: FAIL" echo "${tarcmd}" | tee -a "${scriptlog}" exit ${exitcode} else @@ -75,12 +75,12 @@ fn_fetch_trap() { echo "" echo -ne "downloading ${filename}: " fn_print_canceled_eol_nl - fn_scriptlog "downloading ${filename}: CANCELED" + fn_script_log "downloading ${filename}: CANCELED" sleep 1 rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" echo -ne "downloading ${filename}: " fn_print_removed_eol_nl - fn_scriptlog "downloading ${filename}: REMOVED" + fn_script_log "downloading ${filename}: REMOVED" exit } @@ -125,7 +125,7 @@ fn_fetch_file(){ if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl if [ -f "${scriptlog}" ]; then - fn_scriptlog "downloading ${filename}: FAIL" + fn_script_log "downloading ${filename}: FAIL" fi echo "${curlcmd}" | tee -a "${scriptlog}" echo -e "${fileurl}\n" | tee -a "${scriptlog}" @@ -133,7 +133,7 @@ fn_fetch_file(){ else fn_print_ok_eol_nl if [ -f "${scriptlog}" ]; then - fn_scriptlog "downloading ${filename}: OK" + fn_script_log "downloading ${filename}: OK" fi fi # remove trap diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 648832332..79ccf82ad 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -160,7 +160,7 @@ fn_restart(){ local modulename="Restarting" info_config.sh if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "${servername}" + fn_script_log "${servername}" fi command_stop.sh command_start.sh diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index f8bf9c9a9..ea1271eed 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -12,17 +12,17 @@ fn_fix_msg_start(){ fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Applying ${fixname} fix: ${gamename}" + fn_script_log "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_fix_msg_end(){ if [ $? -ne 0 ]; then fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Failure! Applying ${fixname} fix: ${gamename}" + fn_script_log "Failure! Applying ${fixname} fix: ${gamename}" else fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_scriptlog "Complete! Applying ${fixname} fix: ${gamename}" + fn_script_log "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/lgsm/functions/fn_update_functions b/lgsm/functions/fn_update_functions index 79bfe3cb6..22ebf0548 100644 --- a/lgsm/functions/fn_update_functions +++ b/lgsm/functions/fn_update_functions @@ -7,16 +7,16 @@ lgsm_version="210516" # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub. fn_print_dots "Updating functions" -fn_scriptlog "Updating functions" +fn_script_log "Updating functions" sleep 1 echo -ne "\n" rm -rfv "${rootdir}/functions/"* exitcode=$? if [ "${exitcode}" == "0" ]; then fn_print_ok "Updating functions" - fn_scriptlog "Success! Updating functions" + fn_script_log "Success! Updating functions" else fn_print_fail "Updating functions" - fn_scriptlog "Failure! Updating functions" + fn_script_log "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index f4b885a15..cd3b237e5 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -14,7 +14,7 @@ if [ "${gamename}" == "Don't Starve Together" ]; then fi echo "=================================" echo "Install Complete!" -fn_scriptlog "Install Complete!" +fn_script_log "Install Complete!" echo "" echo "To start server type:" echo "./${selfname} start" diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index 96cb21459..f7dc596ef 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -14,16 +14,16 @@ echo "=================================" sleep 1 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then echo "GSLT is required to run a public ${gamename} server" - fn_scriptlog "GSLT is required to run a public ${gamename} server" + fn_script_log "GSLT is required to run a public ${gamename} server" else echo "GSLT is an optional feature for ${gamename} server" - fn_scriptlog "GSLT is an optional feature for ${gamename} server" + fn_script_log "GSLT is an optional feature for ${gamename} server" fi echo "Get more info and a token here:" echo "https://gameservermanagers.com/gslt" -fn_scriptlog "Get more info and a token here:" -fn_scriptlog "https://gameservermanagers.com/gslt" +fn_script_log "Get more info and a token here:" +fn_script_log "https://gameservermanagers.com/gslt" echo "" if [ -z "${autoinstall}" ]; then echo "Enter token below (Can be blank)." @@ -33,5 +33,5 @@ if [ -z "${autoinstall}" ]; then fi sleep 1 echo "The GSLT can be changed by editing ${selfname}." -fn_scriptlog "The GSLT can be changed by editing ${selfname}." +fn_script_log "The GSLT can be changed by editing ${selfname}." echo "" \ No newline at end of file diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index 5ce29635e..e077ee8ab 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -40,4 +40,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then fi fi sleep 1 -fn_scriptlog "logs installed" \ No newline at end of file +fn_script_log "logs installed" \ No newline at end of file diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 4b383a31f..2438b1c01 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -32,7 +32,7 @@ fn_install_server_files_steamcmd(){ if [ "${counter}" -ge "2" ]; then fn_print_warning_nl "SteamCMD did not complete the download, retrying: Attempt ${counter}" - fn_scriptlog "SteamCMD did not complete the download, retrying: Attempt ${counter}" + fn_script_log "SteamCMD did not complete the download, retrying: Attempt ${counter}" fi if [ "${counter}" -ge "7" ]; then @@ -70,7 +70,7 @@ fn_install_server_files_steamcmd(){ fi elif [ "${counter}" -ge "11" ]; then fn_print_failure_nl "SteamCMD did not complete the download, too many retrys" - fn_scriptlog "SteamCMD did not complete the download, too many retrys" + fn_script_log "SteamCMD did not complete the download, too many retrys" break fi done diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 5a0837af0..212cfba25 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -20,7 +20,7 @@ if [ -z "${autoinstall}" ]; then read CODE echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" if [ -f "${systemdir}/cdkey" ]; then - fn_scriptlog "UT2K4 Server CD Key created" + fn_script_log "UT2K4 Server CD Key created" fi else echo "You can add your key using the following command" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index ad309c7a0..03682368e 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -20,7 +20,7 @@ fi if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then fn_print_info "Moving game logs to ${gamelogdir}" - fn_scriptlog "Moving game logs to ${gamelogdir}" + fn_script_log "Moving game logs to ${gamelogdir}" echo -en "\n" sleep 1 mv "${systemdir}"/gamelog*.log "${gamelogdir}" @@ -39,9 +39,9 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0" sleep 1 fn_print_ok_nl "Starting" - fn_scriptlog "Starting" + fn_script_log "Starting" fn_print_info_nl "Removing logs older than "${logdays}" days" - fn_scriptlog "Removing logs older than "${logdays}" days" + fn_script_log "Removing logs older than "${logdays}" days" # Logging logfiles to be removed according to "${logdays}", counting and removing them # Script logfiles find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" @@ -98,5 +98,5 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th count=$((${scriptcount} + ${consolecount} + ${gamecount} + ${srcdscount} + ${smcount} + ${ulxcount} + ${darkrpcount} + ${legacycount})) # Job done fn_print_ok_nl "Removed ${count} log files" - fn_scriptlog "Removed ${count} log files" + fn_script_log "Removed ${count} log files" fi diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index bb1679e1f..50905559c 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -34,7 +34,7 @@ if [ "${gsquery}" == "yes" ]; then fi fn_print_info "Querying port: gsquery.py enabled" - fn_scriptlog "Querying port: gsquery.py enabled" + fn_script_log "Querying port: gsquery.py enabled" sleep 1 # Will query up to 4 times every 15 seconds. @@ -44,7 +44,7 @@ if [ "${gsquery}" == "yes" ]; then for queryattempt in {1..5}; do fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_querying_eol - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" + fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1) exitcode=$? @@ -54,18 +54,18 @@ if [ "${gsquery}" == "yes" ]; then # Server OK fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : " fn_print_ok_eol_nl - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : OK" + fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : OK" sleep 1 exit else # Server failed query - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" + fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" if [ "${queryattempt}" == "5" ]; then # Server failed query 4 times confirmed failure fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_fail_eol_nl - fn_scriptlog "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" + fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" sleep 1 # Send alert if enabled diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index c5c7a8359..716889b43 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -23,7 +23,7 @@ fn_appmanifestcheck(){ if [ "${appmanifestfilewc}" -ge "2" ]; then sleep 1 fn_print_warn "Multiple appmanifest_${appid}.acf files found" - fn_scriptlog "Warning! Multiple appmanifest_${appid}.acf files found" + fn_script_log "Warning! Multiple appmanifest_${appid}.acf files found" sleep 2 fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 @@ -34,7 +34,7 @@ fn_appmanifestcheck(){ fn_appmanifestinfo if [ "${appmanifestfilewc}" -ge "2" ]; then fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - fn_scriptlog "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" + fn_script_log "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 echo "" echo " Check user permissions" @@ -45,10 +45,10 @@ fn_appmanifestcheck(){ else sleep 1 fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" - fn_scriptlog "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" + fn_script_log "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" sleep 1 fn_print_info_nl "Forcing update to correct issue" - fn_scriptlog "Forcing update to correct issue" + fn_script_log "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -56,15 +56,15 @@ fn_appmanifestcheck(){ elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" == "1" ]; then fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" - fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update" + fn_script_log "Warning! Still no appmanifest_${appid}.acf found: Unable to update" exit 1 fi forceupdate=1 fn_print_warn "No appmanifest_${appid}.acf found" - fn_scriptlog "Warning! No appmanifest_${appid}.acf found" + fn_script_log "Warning! No appmanifest_${appid}.acf found" sleep 2 fn_print_info_nl "Forcing update to correct issue" - fn_scriptlog "Forcing update to correct issue" + fn_script_log "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -74,7 +74,7 @@ fn_appmanifestcheck(){ fn_logupdaterequest(){ # Checks for server update requests from server logs. fn_print_dots "Checking for update: Server logs" - fn_scriptlog "Checking for update: Server logs" + fn_script_log "Checking for update: Server logs" sleep 1 requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") if [ "${requestrestart}" -ge "1" ]; then @@ -110,7 +110,7 @@ fn_steamcmdcheck(){ fn_appmanifestcheck # Checks for server update from SteamCMD fn_print_dots "Checking for update: SteamCMD" - fn_scriptlog "Checking for update: SteamCMD" + fn_script_log "Checking for update: SteamCMD" sleep 1 # Gets currentbuild @@ -135,14 +135,14 @@ fn_steamcmdcheck(){ availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) if [ -z "${availablebuild}" ]; then fn_print_fail "Checking for update: SteamCMD" - fn_scriptlog "Failure! Checking for update: SteamCMD" + fn_script_log "Failure! Checking for update: SteamCMD" sleep 1 fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info" - fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info" + fn_script_log "Failure! Checking for update: SteamCMD: Not returning version info" exit 1 else fn_print_ok "Checking for update: SteamCMD" - fn_scriptlog "Success! Checking for update: SteamCMD" + fn_script_log "Success! Checking for update: SteamCMD" sleep 1 fi @@ -163,10 +163,10 @@ fn_steamcmdcheck(){ echo -en "Applying update...\r" sleep 1 echo -en "\n" - fn_scriptlog "Update available" - fn_scriptlog "Current build: ${currentbuild}" - fn_scriptlog "Available build: ${availablebuild}" - fn_scriptlog "${currentbuild} > ${availablebuild}" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" unset updateonstart check_status.sh @@ -187,8 +187,8 @@ fn_steamcmdcheck(){ echo -e " https://steamdb.info/app/${appid}/" echo -e "" fn_print_ok_nl "No update available" - fn_scriptlog "Current build: ${currentbuild}" - fn_scriptlog "Available build: ${availablebuild}" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" fi } @@ -197,7 +197,7 @@ fn_steamcmdcheck(){ fn_teamspeak3_check(){ # Checks for server update from teamspeak.com using a mirror dl.4players.de fn_print_dots "Checking for update: teamspeak.com" - fn_scriptlog "Checking for update: teamspeak.com" + fn_script_log "Checking for update: teamspeak.com" sleep 1 # Gets currentbuild info @@ -206,10 +206,10 @@ fn_teamspeak3_check(){ fn_print_fail "Checking for update: teamspeak.com" sleep 1 fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_scriptlog "Failure! Checking for update: teamspeak.com: No logs with server version found" + fn_script_log "Failure! Checking for update: teamspeak.com: No logs with server version found" sleep 2 fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_scriptlog "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log "Checking for update: teamspeak.com: Forcing server restart" sleep 2 command_stop.sh command_start.sh @@ -217,7 +217,7 @@ fn_teamspeak3_check(){ # If still failing will exit if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_scriptlog "Failure! Checking for update: teamspeak.com: Still No logs with server version found" + fn_script_log "Failure! Checking for update: teamspeak.com: Still No logs with server version found" exit 1 fi fi @@ -260,15 +260,15 @@ fn_teamspeak3_check(){ # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then fn_print_fail "Checking for update: teamspeak.com" - fn_scriptlog "Checking for update: teamspeak.com" + fn_script_log "Checking for update: teamspeak.com" sleep 1 fn_print_fail "Checking for update: teamspeak.com: Not returning version info" - fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info" + fn_script_log "Failure! Checking for update: teamspeak.com: Not returning version info" sleep 2 exit 1 else fn_print_ok "Checking for update: teamspeak.com" - fn_scriptlog "Success! Checking for update: teamspeak.com" + fn_script_log "Success! Checking for update: teamspeak.com" sleep 1 fi @@ -291,10 +291,10 @@ fn_teamspeak3_check(){ echo -en "Applying update...\r" sleep 1 echo -en "\n" - fn_scriptlog "Update available" - fn_scriptlog "Current build: ${currentbuild}" - fn_scriptlog "Available build: ${availablebuild}" - fn_scriptlog "${currentbuild} > ${availablebuild}" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" unset updateonstart check_status.sh @@ -317,8 +317,8 @@ fn_teamspeak3_check(){ echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" echo -e "" fn_print_ok_nl "No update available" - fn_scriptlog "Current build: ${currentbuild}" - fn_scriptlog "Available build: ${availablebuild}" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" fi } diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index 0adda4991..5d5fb6ced 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -32,39 +32,39 @@ fn_steamcmd_dl(){ fn_teamspeak3_dl(){ cd "${rootdir}" echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" - fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" + fn_script_log "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq sleep 1 echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" - fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" + fn_script_log "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp" local status=$? if [ ${status} -eq 0 ]; then echo "OK" else echo "FAIL - Exit status ${status}" - fn_scriptlog "Failed to extract - Exit status ${status}" + fn_script_log "Failed to extract - Exit status ${status}" sleep 1 cat "${scriptlogdir}/.${servicename}-tar-error.tmp" cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}" rm "${scriptlogdir}/.${servicename}-tar-error.tmp" - fn_scriptlog "Failure! Unable to update" + fn_script_log "Failure! Unable to update" exit ${status} fi echo -e "copying to ${filesdir}...\c" - fn_scriptlog "Copying to ${filesdir}" + fn_script_log "Copying to ${filesdir}" cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp" local status=$? if [ ${status} -eq 0 ]; then echo "OK" else echo "FAIL - Exit status ${status}" - fn_scriptlog "Failed to copy - Exit status ${status}" + fn_script_log "Failed to copy - Exit status ${status}" sleep 1 cat "${scriptlogdir}/.${servicename}-cp-error.tmp" cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}" rm "${scriptlogdir}/.${servicename}-cp-error.tmp" - fn_scriptlog "Failure! Unable to update" + fn_script_log "Failure! Unable to update" exit ${status} fi rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 @@ -76,7 +76,7 @@ info_config.sh fn_print_dots "Updating ${servername}" sleep 1 fn_print_ok_nl "Updating ${servername}" -fn_scriptlog "Updating ${servername}" +fn_script_log "Updating ${servername}" sleep 1 if [ "${gamename}" == "Teamspeak 3" ]; then fn_teamspeak3_dl From 58b3f6301e72e13d397ad20536de3f2652293ad1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 14:48:29 +0100 Subject: [PATCH 002/195] Added LGSM total disk used and tidy up --- lgsm/functions/command_details.sh | 5 +- lgsm/functions/info_distro.sh | 85 +++++++++++++++++++------------ 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index cfac2a5dd..9096f1f46 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -2,7 +2,7 @@ # LGSM command_details.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +lgsm_version="190616" # Description: Displays server infomation. @@ -69,7 +69,9 @@ fn_details_disk(){ # Total: 15G # Used: 8.4G # Available: 5.7G + # LGSM Total: 1G # Serverfiles: 961M + # Backups: 2G echo -e "" echo -e "\e[93mStorage\e[0m" @@ -79,6 +81,7 @@ fn_details_disk(){ echo -e "\e[34mTotal:\t\e[0m${totalspace}" echo -e "\e[34mUsed:\t\e[0m${usedspace}" echo -e "\e[34mAvailable:\t\e[0m${availspace}" + echo -e "\e[34mLGSM Total:\t\e[0m${rootdirdu}" echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}" if [ -d "${backupdir}" ]; then echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 81b434f1b..17aff8d92 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -2,30 +2,33 @@ # LGSM info_distro.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +lgsm_version="190616" # Description: Variables providing useful info on the Operating System such as disk and performace info. -# Used for command_details.sh, command_debug.sh and email.sh. +# Used for command_details.sh, command_debug.sh and alert.sh. -## Distro infomation + +### Distro infomation + +## Distro # Returns architecture, kernel and distro/os. arch=$(uname -m) kernel=$(uname -r) if [ -n "$(command -v lsb_release)" ]; then os=$(lsb_release -s -d) -elif [ -f /etc/debian_version ]; then +elif [ -f "/etc/debian_version" ]; then os="Debian $(cat /etc/debian_version)" -elif [ -f /etc/redhat-release ]; then +elif [ -f "/etc/redhat-release" ]; then os=$(cat /etc/redhat-release) else os="$(uname -s) $(uname -r)" fi -# Glibc version number +## Glibc version # e.g: 1.17 glibcversion="$(ldd --version | sed -n '1s/.* //p')" -# tmux version +## tmux version # e.g: tmux 1.6 if [ -z "$(command -v tmux)" ]; then tmuxv="\e[0;31mNOT INSTALLED!\e[0m" @@ -35,53 +38,71 @@ else tmuxv=$(tmux -V) fi -## Performance +## Uptime +uptime=$( /dev/null 2>&1; echo $?)" -ne "0" ]; then - option="-m" + humanreadable="-m" else - option="-h" + humanreadable="-h" fi -physmemtotal=$(free ${option} | awk '/Mem:/ {print $2}') -physmemused=$(free ${option} | awk '/Mem:/ {print $3}') -physmemfree=$(free ${option} | awk '/Mem:/ {print $4}') -swaptotal=$(free ${option} | awk '/Swap:/ {print $2}') -swapused=$(free ${option} | awk '/Swap:/ {print $3}') -swapfree=$(free ${option} | awk '/Swap:/ {print $4}') - -# Uptime -uptime=$( /dev/null | awk '{print $1}') +if [ -z "${rootdirdu}" ]; then + rootdirdu="0M" +fi + +## LGSM used space in serverfiles dir. filesdirdu=$(du -sh "${filesdir}" 2> /dev/null | awk '{print $1}') -if [ -z ${filesdirdu} ]; then +if [ -z "${filesdirdu}" ]; then filesdirdu="0M" fi -# Backup info +## LGSM used space total minus backup dir. +rootdirduexbackup=$(du -sh --exclude="${backupdir}" "${filesdir}" 2> /dev/null | awk '{print $1}') +if [ -z "${rootdirduexbackup}" ]; then + rootdirduexbackup="0M" +fi + +## Backup info if [ -d "${backupdir}" ]; then # used space in backups dir. backupdirdu=$(du -sh "${backupdir}" | awk '{print $1}') - if [ -z ${backupdirdu} ]; then + if [ -z "${backupdirdu}" ]; then backupdirdu="0M" fi + # number of backups. backupcount=$(find "${backupdir}"/*.tar.gz | wc -l) # most recent backup. @@ -91,4 +112,4 @@ if [ -d "${backupdir}" ]; then # size of most recent backup. lastbackupsize=$(du -h "${lastbackup}" | awk '{print $1}') -fi +fi \ No newline at end of file From f5d765dbffaac72af309a671d5acc7d328eed3fb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 14:50:03 +0100 Subject: [PATCH 003/195] Added new fn_script_log vars Depending on the error the script log will now display PASS, FATAL, ERROR, WARN, INFO in the log. --- lgsm/functions/core_messages.sh | 46 ++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 972688a6e..7cbb2d1cb 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -11,7 +11,7 @@ lgsm_version="210516" # Date, servicename & module details displayed in log files. # e.g Feb 28 14:56:58 ut99-server: Monitor: -fn_scriptlog(){ +fn_script_log(){ if [ -n "${modulename}" ]; then echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}" else @@ -19,6 +19,50 @@ fn_scriptlog(){ fi } +fn_script_log_pass(){ + if [ -n "${modulename}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: PASS: ${1}" >> "${scriptlog}" + else + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: PASS: ${1}" >> "${scriptlog}" + fi + exitcode=0 +} + +fn_script_log_fatal(){ + if [ -n "${modulename}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: FATAL: ${1}" >> "${scriptlog}" + else + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: FATAL: ${1}" >> "${scriptlog}" + fi + exitcode=1 +} + +fn_script_log_error(){ + if [ -n "${modulename}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ERROR: ${1}" >> "${scriptlog}" + else + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ERROR: ${1}" >> "${scriptlog}" + fi + exitcode=2 +} + +fn_script_log_warn(){ + if [ -n "${modulename}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: WARN: ${1}" >> "${scriptlog}" + else + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: WARN: ${1}" >> "${scriptlog}" + fi + exitcode=3 +} + +fn_script_log_info(){ + if [ -n "${modulename}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: INFO: ${1}" >> "${scriptlog}" + else + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: INFO: ${1}" >> "${scriptlog}" + fi +} + # [ FAIL ] fn_print_fail(){ if [ -n "${modulename}" ]; then From 2ec677b94efc42f7a0fa26d5e1ba952d7311db2d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 14:50:29 +0100 Subject: [PATCH 004/195] added core_exit.sh --- lgsm/functions/core_functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 79ccf82ad..3b8b02a62 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -78,17 +78,17 @@ functionfile="${FUNCNAME}" fn_fetch_core_dl } -core_getopt.sh(){ +core_exit.sh(){ functionfile="${FUNCNAME}" fn_fetch_core_dl } -core_messages.sh(){ +core_getopt.sh(){ functionfile="${FUNCNAME}" fn_fetch_core_dl } -core_dl.sh(){ +core_messages.sh(){ functionfile="${FUNCNAME}" fn_fetch_core_dl } From 3cb1246e7f6fa907fd6715ca473275daad685cfa Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 15:11:15 +0100 Subject: [PATCH 005/195] scriptlog --- lgsm/functions/check_root.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index 3c16ed073..0ffb7b9d7 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -7,7 +7,7 @@ lgsm_version="210516" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" if [ -d "${scriptlogdir}" ]; then - fn_script_log "${selfname} attempted to run as root." + fn_scriptlog "${selfname} attempted to run as root." fi exit 1 fi From a0692dd9a26a99eeb945724c0ff1a0f108c71758 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 15:11:47 +0100 Subject: [PATCH 006/195] Scriptlog and added info_distro.sh --- lgsm/functions/command_backup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 904e76ba4..a9f8f74eb 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -10,9 +10,10 @@ local modulename="Backup" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh +info_distro.sh backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" echo "" -fn_print_info_nl "A total of $(du -sh "${rootdir}" --exclude="${backupdir}" | awk '{print $1}') will be compressed into the following backup:" +fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:" echo "${backupdir}/${backupname}.tar.gz" echo "" while true; do @@ -38,14 +39,17 @@ if [ "${status}" != "0" ]; then esac done fi -fn_script_log "Started backup" + fn_print_dots "Backup in progress, please wait..." +fn_script_log_info "Started backup" sleep 2 if [ ! -d "${backupdir}" ]; then mkdir "${backupdir}" fi tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* +# NOTE: Need to add error checking for tar. fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" -fn_script_log "Complete, Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" +fn_script_log_pass "Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" sleep 1 -echo "" \ No newline at end of file +echo "" +core_exit.sh \ No newline at end of file From 47f068270ac348c7bf847cba3cead3b3f2d08a82 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 19 Jun 2016 15:12:16 +0100 Subject: [PATCH 007/195] scriptlog --- lgsm/functions/command_console.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 0eb8e1a93..e12234f9d 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -30,12 +30,12 @@ sleep 1 check_status.sh if [ "${status}" != "0" ]; then fn_print_ok_nl "Starting" - fn_script_log "accessed" + fn_script_log_info "Accessed" sleep 1 tmux attach-session -t ${servicename} else fn_print_fail_nl "Server not running" - fn_script_log "Failed to access: Server not running" + fn_script_log_fatal "Failed to access: Server not running" sleep 1 while true; do read -p "Do you want to start the server? [y/N]" yn @@ -46,3 +46,4 @@ else esac done fi +core_exit.sh From d9b919121e82ddb66a3e0f6bdea2db04814fed9b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 23 Jun 2016 19:03:33 +0100 Subject: [PATCH 008/195] added lock file to debug --- lgsm/functions/command_debug.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index c55acae21..067289659 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -9,9 +9,17 @@ lgsm_version="210516" local modulename="Debug" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +# Trap to remove lockfile on quit. +fn_lockfile_trap(){ + # Remove lock file + rm -f "${rootdir}/${lockselfname}" + core_exit.sh +} + check.sh fix.sh info_distro.sh +# NOTE: Check if works with server without parms. Could be intergrated in to info_parms.sh fn_parms echo "" echo "${gamename} Debug" @@ -41,19 +49,28 @@ while true; do * ) echo "Please answer yes or no.";; esac done -fn_script_log "Starting debug" + fn_print_info_nl "Stopping any running servers" -fn_script_log "Stopping any running servers" +fn_script_log_info "Stopping any running servers" sleep 1 command_stop.sh fn_print_dots "Starting debug" +fn_script_log "Starting debug" sleep 1 fn_print_ok_nl "Starting debug" fn_script_log "Started debug" + +# create lock file. +date > "${rootdir}/${lockselfname}" +# trap to remove lockfile on quit. +trap fn_lockfile_trap INT + cd "${executabledir}" -fix.sh if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then ${executable} ${parms} -debug else ${executable} ${parms} -fi \ No newline at end of file +fi + +# remove trap. +trap - INT \ No newline at end of file From 603fc30fdccd656cc3d7e22973f3b0b2aeb7bbc7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 23 Jun 2016 19:03:59 +0100 Subject: [PATCH 009/195] added exit code handling. --- lgsm/functions/command_dev_debug.sh | 2 + lgsm/functions/command_monitor.sh | 18 ++--- lgsm/functions/command_start.sh | 43 ++++++------ lgsm/functions/command_stop.sh | 101 ++++++++++++++-------------- lgsm/functions/core_dl.sh | 33 ++++----- lgsm/functions/core_exit.sh | 23 +++++++ lgsm/functions/info_parms.sh | 2 +- 7 files changed, 125 insertions(+), 97 deletions(-) create mode 100644 lgsm/functions/core_exit.sh diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 625201df0..34264deca 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -11,7 +11,9 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then rm .dev-debug fn_print_ok_nl "Disabled dev-debug" + fn_script_log_info "Disabled dev-debug" else date > .dev-debug fn_print_ok_nl "Enabled dev-debug" + fn_script_log_info "Enabled dev-debug" fi \ No newline at end of file diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 325388789..082f72fcd 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -14,7 +14,7 @@ fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_print_info_nl "Disabled: No lock file found" - fn_script_log "Disabled: No lock file found" + fn_script_log_info "Disabled: No lock file found" echo " * To enable monitor run ./${selfname} start" exit 1 fi @@ -24,7 +24,7 @@ fn_monitor_check_update(){ # Monitor will not check if update is running. if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then fn_print_info_nl "SteamCMD is currently checking for updates" - fn_script_log "SteamCMD is currently checking for updates" + fn_script_log_info "SteamCMD is currently checking for updates" sleep 1 exit fi @@ -33,7 +33,7 @@ fn_monitor_check_update(){ fn_monitor_msg_checking(){ fn_print_dots "Checking session: " fn_print_checking_eol - fn_script_log "Checking session: CHECKING" + fn_script_log_info "Checking session: CHECKING" sleep 1 } @@ -41,17 +41,17 @@ fn_monitor_teamspeak3(){ if [ "${status}" != "0" ]; then fn_print_ok "Checking session: " fn_print_ok_eol_nl - fn_script_log "Checking session: OK" + fn_script_log_pass "Checking session: OK" exit else fn_print_fail "Checking session: ${ts3error}: " fn_print_fail_eol_nl - fn_script_log "Checking session: ${ts3error}: FAIL" + fn_script_log_error "Checking session: ${ts3error}: FAIL" failurereason="${ts3error}" alert="restart" alert.sh fi - fn_script_log "Monitor is starting ${servername}" + fn_script_log_info "Monitor is starting ${servername}" sleep 1 fn_restart } @@ -61,7 +61,7 @@ fn_monitor_tmux(){ if [ "${status}" != "0" ]; then fn_print_ok "Checking session: " fn_print_ok_eol_nl - fn_script_log "Checking session: OK" + fn_script_log_pass "Checking session: OK" # runs gsquery check on game with specific engines. local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 ) for allowed_engine in "${allowed_engines_array[@]}" @@ -74,10 +74,10 @@ fn_monitor_tmux(){ else fn_print_fail "Checking session: " fn_print_fail_eol_nl - fn_script_log "Checking session: FAIL" + fn_script_log_error "Checking session: FAIL" alert="restart" alert.sh - fn_script_log "Monitor is starting ${servername}" + fn_script_log_info "Monitor is starting ${servername}" sleep 1 command_start.sh fi diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 5ffec928b..3408b193c 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -12,15 +12,15 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ if [ ! -e "${servercfgfullpath}" ]; then fn_print_warn_nl "${servercfgfullpath} is missing" - fn_script_log "${servercfgfullpath} is missing" + fn_script_log_warn "${servercfgfullpath} is missing" echo " * Creating blank ${servercfg}" - fn_script_log "Creating blank ${servercfg}" + fn_script_log_info "Creating blank ${servercfg}" sleep 2 echo " * ${servercfg} can remain blank by default." - fn_script_log "${servercfgfullpath} can remain blank by default." + fn_script_log_info "${servercfgfullpath} can remain blank by default." sleep 2 echo " * ${servercfg} is located in ${servercfgfullpath}." - fn_script_log "${servercfg} is located in ${servercfgfullpath}." + fn_script_log_info "${servercfg} is located in ${servercfgfullpath}." sleep 5 touch "${servercfgfullpath}" fi @@ -31,8 +31,8 @@ fn_start_teamspeak3(){ check_status.sh if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" - fn_script_log "${servername} is already running" - exit + fn_script_log_error "${servername} is already running" + core_exit.sh fi mv "${scriptlog}" "${scriptlogdate}" @@ -48,12 +48,12 @@ fn_start_teamspeak3(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_fail_nl "Unable to start ${servername}" - fn_script_log "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" echo -e " Check log files: ${rootdir}/log" - exit 1 + core_exit.sh else fn_print_ok_nl "${servername}" - fn_script_log "Started ${servername}" + fn_script_log_pass "Started ${servername}" fi } @@ -66,7 +66,7 @@ fn_start_tmux(){ # Log rotation check_status.sh if [ "${status}" == "0" ]; then - fn_script_log "Rotating log files" + fn_script_log_info "Rotating log files" if [ "${engine}" == "unreal2" ]; then if [ -f "${gamelog}" ]; then mv "${gamelog}" "${gamelogdate}" @@ -80,8 +80,8 @@ fn_start_tmux(){ check_status.sh if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" - fn_script_log "${servername} is already running" - exit + fn_script_log_error "${servername} is already running" + core_exit.sh fi # Create lock file @@ -118,11 +118,11 @@ fn_start_tmux(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_fail_nl "Unable to start ${servername}" - fn_script_log "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" sleep 1 if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then fn_print_fail_nl "Unable to start ${servername}: Tmux error:" - fn_script_log "Tmux error" + fn_script_log_fatal "Unable to start ${servername}: Tmux error:" echo "" echo "Command" echo "=================================" @@ -139,30 +139,31 @@ fn_start_tmux(){ echo "=================================" if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then echo "$(whoami) is not part of the tty group." - fn_script_log "$(whoami) is not part of the tty group." + fn_script_log_info "$(whoami) is not part of the tty group." group=$(grep tty /etc/group) echo "" echo " ${group}" - fn_script_log "${group}" + fn_script_log_info "${group}" echo "" echo "Run the following command with root privileges." echo "" echo " usermod -G tty $(whoami)" echo "" echo "https://gameservermanagers.com/tmux-op-perm" - fn_script_log "https://gameservermanagers.com/tmux-op-perm" + fn_script_log_info "https://gameservermanagers.com/tmux-op-perm" else echo "No known fix currently. Please log an issue." - fn_script_log "No known fix currently. Please log an issue." + fn_script_log_info "No known fix currently. Please log an issue." echo "https://gameservermanagers.com/issues" - fn_script_log "https://gameservermanagers.com/issues" + fn_script_log_info "https://gameservermanagers.com/issues" fi fi fi - exit 1 + + core_exit.sh else fn_print_ok "${servername}" - fn_script_log "Started ${servername}" + fn_script_log_pass "Started ${servername}" fi rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" echo -en "\n" diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index b88272899..ede8c625a 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -21,7 +21,7 @@ fn_stop_graceful_source(){ if [ "${status}" == "0" ]; then fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok_eol_nl - fn_script_log "Graceful: rcon quit: OK: ${seconds} seconds" + fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds" break fi sleep 1 @@ -31,7 +31,7 @@ fn_stop_graceful_source(){ if [ "${status}" != "0" ]; then fn_print_fail "Graceful: rcon quit: " fn_print_fail_eol_nl - fn_script_log "Graceful: rcon quit: FAIL" + fn_script_log_fail "Graceful: rcon quit: FAIL" fi sleep 1 fn_stop_tmux @@ -53,7 +53,7 @@ fn_stop_graceful_goldsource(){ done fn_print_ok "Graceful: rcon quit: ${seconds}: " fn_print_ok_eol_nl - fn_script_log "Graceful: rcon quit: OK: ${seconds} seconds" + fn_script_log_pass "Graceful: rcon quit: OK: ${seconds} seconds" sleep 1 fn_stop_tmux } @@ -77,7 +77,6 @@ fn_stop_telnet_sdtd(){ expect { eof } puts "Completed.\n" ') - } fn_stop_graceful_sdtd(){ @@ -98,7 +97,7 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_warn "Graceful: telnet: ${telnetip}: " fn_print_fail_eol_nl - fn_script_log "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log_warn "Graceful: telnet: ${telnetip}: FAIL" sleep 1 elif [ -n "${completed}" ]; then break @@ -114,7 +113,7 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_ok "Graceful: telnet: ${telnetip}: " fn_print_ok_eol_nl - fn_script_log "Graceful: telnet: ${telnetip}: ${seconds} seconds" + fn_script_log_pass "Graceful: telnet: ${telnetip}: ${seconds} seconds" break fi sleep 1 @@ -126,10 +125,10 @@ fn_stop_graceful_sdtd(){ if [ -n "${refused}" ]; then fn_print_fail "Graceful: telnet: " fn_print_fail_eol_nl - fn_script_log "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log_fail "Graceful: telnet: ${telnetip}: FAIL" else fn_print_fail_nl "Graceful: telnet: Unknown error" - fn_script_log "Graceful: telnet: Unknown error" + fn_script_log_fail "Graceful: telnet: Unknown error" fi echo -en "\n" | tee -a "${scriptlog}" echo -en "Telnet output:" | tee -a "${scriptlog}" @@ -141,7 +140,7 @@ fn_stop_graceful_sdtd(){ fn_script_log "Graceful: telnet: " fn_print_fail "Graceful: telnet: expect not installed: " fn_print_fail_eol_nl - fn_script_log "Graceful: telnet: expect not installed: FAIL" + fn_script_log_fail "Graceful: telnet: expect not installed: FAIL" fi sleep 1 fn_stop_tmux @@ -160,42 +159,42 @@ fn_stop_graceful_select(){ } fn_stop_ark(){ - MAXPIDITER=15 # The maximum number of times to check if the ark pid has closed gracefully. - info_config.sh - if [ -z $queryport ] ; then - fn_print_warn "no queryport found using info_config.sh" - userconfigfile="${filesdir}" - userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini" - queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g") - fi - if [ -z $queryport ] ; then - fn_print_warn "no queryport found in the GameUsersettings.ini file" - return - fi + maxpiditer=15 # The maximum number of times to check if the ark pid has closed gracefully. + info_config.sh + if [ -z "${queryport}" ]; then + fn_print_warn "no queryport found using info_config.sh" + userconfigfile="${filesdir}" + userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini" + queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g") + fi + if [ -z "${queryport}" ]; then + fn_print_warn "no queryport found in the GameUsersettings.ini file" + return + fi - if [[ ${#queryport} -gt 0 ]] ; then - for (( pidcheck=0 ; pidcheck < ${MAXPIDITER} ; pidcheck++ )) ; do - pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\ - grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\ - rev | cut -d\/ -f1) - # - # check for a valid pid - let pid+=0 # turns an empty string into a valid number, '0', - # and a valid numeric pid remains unchanged. - if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then - fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck" - sleep 1 - else - break # Our job is done here - fi # end if for pid range check - done - if [[ ${pidcheck} -eq ${MAXPIDITER} ]] ; then - # The process doesn't want to close after 20 seconds. - # kill it hard. - fn_print_warn "Terminating reluctant Ark process: $pid" - kill -9 $pid - fi - fi # end if for port check + if [[ ${#queryport} -gt 0 ]] ; then + for (( pidcheck=0 ; pidcheck < ${maxpiditer} ; pidcheck++ )) ; do + pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\ + grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\ + rev | cut -d\/ -f1) + # + # check for a valid pid + let pid+=0 # turns an empty string into a valid number, '0', + # and a valid numeric pid remains unchanged. + if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then + fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck" + sleep 1 + else + break # Our job is done here + fi # end if for pid range check + done + if [[ ${pidcheck} -eq ${maxpiditer} ]] ; then + # The process doesn't want to close after 20 seconds. + # kill it hard. + fn_print_warn "Terminating reluctant Ark process: $pid" + kill -9 $pid + fi + fi # end if for port check } # end of fn_stop_ark fn_stop_teamspeak3(){ @@ -208,10 +207,10 @@ fn_stop_teamspeak3(){ # Remove lock file rm -f "${rootdir}/${lockselfname}" fn_print_ok_nl "${servername}" - fn_script_log "Stopped ${servername}" + fn_script_log_pass "Stopped ${servername}" else fn_print_fail_nl "Unable to stop${servername}" - fn_script_log "Unable to stop${servername}" + fn_script_log_fail "Unable to stop${servername}" fi } @@ -227,11 +226,11 @@ fn_stop_tmux(){ # Remove lock file rm -f "${rootdir}/${lockselfname}" # ARK doesn't clean up immediately after tmux is killed. - # Make certain the ports are cleared before continuing. - if [ "${gamename}" == "ARK: Survivial Evolved" ]; then - fn_stop_ark - echo -en "\n" - fi + # Make certain the ports are cleared before continuing. + if [ "${gamename}" == "ARK: Survivial Evolved" ]; then + fn_stop_ark + echo -en "\n" + fi fn_print_ok_nl "${servername}" fn_script_log "Stopped ${servername}" else diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 5b0489c51..832ae7fbf 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -28,15 +28,15 @@ fn_dl_md5(){ fn_print_fail_eol_nl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" - fn_script_log "verifying ${filename} with MD5: FAIL" - fn_script_log "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_script_log "expected MD5 checksum: ${md5}" + fn_script_log_fatal "verifying ${filename} with MD5: FAIL" + fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_script_log_info "expected MD5 checksum: ${md5}" exit 1 else fn_print_ok_eol_nl - fn_script_log "verifying ${filename} with MD5: OK" - fn_script_log "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_script_log "expected MD5 checksum: ${md5}" + fn_script_log_pass "verifying ${filename} with MD5: OK" + fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}" + fn_script_log_info "expected MD5 checksum: ${md5}" fi fi } @@ -62,26 +62,26 @@ fn_dl_extract(){ local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl - fn_script_log "extracting download: FAIL" + fn_script_log_fatal "extracting download: FAIL" echo "${tarcmd}" | tee -a "${scriptlog}" - exit ${exitcode} + core_exit.sh else fn_print_ok_eol_nl fi } # Trap to remove file download if canceled before completed -fn_fetch_trap() { +fn_fetch_trap(){ echo "" echo -ne "downloading ${filename}: " fn_print_canceled_eol_nl - fn_script_log "downloading ${filename}: CANCELED" + fn_script_log_info "downloading ${filename}: CANCELED" sleep 1 rm -f "${filedir}/${filename}" | tee -a "${scriptlog}" echo -ne "downloading ${filename}: " fn_print_removed_eol_nl - fn_script_log "downloading ${filename}: REMOVED" - exit + fn_script_log_info "downloading ${filename}: REMOVED" + core_exit.sh } fn_fetch_file(){ @@ -125,15 +125,15 @@ fn_fetch_file(){ if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl if [ -f "${scriptlog}" ]; then - fn_script_log "downloading ${filename}: FAIL" + fn_script_log_fatal "downloading ${filename}: FAIL" fi echo "${curlcmd}" | tee -a "${scriptlog}" echo -e "${fileurl}\n" | tee -a "${scriptlog}" - exit ${exitcode} + core_exit.sh else fn_print_ok_eol_nl if [ -f "${scriptlog}" ]; then - fn_script_log "downloading ${filename}: OK" + fn_script_log_pass "downloading ${filename}: OK" fi fi # remove trap @@ -142,6 +142,9 @@ fn_fetch_file(){ fn_print_fail_eol_nl echo "Curl is not installed!" echo -e "" + if [ -f "${scriptlog}" ]; then + fn_script_log_fatal "Curl is not installed!" + fi exit 1 fi # make file executecmd if executecmd is set diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh new file mode 100644 index 000000000..70da437cc --- /dev/null +++ b/lgsm/functions/core_exit.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# LGSM core_exit.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description: handles exiting of LGSM by running and reporting an exit code. + +if [ "${exitcode}" != "0" ]; then + if [ "${exitcode}" == "1" ]; then + fn_script_log_fatal "Exiting with exit code: ${exitcode}" + if [ "${exitcode}" == "2" ]; then + fn_script_log_error "Exiting with exit code: ${exitcode}" + if [ "${exitcode}" == "3" ]; then + fn_script_log_warn "Exiting with exit code: ${exitcode}" + else + fn_script_log "Exiting with exit code: ${exitcode}" + fi +else + fn_script_log_pass "Exiting with exit code: ${exitcode}" +fi + +exit ${exitcode} \ No newline at end of file diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index e0b63e585..1e59ca162 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -# Description: Gets specific details server parameters. +# Description: Gets specific details from server parameters. ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo From 77829d393b1b7325d6e9468802d29e7323620b98 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 23 Jun 2016 20:31:40 +0100 Subject: [PATCH 010/195] altered to fatal error --- lgsm/functions/check_ip.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index 514949522..e532d2056 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -18,14 +18,18 @@ if [ "${gamename}" != "Teamspeak 3" ]; then if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then - fn_print_warn "Multiple active network interfaces found.\n\n" + fn_print_fatal "Multiple active network interfaces found.\n\n" + fn_script_log_fatal "Multiple active network interfaces found." echo -en "Manually specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "${getip}\n" echo -en "" echo -en "https://gameservermanagers.com/network-interfaces\n" echo -en "" - exit 1 + fn_script_log_fatal "Multiple active network interfaces found." + fn_script_log_fatal "Manually specify the IP you want to use within the ${selfname} script." + fn_script_log_fatal "https://gameservermanagers.com/network-interfaces\n" + core_exit.sh else ip=${getip} fi From a7ac7adfa25228b751e236f7bc55270c51a74c0f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 23 Jun 2016 20:43:20 +0100 Subject: [PATCH 011/195] elif --- lgsm/functions/core_exit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 70da437cc..7842f3375 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -9,9 +9,9 @@ lgsm_version="210516" if [ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then fn_script_log_fatal "Exiting with exit code: ${exitcode}" - if [ "${exitcode}" == "2" ]; then + elif [ "${exitcode}" == "2" ]; then fn_script_log_error "Exiting with exit code: ${exitcode}" - if [ "${exitcode}" == "3" ]; then + elif [ "${exitcode}" == "3" ]; then fn_script_log_warn "Exiting with exit code: ${exitcode}" else fn_script_log "Exiting with exit code: ${exitcode}" From b077588f36d0763c2c86ff290b3ed162033ee8d1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 00:03:22 +0100 Subject: [PATCH 012/195] More alterations for exitcodes --- lgsm/functions/check_ip.sh | 3 +-- lgsm/functions/check_root.sh | 2 +- lgsm/functions/check_steamcmd.sh | 10 +++++----- lgsm/functions/check_system_dir.sh | 5 +++-- lgsm/functions/check_tmux.sh | 4 ++-- lgsm/functions/command_debug.sh | 6 +++--- lgsm/functions/command_details.sh | 1 + lgsm/functions/command_dev_debug.sh | 3 ++- lgsm/functions/command_install.sh | 1 + lgsm/functions/command_monitor.sh | 3 ++- lgsm/functions/command_start.sh | 5 ++--- lgsm/functions/command_stop.sh | 18 ++++++++---------- lgsm/functions/command_ts3_server_pass.sh | 6 +++--- lgsm/functions/command_update_functions.sh | 1 + 14 files changed, 35 insertions(+), 33 deletions(-) diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index e532d2056..70ee81d31 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -18,8 +18,7 @@ if [ "${gamename}" != "Teamspeak 3" ]; then if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then - fn_print_fatal "Multiple active network interfaces found.\n\n" - fn_script_log_fatal "Multiple active network interfaces found." + fn_print_fail "Multiple active network interfaces found.\n\n" echo -en "Manually specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "${getip}\n" diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index 0ffb7b9d7..bed8f0c9e 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -7,7 +7,7 @@ lgsm_version="210516" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "${selfname} attempted to run as root." + fn_scriptlog_fatal "${selfname} attempted to run as root." fi exit 1 fi diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 56d30a22b..28a5973a9 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -20,18 +20,18 @@ fn_install_steamcmd(){ fn_check_steamcmd_user(){ # Checks steamuser is setup. if [ "${steamuser}" == "username" ]; then - fn_print_fail_nl "Steam login not set. Update steamuser." + fn_print_fail_nl "Steam login not set. Update steamuser in ${selfname}." echo " * Change steamuser=\"username\" to a valid steam login." if [ -d "${scriptlogdir}" ]; then - fn_script_log "edit ${selfname}. change steamuser=\"username\" to a valid steam login." - exit 1 + fn_script_log_fatal "Steam login not set. Update steamuser in ${selfname}." fi + core_exit.sh fi # Anonymous user is set if steamuser is missing if [ -z "${steamuser}" ]; then fn_print_warn_nl "Steam login not set. Using anonymous login." if [ -d "${scriptlogdir}" ]; then - fn_script_log "Steam login not set. Using anonymous login." + fn_script_log_error "Steam login not set. Using anonymous login." fi steamuser="anonymous" steampass="" @@ -48,7 +48,7 @@ fn_check_steamcmd_sh(){ fn_install_steamcmd else fn_print_warn_nl "SteamCMD is missing" - fn_script_log "SteamCMD is missing" + fn_script_log_warn "SteamCMD is missing" sleep 1 fn_install_steamcmd fi diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index 2c8ab795b..54ca646ae 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -7,7 +7,8 @@ lgsm_version="210516" if [ ! -d "${systemdir}" ]; then fn_print_fail_nl "Cannot access ${systemdir}: No such directory" if [ -d "${scriptlogdir}" ]; then - fn_script_log "Cannot access ${systemdir}: No such directory." + fn_script_log_failure "Cannot access ${systemdir}: No such directory." fi - exit 1 + exitcode=1 + core_exit.sh fi diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index 2493d0987..441ad177a 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -11,10 +11,10 @@ if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin else fn_print_fail_nl "Tmux not installed" sleep 1 - fn_script_log "Tmux is not installed" + fn_script_log_fatal "Tmux is not installed" echo " * Tmux is required to run this server." # Suitable passive agressive message echo " * Please see the the following link." echo " * https://gameservermanagers.com/tmux-not-found" - exit 127 + core_exit.sh fi diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 067289659..655c0607a 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -55,10 +55,9 @@ fn_script_log_info "Stopping any running servers" sleep 1 command_stop.sh fn_print_dots "Starting debug" -fn_script_log "Starting debug" +fn_script_log_info "Starting debug" sleep 1 fn_print_ok_nl "Starting debug" -fn_script_log "Started debug" # create lock file. date > "${rootdir}/${lockselfname}" @@ -73,4 +72,5 @@ else fi # remove trap. -trap - INT \ No newline at end of file +trap - INT +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 9096f1f46..68fc38967 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -612,3 +612,4 @@ else fi fn_details_statusbottom +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 34264deca..fe704d146 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -16,4 +16,5 @@ else date > .dev-debug fn_print_ok_nl "Enabled dev-debug" fn_script_log_info "Enabled dev-debug" -fi \ No newline at end of file +fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 49532e9ba..fbf209b81 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -36,3 +36,4 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then fi fix.sh install_complete.sh +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 082f72fcd..d24072faa 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -96,4 +96,5 @@ if [ "${gamename}" == "Teamspeak 3" ]; then fn_monitor_teamspeak3 else fn_monitor_tmux -fi \ No newline at end of file +fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 3408b193c..9dbdca200 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -26,7 +26,6 @@ fn_start_teamspeak3(){ fi fn_print_dots "${servername}" - fn_script_log "${servername}" sleep 1 check_status.sh if [ "${status}" != "0" ]; then @@ -60,7 +59,6 @@ fn_start_teamspeak3(){ fn_start_tmux(){ fn_parms fn_print_dots "${servername}" - fn_script_log "${servername}" sleep 1 # Log rotation @@ -110,7 +108,7 @@ fn_start_tmux(){ elif [ "${consolelogging}" == "off" ]; then touch "${consolelog}" cat "Console logging disabled by user" >> "{consolelog}" - fn_script_log "Console logging disabled by user" + fn_script_log_info "Console logging disabled by user" fi sleep 1 @@ -186,3 +184,4 @@ if [ "${gamename}" == "Teamspeak 3" ]; then else fn_start_tmux fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index ede8c625a..a24833bbf 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -12,7 +12,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ fn_print_dots "Graceful: rcon quit" - fn_script_log "Graceful: rcon quit" + fn_script_log_info "Graceful: rcon quit" # sends quit tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 # waits up to 30 seconds giving the server time to shutdown gracefuly @@ -43,7 +43,7 @@ fn_stop_graceful_source(){ # preventing the server from coming back online. fn_stop_graceful_goldsource(){ fn_print_dots "Graceful: rcon quit" - fn_script_log "Graceful: rcon quit" + fn_script_log_info "Graceful: rcon quit" # sends quit tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1 # waits 3 seconds as goldsource servers restart with the quit command @@ -81,7 +81,7 @@ fn_stop_telnet_sdtd(){ fn_stop_graceful_sdtd(){ fn_print_dots "Graceful: telnet" - fn_script_log "Graceful: telnet" + fn_script_log_info "Graceful: telnet" sleep 1 if [ "${telnetenabled}" == "false" ]; then fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}" @@ -89,7 +89,7 @@ fn_stop_graceful_sdtd(){ # Tries to shutdown with both localhost and server IP. for telnetip in 127.0.0.1 ${ip}; do fn_print_dots "Graceful: telnet: ${telnetip}" - fn_script_log "Graceful: telnet: ${telnetip}" + fn_script_log_info "Graceful: telnet: ${telnetip}" sleep 1 fn_stop_telnet_sdtd completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.") @@ -136,8 +136,6 @@ fn_stop_graceful_sdtd(){ echo -en "\n\n" | tee -a "${scriptlog}" fi else - fn_print_dots "Graceful: telnet: " - fn_script_log "Graceful: telnet: " fn_print_fail "Graceful: telnet: expect not installed: " fn_print_fail_eol_nl fn_script_log_fail "Graceful: telnet: expect not installed: FAIL" @@ -199,7 +197,6 @@ fn_stop_ark(){ fn_stop_teamspeak3(){ fn_print_dots "${servername}" - fn_script_log "${servername}" sleep 1 ${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1 check_status.sh @@ -216,7 +213,7 @@ fn_stop_teamspeak3(){ fn_stop_tmux(){ fn_print_dots "${servername}" - fn_script_log "tmux kill-session: ${servername}" + fn_script_log_info "tmux kill-session: ${servername}" sleep 1 # Kill tmux session tmux kill-session -t "${servicename}" > /dev/null 2>&1 @@ -232,10 +229,10 @@ fn_stop_tmux(){ echo -en "\n" fi fn_print_ok_nl "${servername}" - fn_script_log "Stopped ${servername}" + fn_script_log_pass "Stopped ${servername}" else fn_print_fail_nl "Unable to stop${servername}" - fn_script_log "Unable to stop${servername}" + fn_script_log_error "Unable to stop${servername}" fi } @@ -266,3 +263,4 @@ fn_print_dots "${servername}" fn_script_log "${servername}" sleep 1 fn_stop_pre_check +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 26883b7a7..6b344b72f 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -28,14 +28,14 @@ fn_serveradmin_password_prompt(){ * ) echo "Please answer yes or no.";; esac done - fn_script_log "Initiating ${gamename} ServerAdmin password change" + fn_script_log_info "Initiating ${gamename} ServerAdmin password change" read -p "Enter new password : " newpassword } fn_serveradmin_password_set(){ fn_print_info_nl "Applying new password" - fn_script_log "Applying new password" + fn_script_log_info "Applying new password" sleep 1 # Stop any running server command_stop.sh @@ -47,7 +47,7 @@ fn_serveradmin_password_prompt(){ command_stop.sh ts3serverpass="0" fn_print_ok_nl "Password applied" - fn_script_log "New ServerAdmin password applied" + fn_script_log_pass "New ServerAdmin password applied" sleep 1 } diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index d97bdc4e8..214849472 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -33,6 +33,7 @@ if [ "${exitcode}" == "0" ]; then fn_script_log "Success! Updating functions" else fn_print_fail "Updating functions" + fn_script_log "Failure! Updating functions" fi echo -ne "\n" \ No newline at end of file From 3d507d8d7310d070ed9ad8f023c45d3ff31f9f25 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 17:32:02 +0100 Subject: [PATCH 013/195] removed exit on pass --- lgsm/functions/core_exit.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 7842f3375..863460ae4 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -8,16 +8,18 @@ lgsm_version="210516" if [ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then - fn_script_log_fatal "Exiting with exit code: ${exitcode}" + fn_script_log_fatal "Exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then - fn_script_log_error "Exiting with exit code: ${exitcode}" + fn_script_log_error "Exiting with code: ${exitcode}" elif [ "${exitcode}" == "3" ]; then - fn_script_log_warn "Exiting with exit code: ${exitcode}" + fn_script_log_warn "Exiting with code: ${exitcode}" else - fn_script_log "Exiting with exit code: ${exitcode}" + fn_script_log "Exiting with code: ${exitcode}" fi -else - fn_script_log_pass "Exiting with exit code: ${exitcode}" + exit ${exitcode} +fi + +if [ -f ".dev-debug" ]; then + echo "Exiting with code: ${exitcode}" fi -exit ${exitcode} \ No newline at end of file From 7dc2a723d1e5c8442bb929e4b0e497e46cbc29a3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 17:40:55 +0100 Subject: [PATCH 014/195] stopped exit from running if no exitcode --- lgsm/functions/core_exit.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 863460ae4..bc2e1717d 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: handles exiting of LGSM by running and reporting an exit code. -if [ "${exitcode}" != "0" ]; then +if [ -n "${exitcode}" ]||[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then fn_script_log_fatal "Exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then @@ -17,6 +17,8 @@ if [ "${exitcode}" != "0" ]; then fn_script_log "Exiting with code: ${exitcode}" fi exit ${exitcode} +else + exitcode=0 fi if [ -f ".dev-debug" ]; then From 907ae11233e0660aa26cb04695297bacd7aa9b4e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 17:44:31 +0100 Subject: [PATCH 015/195] and not or --- lgsm/functions/core_exit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index bc2e1717d..cc3041fa2 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: handles exiting of LGSM by running and reporting an exit code. -if [ -n "${exitcode}" ]||[ "${exitcode}" != "0" ]; then +if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then fn_script_log_fatal "Exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then From 3f22dc1ef5702b10034a2c7778a1168155104a4d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 17:53:38 +0100 Subject: [PATCH 016/195] converted more to exitcodes --- lgsm/functions/command_test_alert.sh | 1 + lgsm/functions/command_ts3_server_pass.sh | 3 ++- lgsm/functions/command_update_functions.sh | 12 +++++++----- lgsm/functions/command_validate.sh | 4 ++-- lgsm/functions/compress_ut99_maps.sh | 1 + lgsm/functions/core_exit.sh | 3 +-- lgsm/functions/core_functions.sh | 3 --- lgsm/functions/core_getopt.sh | 1 + lgsm/functions/fix.sh | 7 ++++--- lgsm/functions/fix_ins.sh | 4 ++-- lgsm/functions/install_complete.sh | 3 ++- 11 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index 339cfeec8..c1c105a01 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -13,3 +13,4 @@ check.sh info_config.sh alert="test" alert.sh +core_exit.sh diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 6b344b72f..2ec6d52d8 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -60,4 +60,5 @@ if [ "${status}" != "0" ]; then command_start.sh else fn_serveradmin_password_set -fi \ No newline at end of file +fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 214849472..5069c43f9 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -9,7 +9,7 @@ lgsm_version="210516" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" -fn_script_log "Updating functions" +fn_script_log_info "Updating functions" sleep 1 echo -ne "\n" @@ -30,10 +30,12 @@ fi if [ "${exitcode}" == "0" ]; then fn_print_ok "Updating functions" - fn_script_log "Success! Updating functions" + fn_script_log_pass "Success! Updating functions" + exitcode=0 else fn_print_fail "Updating functions" - - fn_script_log "Failure! Updating functions" + fn_script_log_fatal "Failure! Updating functions" + exitcode=1 fi -echo -ne "\n" \ No newline at end of file +echo -ne "\n" +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 7d917f002..9826b6b7f 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -17,7 +17,7 @@ fn_validation(){ fn_print_dots "Checking server files" sleep 1 fn_print_ok "Checking server files" - fn_script_log "Checking server files" + fn_script_log_info "Checking server files" sleep 1 cd "${rootdir}/steamcmd" @@ -35,7 +35,7 @@ fn_validation(){ fi fix.sh - fn_script_log "Checking complete" + fn_script_log_info "Checking complete" } check_status.sh diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index bb5f78630..ac52a9e4e 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -33,3 +33,4 @@ for map in "${filesdir}/Maps/"*; do ./ucc-bin compress "${map}" --nohomedir done mv -fv "${filesdir}/Maps/"*.unr.uz "${compressedmapsdir}" +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index cc3041fa2..c5b0028dc 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,5 +23,4 @@ fi if [ -f ".dev-debug" ]; then echo "Exiting with code: ${exitcode}" -fi - +fi \ No newline at end of file diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 3b8b02a62..1adeb7f81 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -159,9 +159,6 @@ fn_fetch_function fn_restart(){ local modulename="Restarting" info_config.sh -if [ -d "${scriptlogdir}" ]; then - fn_script_log "${servername}" -fi command_stop.sh command_start.sh } diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 15f44944f..c68e9e663 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -439,3 +439,4 @@ elif [ "${engine}" == "unreal" ]; then else fn_getopt_generic fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index ea1271eed..f012b706f 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -12,17 +12,18 @@ fn_fix_msg_start(){ fn_print_dots "Applying ${fixname} fix: ${gamename}" sleep 1 fn_print_info "Applying ${fixname} fix: ${gamename}" - fn_script_log "Applying ${fixname} fix: ${gamename}" + fn_script_log_info "Applying ${fixname} fix: ${gamename}" sleep 1 } fn_fix_msg_end(){ if [ $? -ne 0 ]; then fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_script_log "Failure! Applying ${fixname} fix: ${gamename}" + fn_script_log_error "Failure! Applying ${fixname} fix: ${gamename}" + exitcode=2 else fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_script_log "Complete! Applying ${fixname} fix: ${gamename}" + fn_script_log_pass "Complete! Applying ${fixname} fix: ${gamename}" fi } diff --git a/lgsm/functions/fix_ins.sh b/lgsm/functions/fix_ins.sh index 3e86c070f..81a206d84 100644 --- a/lgsm/functions/fix_ins.sh +++ b/lgsm/functions/fix_ins.sh @@ -13,7 +13,7 @@ export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH} # fix for issue #529 - gamemode not passed to debug or start if [ "${function_selfname}" == "command_debug.sh" ]; then - defaultmap="\"${defaultmap}\"" + defaultmap="\"${defaultmap}\"" else - defaultmap="\\\"${defaultmap}\\\"" + defaultmap="\\\"${defaultmap}\\\"" fi diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index cd3b237e5..6f9c9c8fa 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -14,8 +14,9 @@ if [ "${gamename}" == "Don't Starve Together" ]; then fi echo "=================================" echo "Install Complete!" -fn_script_log "Install Complete!" +fn_script_log_info "Install Complete!" echo "" echo "To start server type:" echo "./${selfname} start" echo "" +core_exit.sh \ No newline at end of file From 1af3ce47ce655336cdd2351265bc768792fa9624 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 17:59:32 +0100 Subject: [PATCH 017/195] added sleep and absolute location of .dev-debug --- lgsm/functions/core_exit.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index c5b0028dc..27ad162d8 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -21,6 +21,7 @@ else exitcode=0 fi -if [ -f ".dev-debug" ]; then +if [ -f "${rootdir}/.dev-debug" ]; then + sleep 0.5 echo "Exiting with code: ${exitcode}" fi \ No newline at end of file From a2a8208fe7b6c0192af1fed1e6b7e93cb1ef83e3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:02:02 +0100 Subject: [PATCH 018/195] warn --- lgsm/functions/core_exit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 27ad162d8..9704b0115 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -14,7 +14,7 @@ if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then elif [ "${exitcode}" == "3" ]; then fn_script_log_warn "Exiting with code: ${exitcode}" else - fn_script_log "Exiting with code: ${exitcode}" + fn_script_log_warn "Exiting with code: ${exitcode}" fi exit ${exitcode} else From e385f56638611f183db1ec7824cf850d90742cd3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:07:07 +0100 Subject: [PATCH 019/195] altered to exitcodes --- lgsm/functions/command_monitor.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index d24072faa..cc4d3b453 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -16,7 +16,7 @@ fn_monitor_check_lockfile(){ fn_print_info_nl "Disabled: No lock file found" fn_script_log_info "Disabled: No lock file found" echo " * To enable monitor run ./${selfname} start" - exit 1 + core_exit.sh fi } @@ -26,7 +26,7 @@ fn_monitor_check_update(){ fn_print_info_nl "SteamCMD is currently checking for updates" fn_script_log_info "SteamCMD is currently checking for updates" sleep 1 - exit + core_exit.sh fi } @@ -42,7 +42,7 @@ fn_monitor_teamspeak3(){ fn_print_ok "Checking session: " fn_print_ok_eol_nl fn_script_log_pass "Checking session: OK" - exit + core_exit.sh else fn_print_fail "Checking session: ${ts3error}: " fn_print_fail_eol_nl From 019f078025b59e1bdaa40e4c95dcdc810ff69ebe Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:10:57 +0100 Subject: [PATCH 020/195] exitcode shuffle --- lgsm/functions/command_monitor.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index cc4d3b453..c903b463c 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -42,7 +42,6 @@ fn_monitor_teamspeak3(){ fn_print_ok "Checking session: " fn_print_ok_eol_nl fn_script_log_pass "Checking session: OK" - core_exit.sh else fn_print_fail "Checking session: ${ts3error}: " fn_print_fail_eol_nl @@ -50,10 +49,10 @@ fn_monitor_teamspeak3(){ failurereason="${ts3error}" alert="restart" alert.sh + fn_script_log_info "Monitor is starting ${servername}" + sleep 1 + fn_restart fi - fn_script_log_info "Monitor is starting ${servername}" - sleep 1 - fn_restart } fn_monitor_tmux(){ @@ -70,7 +69,6 @@ fn_monitor_tmux(){ monitor_gsquery.sh fi done - exit else fn_print_fail "Checking session: " fn_print_fail_eol_nl From 8e4c91ab28974f992326f58c680ed29573415d85 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:16:13 +0100 Subject: [PATCH 021/195] exitcode shuffle --- lgsm/functions/monitor_gsquery.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 4a5522ff2..607f3ac96 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -26,7 +26,7 @@ if [ "${gsquery}" == "yes" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then port=$((port + 1)) elif [ "${engine}" == "realvirtuality" ]; then - port=$((port + 1)) + port=$((port + 1)) elif [ "${engine}" == "spark" ]; then port=$((port + 1)) fi @@ -36,7 +36,7 @@ if [ "${gsquery}" == "yes" ]; then fi fn_print_info "Querying port: gsquery.py enabled" - fn_script_log "Querying port: gsquery.py enabled" + fn_script_log_info "Querying port: gsquery.py enabled" sleep 1 # Will query up to 4 times every 15 seconds. @@ -46,7 +46,7 @@ if [ "${gsquery}" == "yes" ]; then for queryattempt in {1..5}; do fn_print_dots "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_querying_eol - fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" + fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : QUERYING" gsquerycmd=$("${functionsdir}"/gsquery.py -a "${ip}" -p "${port}" -e "${engine}" 2>&1) exitcode=$? @@ -56,18 +56,18 @@ if [ "${gsquery}" == "yes" ]; then # Server OK fn_print_ok "Querying port: ${ip}:${port} : ${queryattempt} : " fn_print_ok_eol_nl - fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : OK" - sleep 1 - exit + fn_script_log_pass "Querying port: ${ip}:${port} : ${queryattempt} : OK" + exitcode=0 + break else # Server failed query - fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" + fn_script_log_info "Querying port: ${ip}:${port} : ${queryattempt} : ${gsquerycmd}" if [ "${queryattempt}" == "5" ]; then # Server failed query 4 times confirmed failure fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : " fn_print_fail_eol_nl - fn_script_log "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" + fn_script_log_error "Querying port: ${ip}:${port} : ${queryattempt} : FAIL" sleep 1 # Send alert if enabled From 9b855bc92dc0a021ed60e870021630acd9d19284 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:22:10 +0100 Subject: [PATCH 022/195] removed non required exits --- lgsm/functions/core_getopt.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index c68e9e663..5f9108a08 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -67,7 +67,6 @@ case "$getopt" in echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." } | column -s $'\t' -t esac -exit } fn_getopt_teamspeak3(){ @@ -121,7 +120,6 @@ case "$getopt" in echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." } | column -s $'\t' -t esac -exit } fn_getopt_mumble(){ @@ -166,7 +164,6 @@ case "$getopt" in echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." } | column -s $'\t' -t esac -exit } fn_getopt_gmodserver(){ @@ -233,7 +230,6 @@ case "$getopt" in echo -e "\e[34mfastdl\t\e[0mfd |Generates or update a FastDL folder for your server." } | column -s $'\t' -t esac -exit } fn_getopt_unreal(){ @@ -290,7 +286,6 @@ case "$getopt" in echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac -exit } @@ -358,7 +353,6 @@ case "$getopt" in echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac -exit } @@ -419,7 +413,6 @@ case "$getopt" in echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac -exit } if [ "${gamename}" == "Mumble" ]; then From e880fda8fefc8a2db62232585cf5ba67c4d1f134 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:26:30 +0100 Subject: [PATCH 023/195] Removed local from module name as for functions only --- lgsm/functions/alert_email.sh | 2 +- lgsm/functions/alert_pushbullet.sh | 2 +- lgsm/functions/command_backup.sh | 2 +- lgsm/functions/command_console.sh | 2 +- lgsm/functions/command_debug.sh | 2 +- lgsm/functions/command_dev_detect_deps.sh | 2 +- lgsm/functions/command_fastdl.sh | 2 +- lgsm/functions/command_install.sh | 2 +- lgsm/functions/command_monitor.sh | 2 +- lgsm/functions/command_start.sh | 2 +- lgsm/functions/command_stop.sh | 2 +- lgsm/functions/command_test_alert.sh | 2 +- lgsm/functions/command_ts3_server_pass.sh | 2 +- lgsm/functions/command_validate.sh | 2 +- lgsm/functions/core_exit.sh | 2 +- lgsm/functions/core_functions.sh | 2 +- lgsm/functions/install_complete.sh | 2 +- lgsm/functions/install_config.sh | 2 +- lgsm/functions/install_gslt.sh | 2 +- lgsm/functions/install_header.sh | 2 +- lgsm/functions/install_logs.sh | 2 +- lgsm/functions/install_retry.sh | 2 +- lgsm/functions/install_server_dir.sh | 2 +- lgsm/functions/install_server_files.sh | 2 +- lgsm/functions/install_steamcmd.sh | 2 +- lgsm/functions/install_ts3.sh | 2 +- lgsm/functions/install_ts3db.sh | 2 +- lgsm/functions/install_ut2k4_key.sh | 2 +- lgsm/functions/logs.sh | 2 +- lgsm/functions/monitor_gsquery.sh | 2 +- lgsm/functions/update_check.sh | 2 +- lgsm/functions/update_dl.sh | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 3f29219e1..716cc84a6 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Sends email alert if monitor picks up a failure. -local modulename="Alert" +modulename="Alert" fn_details_email(){ diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 10a704190..bca8e2547 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: alerts using pushbullet. -local modulename="Alert" +modulename="Alert" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index a9f8f74eb..71264b5c9 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Creates a .tar.gz file in the backup directory. -local modulename="Backup" +modulename="Backup" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index e12234f9d..5e23788d7 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Gives access to the server tmux console. -local modulename="Console" +modulename="Console" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 655c0607a..73333eb4e 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs the server without tmux. Runs direct from the terminal. -local modulename="Debug" +modulename="Debug" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Trap to remove lockfile on quit. diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index a80fdb4c9..c9cb3cf9f 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Detects dependencies the server binary requires. -local modulename="Backup" +modulename="Backup" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 2a11050c4..a962912c0 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -7,7 +7,7 @@ lgsm_version="060616" # Description: Creates a FastDL folder -local modulename="FastDL" +modulename="FastDL" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index fbf209b81..e0fbad091 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Overall function for the installer. -local modulename="Install" +modulename="Install" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index c903b463c..50b23677f 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Monitors server by checking for running proccesses # then passes to monitor_gsquery.sh. -local modulename="Monitor" +modulename="Monitor" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 9dbdca200..d957c31c6 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Starts the server. -local modulename="Starting" +modulename="Starting" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index a24833bbf..dd75fcf28 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -6,7 +6,7 @@ lgsm_version="050616" # Description: Stops the server. -local modulename="Stopping" +modulename="Stopping" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index c1c105a01..9fd6eedef 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Sends a test email alert. -local modulename="Alert" +modulename="Alert" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 2ec6d52d8..023b32c2d 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Changes TS3 serveradmin password -local modulename="Change password" +modulename="Change password" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 9826b6b7f..50c4aa975 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs a server validation. -local modulename="Validate" +modulename="Validate" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 9704b0115..6e59918ec 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,5 +23,5 @@ fi if [ -f "${rootdir}/.dev-debug" ]; then sleep 0.5 - echo "Exiting with code: ${exitcode}" + echo "${modulename} Exiting with code: ${exitcode}" fi \ No newline at end of file diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 1adeb7f81..8e97962a1 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -157,7 +157,7 @@ fn_fetch_function } fn_restart(){ -local modulename="Restarting" +modulename="Restarting" info_config.sh command_stop.sh command_start.sh diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index 6f9c9c8fa..bf61286ae 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" if [ "${gamename}" == "Don't Starve Together" ]; then echo "" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index d19eaeddd..57c387af2 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" fn_defaultconfig(){ echo "creating ${servercfg} config file." diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index f7dc596ef..38edd9f68 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Configures GSLT. -local modulename="Install" +modulename="Install" echo "" echo "Game Server Login Token" diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index 96c56a209..e0a5047cb 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" clear echo "=================================" diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index e077ee8ab..3dd932824 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" if [ "${checklogs}" != "1" ]; then echo "" diff --git a/lgsm/functions/install_retry.sh b/lgsm/functions/install_retry.sh index 80df1a6ba..1d5dc5471 100644 --- a/lgsm/functions/install_retry.sh +++ b/lgsm/functions/install_retry.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" while true; do read -e -i "y" -p "Retry install? [Y/n]" yn diff --git a/lgsm/functions/install_server_dir.sh b/lgsm/functions/install_server_dir.sh index c9aabc829..8d50f91ff 100644 --- a/lgsm/functions/install_server_dir.sh +++ b/lgsm/functions/install_server_dir.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" echo "" echo "Server Directory" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 2438b1c01..e0ba0fb22 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="270516" -local modulename="Install" +modulename="Install" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index 7c733d289..b9384b5ea 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Downloads SteamCMD on install. -local modulename="Install" +modulename="Install" echo "" echo "Installing SteamCMD" diff --git a/lgsm/functions/install_ts3.sh b/lgsm/functions/install_ts3.sh index 44d2b4231..4c0c439cf 100644 --- a/lgsm/functions/install_ts3.sh +++ b/lgsm/functions/install_ts3.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" info_distro.sh # Gets the teamspeak server architecture diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index e2027a42b..15ac644dd 100644 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -5,7 +5,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" fn_install_ts3db_mariadb(){ echo "" diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 212cfba25..1b14bdeea 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -local modulename="Install" +modulename="Install" echo "" echo "Enter ${gamename} CD Key" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index 03682368e..9bf33f504 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Acts as a log rotater, removing old logs. -local modulename="Log Manager" +modulename="Log Manager" # Check if logfile variable and file exist, create logfile if it doesn't exist if [ -n "${consolelog}" ]; then diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 607f3ac96..4813786a0 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. -local modulename="Monitor" +modulename="Monitor" # Forces legecy servers to use gsquery if [ -z "${gsquery}" ]; then diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 716889b43..ee73b1558 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Checks if a server update is available. -local modulename="Update" +modulename="Update" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### SteamCMD Update Checker ### diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index 5d5fb6ced..f1332e8b9 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs a server update. -local modulename="Update" +modulename="Update" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ From 38b07557dcb9687de18d6e015901cb2338b7db03 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:29:28 +0100 Subject: [PATCH 024/195] renamed to function_selfname --- lgsm/functions/core_exit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 6e59918ec..516924561 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,5 +23,5 @@ fi if [ -f "${rootdir}/.dev-debug" ]; then sleep 0.5 - echo "${modulename} Exiting with code: ${exitcode}" + echo "${function_selfname} Exiting with code: ${exitcode}" fi \ No newline at end of file From 3262ad89031b125159173c94bd7824cc31b6548e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 18:38:01 +0100 Subject: [PATCH 025/195] e --- lgsm/functions/core_exit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 516924561..4fbda5605 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,5 +23,5 @@ fi if [ -f "${rootdir}/.dev-debug" ]; then sleep 0.5 - echo "${function_selfname} Exiting with code: ${exitcode}" + echo "${function_selfname} exiting with code: ${exitcode}" fi \ No newline at end of file From 6deeb0a7061535fa547c1b2f3de3b7c1b3e5be23 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 20:26:31 +0100 Subject: [PATCH 026/195] Resshuffled code to better suite exitcodes --- lgsm/functions/command_start.sh | 157 ++++++++++++++++---------------- 1 file changed, 77 insertions(+), 80 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index d957c31c6..7ba854854 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -74,97 +74,94 @@ fn_start_tmux(){ mv "${consolelog}" "${consolelogdate}" fi - # If server is already running exit check_status.sh if [ "${status}" != "0" ]; then + # If server is already running exit fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" - core_exit.sh - fi - - # Create lock file - date > "${rootdir}/${lockselfname}" - cd "${executabledir}" - tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" - - # tmux pipe-pane not supported in tmux versions < 1.6 - if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then - echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" - - # Console logging disabled: Bug in tmux 1.8 breaks logging - elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then - echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" - - # Console logging enable or not set - elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then - touch "${consolelog}" - tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" - - # Console logging disabled - elif [ "${consolelogging}" == "off" ]; then - touch "${consolelog}" - cat "Console logging disabled by user" >> "{consolelog}" - fn_script_log_info "Console logging disabled by user" - fi - sleep 1 - - # If the server fails to start - check_status.sh - if [ "${status}" == "0" ]; then - fn_print_fail_nl "Unable to start ${servername}" - fn_script_log_fatal "Unable to start ${servername}" + else + # Create lock file + date > "${rootdir}/${lockselfname}" + + # Start session + cd "${executabledir}" + tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" + + ## Console logging + # tmux pipe-pane not supported in tmux versions < 1.6 + if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then + echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" + # Console logging disabled: Bug in tmux 1.8 breaks logging + elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then + echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" + # Console logging enable or not set + elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then + touch "${consolelog}" + tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" + # Console logging disabled + elif [ "${consolelogging}" == "off" ]; then + touch "${consolelog}" + cat "Console logging disabled by user" >> "{consolelog}" + fn_script_log_info "Console logging disabled by user" + fi sleep 1 - if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then - fn_print_fail_nl "Unable to start ${servername}: Tmux error:" - fn_script_log_fatal "Unable to start ${servername}: Tmux error:" - echo "" - echo "Command" - echo "=================================" - echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}" - echo "" - echo "Error" - echo "=================================" - cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}" - # Detected error https://gameservermanagers.com/issues - if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then - echo "" - echo "Fix" - echo "=================================" - if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then - echo "$(whoami) is not part of the tty group." - fn_script_log_info "$(whoami) is not part of the tty group." - group=$(grep tty /etc/group) - echo "" - echo " ${group}" - fn_script_log_info "${group}" + # Check if the server fails to start + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_fail_nl "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" + sleep 1 + if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then + fn_print_fail_nl "Unable to start ${servername}: Tmux error:" + fn_script_log_fatal "Unable to start ${servername}: Tmux error:" + echo "" + echo "Command" + echo "=================================" + echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}" + echo "" + echo "Error" + echo "=================================" + cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}" + + # Detected error https://gameservermanagers.com/issues + if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then echo "" - echo "Run the following command with root privileges." - echo "" - echo " usermod -G tty $(whoami)" - echo "" - echo "https://gameservermanagers.com/tmux-op-perm" - fn_script_log_info "https://gameservermanagers.com/tmux-op-perm" - else - echo "No known fix currently. Please log an issue." - fn_script_log_info "No known fix currently. Please log an issue." - echo "https://gameservermanagers.com/issues" - fn_script_log_info "https://gameservermanagers.com/issues" + echo "Fix" + echo "=================================" + if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then + echo "$(whoami) is not part of the tty group." + fn_script_log_info "$(whoami) is not part of the tty group." + group=$(grep tty /etc/group) + echo "" + echo " ${group}" + fn_script_log_info "${group}" + echo "" + echo "Run the following command with root privileges." + echo "" + echo " usermod -G tty $(whoami)" + echo "" + echo "https://gameservermanagers.com/tmux-op-perm" + fn_script_log_info "https://gameservermanagers.com/tmux-op-perm" + else + echo "No known fix currently. Please log an issue." + fn_script_log_info "No known fix currently. Please log an issue." + echo "https://gameservermanagers.com/issues" + fn_script_log_info "https://gameservermanagers.com/issues" + fi fi fi + else + fn_print_ok "${servername}" + fn_script_log_pass "Started ${servername}" fi - - core_exit.sh - else - fn_print_ok "${servername}" - fn_script_log_pass "Started ${servername}" + rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" + echo -en "\n" fi - rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" - echo -en "\n" } check.sh From 87a2d72297eddf53a8edbb3e47847b04b6682b45 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 20:33:15 +0100 Subject: [PATCH 027/195] updated to ts3server code --- lgsm/functions/command_start.sh | 40 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 7ba854854..34eebc2d6 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -31,28 +31,26 @@ fn_start_teamspeak3(){ if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" - core_exit.sh - fi - - mv "${scriptlog}" "${scriptlogdate}" - # Create lock file - date > "${rootdir}/${lockselfname}" - cd "${executabledir}" - if [ "${ts3serverpass}" == "1" ];then - ./ts3server_startscript.sh start serveradmin_password="${newpassword}" inifile="${servercfgfullpath}" else - ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 - fi - sleep 1 - check_status.sh - if [ "${status}" == "0" ]; then - fn_print_fail_nl "Unable to start ${servername}" - fn_script_log_fatal "Unable to start ${servername}" - echo -e " Check log files: ${rootdir}/log" - core_exit.sh - else - fn_print_ok_nl "${servername}" - fn_script_log_pass "Started ${servername}" + mv "${scriptlog}" "${scriptlogdate}" + # Create lock file + date > "${rootdir}/${lockselfname}" + cd "${executabledir}" + if [ "${ts3serverpass}" == "1" ];then + ./ts3server_startscript.sh start serveradmin_password="${newpassword}" inifile="${servercfgfullpath}" + else + ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 + fi + sleep 1 + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_fail_nl "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" + echo -e " Check log files: ${rootdir}/log" + else + fn_print_ok_nl "${servername}" + fn_script_log_pass "Started ${servername}" + fi fi } From b6c117bca6a369c029cb5cea4b7f9c4084eea3f9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 26 Jun 2016 20:44:49 +0100 Subject: [PATCH 028/195] local modulename may be required after all --- lgsm/functions/alert_email.sh | 2 +- lgsm/functions/alert_pushbullet.sh | 2 +- lgsm/functions/command_backup.sh | 2 +- lgsm/functions/command_console.sh | 2 +- lgsm/functions/command_debug.sh | 2 +- lgsm/functions/command_dev_detect_deps.sh | 2 +- lgsm/functions/command_fastdl.sh | 2 +- lgsm/functions/command_install.sh | 2 +- lgsm/functions/command_monitor.sh | 2 +- lgsm/functions/command_start.sh | 2 +- lgsm/functions/command_stop.sh | 2 +- lgsm/functions/command_test_alert.sh | 2 +- lgsm/functions/command_ts3_server_pass.sh | 2 +- lgsm/functions/command_validate.sh | 2 +- lgsm/functions/core_functions.sh | 2 +- lgsm/functions/install_complete.sh | 2 +- lgsm/functions/install_config.sh | 2 +- lgsm/functions/install_gslt.sh | 2 +- lgsm/functions/install_header.sh | 2 +- lgsm/functions/install_logs.sh | 2 +- lgsm/functions/install_retry.sh | 2 +- lgsm/functions/install_server_dir.sh | 2 +- lgsm/functions/install_server_files.sh | 2 +- lgsm/functions/install_steamcmd.sh | 2 +- lgsm/functions/install_ts3.sh | 2 +- lgsm/functions/install_ts3db.sh | 2 +- lgsm/functions/install_ut2k4_key.sh | 2 +- lgsm/functions/logs.sh | 2 +- lgsm/functions/monitor_gsquery.sh | 2 +- lgsm/functions/update_check.sh | 2 +- lgsm/functions/update_dl.sh | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 716cc84a6..3f29219e1 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Sends email alert if monitor picks up a failure. -modulename="Alert" +local modulename="Alert" fn_details_email(){ diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index bca8e2547..10a704190 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: alerts using pushbullet. -modulename="Alert" +local modulename="Alert" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 71264b5c9..a9f8f74eb 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Creates a .tar.gz file in the backup directory. -modulename="Backup" +local modulename="Backup" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 5e23788d7..e12234f9d 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Gives access to the server tmux console. -modulename="Console" +local modulename="Console" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 73333eb4e..655c0607a 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs the server without tmux. Runs direct from the terminal. -modulename="Debug" +local modulename="Debug" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Trap to remove lockfile on quit. diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index c9cb3cf9f..a80fdb4c9 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Detects dependencies the server binary requires. -modulename="Backup" +local modulename="Backup" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index a962912c0..2a11050c4 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -7,7 +7,7 @@ lgsm_version="060616" # Description: Creates a FastDL folder -modulename="FastDL" +local modulename="FastDL" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index e0fbad091..fbf209b81 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Overall function for the installer. -modulename="Install" +local modulename="Install" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 50b23677f..c903b463c 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Monitors server by checking for running proccesses # then passes to monitor_gsquery.sh. -modulename="Monitor" +local modulename="Monitor" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 34eebc2d6..99e169b2e 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Starts the server. -modulename="Starting" +local modulename="Starting" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index dd75fcf28..a24833bbf 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -6,7 +6,7 @@ lgsm_version="050616" # Description: Stops the server. -modulename="Stopping" +local modulename="Stopping" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index 9fd6eedef..c1c105a01 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Sends a test email alert. -modulename="Alert" +local modulename="Alert" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 023b32c2d..2ec6d52d8 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Changes TS3 serveradmin password -modulename="Change password" +local modulename="Change password" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index a115294f6..c6d023bc3 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs a server validation. -modulename="Validate" +local modulename="Validate" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 8e97962a1..1adeb7f81 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -157,7 +157,7 @@ fn_fetch_function } fn_restart(){ -modulename="Restarting" +local modulename="Restarting" info_config.sh command_stop.sh command_start.sh diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index bf61286ae..6f9c9c8fa 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" if [ "${gamename}" == "Don't Starve Together" ]; then echo "" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 57c387af2..d19eaeddd 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" fn_defaultconfig(){ echo "creating ${servercfg} config file." diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index 38edd9f68..f7dc596ef 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Configures GSLT. -modulename="Install" +local modulename="Install" echo "" echo "Game Server Login Token" diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index e0a5047cb..96c56a209 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" clear echo "=================================" diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index 3dd932824..e077ee8ab 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" if [ "${checklogs}" != "1" ]; then echo "" diff --git a/lgsm/functions/install_retry.sh b/lgsm/functions/install_retry.sh index 1d5dc5471..80df1a6ba 100644 --- a/lgsm/functions/install_retry.sh +++ b/lgsm/functions/install_retry.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" while true; do read -e -i "y" -p "Retry install? [Y/n]" yn diff --git a/lgsm/functions/install_server_dir.sh b/lgsm/functions/install_server_dir.sh index 8d50f91ff..c9aabc829 100644 --- a/lgsm/functions/install_server_dir.sh +++ b/lgsm/functions/install_server_dir.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" echo "" echo "Server Directory" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index ec6ef2b7a..eeef6fd54 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="270516" -modulename="Install" +local modulename="Install" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index b9384b5ea..7c733d289 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Downloads SteamCMD on install. -modulename="Install" +local modulename="Install" echo "" echo "Installing SteamCMD" diff --git a/lgsm/functions/install_ts3.sh b/lgsm/functions/install_ts3.sh index 4c0c439cf..44d2b4231 100644 --- a/lgsm/functions/install_ts3.sh +++ b/lgsm/functions/install_ts3.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" info_distro.sh # Gets the teamspeak server architecture diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index 15ac644dd..e2027a42b 100644 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -5,7 +5,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" fn_install_ts3db_mariadb(){ echo "" diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 1b14bdeea..212cfba25 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -modulename="Install" +local modulename="Install" echo "" echo "Enter ${gamename} CD Key" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index 9bf33f504..03682368e 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Acts as a log rotater, removing old logs. -modulename="Log Manager" +local modulename="Log Manager" # Check if logfile variable and file exist, create logfile if it doesn't exist if [ -n "${consolelog}" ]; then diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 4813786a0..607f3ac96 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. -modulename="Monitor" +local modulename="Monitor" # Forces legecy servers to use gsquery if [ -z "${gsquery}" ]; then diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index ee73b1558..716889b43 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Checks if a server update is available. -modulename="Update" +local modulename="Update" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### SteamCMD Update Checker ### diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index ad5ed688e..02437aa00 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Runs a server update. -modulename="Update" +local modulename="Update" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ From f9fe306ce6691d842d7c1e9fcf2bdda9708683c9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:15:09 +0100 Subject: [PATCH 029/195] Revert "Resshuffled code to better suite exitcodes" This reverts commit 6deeb0a7061535fa547c1b2f3de3b7c1b3e5be23. --- lgsm/functions/command_start.sh | 155 ++++++++++++++++---------------- 1 file changed, 79 insertions(+), 76 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 99e169b2e..abaa507f3 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -72,94 +72,97 @@ fn_start_tmux(){ mv "${consolelog}" "${consolelogdate}" fi + # If server is already running exit check_status.sh if [ "${status}" != "0" ]; then - # If server is already running exit fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" - else - # Create lock file - date > "${rootdir}/${lockselfname}" + core_exit.sh + fi - # Start session - cd "${executabledir}" - tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" - - ## Console logging - # tmux pipe-pane not supported in tmux versions < 1.6 - if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then - echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" - # Console logging disabled: Bug in tmux 1.8 breaks logging - elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then - echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" - echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" - echo "Currently installed: $(tmux -V)" >> "${consolelog}" - # Console logging enable or not set - elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then - touch "${consolelog}" - tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" - # Console logging disabled - elif [ "${consolelogging}" == "off" ]; then - touch "${consolelog}" - cat "Console logging disabled by user" >> "{consolelog}" - fn_script_log_info "Console logging disabled by user" - fi + # Create lock file + date > "${rootdir}/${lockselfname}" + cd "${executabledir}" + tmux new-session -d -s "${servicename}" "${executable} ${parms}" 2> "${scriptlogdir}/.${servicename}-tmux-error.tmp" + + # tmux pipe-pane not supported in tmux versions < 1.6 + if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then + echo "Console logging disabled: Tmux => 1.6 required" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" + + # Console logging disabled: Bug in tmux 1.8 breaks logging + elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then + echo "Console logging disabled: Bug in tmux 1.8 breaks logging" >> "${consolelog}" + echo "https://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" + echo "Currently installed: $(tmux -V)" >> "${consolelog}" + + # Console logging enable or not set + elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then + touch "${consolelog}" + tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'" + + # Console logging disabled + elif [ "${consolelogging}" == "off" ]; then + touch "${consolelog}" + cat "Console logging disabled by user" >> "{consolelog}" + fn_script_log_info "Console logging disabled by user" + fi + sleep 1 + + # If the server fails to start + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_fail_nl "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" sleep 1 + if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then + fn_print_fail_nl "Unable to start ${servername}: Tmux error:" + fn_script_log_fatal "Unable to start ${servername}: Tmux error:" + echo "" + echo "Command" + echo "=================================" + echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}" + echo "" + echo "Error" + echo "=================================" + cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}" - # Check if the server fails to start - check_status.sh - if [ "${status}" == "0" ]; then - fn_print_fail_nl "Unable to start ${servername}" - fn_script_log_fatal "Unable to start ${servername}" - sleep 1 - if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then - fn_print_fail_nl "Unable to start ${servername}: Tmux error:" - fn_script_log_fatal "Unable to start ${servername}: Tmux error:" - echo "" - echo "Command" - echo "=================================" - echo "tmux new-session -d -s \"${servicename}\" \"${executable} ${parms}\"" | tee -a "${scriptlog}" - echo "" - echo "Error" - echo "=================================" - cat "${scriptlogdir}/.${servicename}-tmux-error.tmp" | tee -a "${scriptlog}" - - # Detected error https://gameservermanagers.com/issues - if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then + # Detected error https://gameservermanagers.com/issues + if [ $(grep -c "Operation not permitted" "${scriptlogdir}/.${servicename}-tmux-error.tmp") ]; then + echo "" + echo "Fix" + echo "=================================" + if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then + echo "$(whoami) is not part of the tty group." + fn_script_log_info "$(whoami) is not part of the tty group." + group=$(grep tty /etc/group) + echo "" + echo " ${group}" + fn_script_log_info "${group}" echo "" - echo "Fix" - echo "=================================" - if [ ! $(grep "tty:" /etc/group|grep "$(whoami)") ]; then - echo "$(whoami) is not part of the tty group." - fn_script_log_info "$(whoami) is not part of the tty group." - group=$(grep tty /etc/group) - echo "" - echo " ${group}" - fn_script_log_info "${group}" - echo "" - echo "Run the following command with root privileges." - echo "" - echo " usermod -G tty $(whoami)" - echo "" - echo "https://gameservermanagers.com/tmux-op-perm" - fn_script_log_info "https://gameservermanagers.com/tmux-op-perm" - else - echo "No known fix currently. Please log an issue." - fn_script_log_info "No known fix currently. Please log an issue." - echo "https://gameservermanagers.com/issues" - fn_script_log_info "https://gameservermanagers.com/issues" - fi + echo "Run the following command with root privileges." + echo "" + echo " usermod -G tty $(whoami)" + echo "" + echo "https://gameservermanagers.com/tmux-op-perm" + fn_script_log_info "https://gameservermanagers.com/tmux-op-perm" + else + echo "No known fix currently. Please log an issue." + fn_script_log_info "No known fix currently. Please log an issue." + echo "https://gameservermanagers.com/issues" + fn_script_log_info "https://gameservermanagers.com/issues" fi fi - else - fn_print_ok "${servername}" - fn_script_log_pass "Started ${servername}" fi - rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" - echo -en "\n" + + core_exit.sh + else + fn_print_ok "${servername}" + fn_script_log_pass "Started ${servername}" fi + rm "${scriptlogdir}/.${servicename}-tmux-error.tmp" + echo -en "\n" } check.sh From 4a363c67bfd3cded9e70a0d9d822bd1c47120fa0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:15:13 +0100 Subject: [PATCH 030/195] Revert "updated to ts3server code" This reverts commit 87a2d72297eddf53a8edbb3e47847b04b6682b45. --- lgsm/functions/command_start.sh | 40 +++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index abaa507f3..9dbdca200 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -31,26 +31,28 @@ fn_start_teamspeak3(){ if [ "${status}" != "0" ]; then fn_print_info_nl "${servername} is already running" fn_script_log_error "${servername} is already running" + core_exit.sh + fi + + mv "${scriptlog}" "${scriptlogdate}" + # Create lock file + date > "${rootdir}/${lockselfname}" + cd "${executabledir}" + if [ "${ts3serverpass}" == "1" ];then + ./ts3server_startscript.sh start serveradmin_password="${newpassword}" inifile="${servercfgfullpath}" else - mv "${scriptlog}" "${scriptlogdate}" - # Create lock file - date > "${rootdir}/${lockselfname}" - cd "${executabledir}" - if [ "${ts3serverpass}" == "1" ];then - ./ts3server_startscript.sh start serveradmin_password="${newpassword}" inifile="${servercfgfullpath}" - else - ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 - fi - sleep 1 - check_status.sh - if [ "${status}" == "0" ]; then - fn_print_fail_nl "Unable to start ${servername}" - fn_script_log_fatal "Unable to start ${servername}" - echo -e " Check log files: ${rootdir}/log" - else - fn_print_ok_nl "${servername}" - fn_script_log_pass "Started ${servername}" - fi + ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1 + fi + sleep 1 + check_status.sh + if [ "${status}" == "0" ]; then + fn_print_fail_nl "Unable to start ${servername}" + fn_script_log_fatal "Unable to start ${servername}" + echo -e " Check log files: ${rootdir}/log" + core_exit.sh + else + fn_print_ok_nl "${servername}" + fn_script_log_pass "Started ${servername}" fi } From eb74cfa4599665c449f21a66ebfe4a1e50c0a4a8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:15:40 +0100 Subject: [PATCH 031/195] core_exit --- lgsm/functions/check_root.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index bed8f0c9e..d7a0eb100 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -9,5 +9,5 @@ if [ $(whoami) = "root" ]; then if [ -d "${scriptlogdir}" ]; then fn_scriptlog_fatal "${selfname} attempted to run as root." fi - exit 1 + core_exit.sh fi From c3e0d4352122a51c8c934ec92034139464546d69 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:22:51 +0100 Subject: [PATCH 032/195] restart now has its own script --- lgsm/functions/command_restart.sh | 15 +++++++++++++++ lgsm/functions/core_functions.sh | 8 +++----- 2 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 lgsm/functions/command_restart.sh diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh new file mode 100644 index 000000000..35f85b639 --- /dev/null +++ b/lgsm/functions/command_restart.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# LGSM command_start.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description: Starts the server. + +local modulename="Restarting" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +restart=1 +info_config.sh +command_stop.sh +command_start.sh \ No newline at end of file diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 1adeb7f81..22ca78f4f 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -156,11 +156,9 @@ functionfile="${FUNCNAME}" fn_fetch_function } -fn_restart(){ -local modulename="Restarting" -info_config.sh -command_stop.sh -command_start.sh +command_restart.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function } From da01a06127215a0fbe7fe1d575804dd52b3abf7c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:24:28 +0100 Subject: [PATCH 033/195] command_restart.sh --- lgsm/functions/core_getopt.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 5f9108a08..eb0bd3c58 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -13,7 +13,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; u|update) update_check.sh;; fu|force-update|update-restart) @@ -76,7 +76,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; u|update) update_check.sh;; uf|update-functions) @@ -129,7 +129,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; uf|update-functions) command_update_functions.sh;; m|monitor) @@ -173,7 +173,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; u|update) update_check.sh;; fu|force-update|update-restart) @@ -239,7 +239,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; uf|update-functions) command_update_functions.sh;; m|monitor) @@ -296,7 +296,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; u|update) update_check.sh;; fu|force-update|update-restart) @@ -363,7 +363,7 @@ case "$getopt" in sp|stop) command_stop.sh;; r|restart) - fn_restart;; + command_restart.sh;; uf|update-functions) command_update_functions.sh;; m|monitor) From cf95c40de808ae7b6424852bc1fbc46764d2e924 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 27 Jun 2016 23:48:12 +0100 Subject: [PATCH 034/195] setting up an exit bypass --- lgsm/functions/command_debug.sh | 1 + lgsm/functions/command_restart.sh | 2 +- lgsm/functions/core_exit.sh | 24 ++++++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 655c0607a..a0452f6ff 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -53,6 +53,7 @@ done fn_print_info_nl "Stopping any running servers" fn_script_log_info "Stopping any running servers" sleep 1 +exitbypass=1 command_stop.sh fn_print_dots "Starting debug" fn_script_log_info "Starting debug" diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 35f85b639..23a9d6e60 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -9,7 +9,7 @@ lgsm_version="210516" local modulename="Restarting" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -restart=1 +exitbypass=1 info_config.sh command_stop.sh command_start.sh \ No newline at end of file diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 4fbda5605..bfef50e7b 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -6,22 +6,30 @@ lgsm_version="210516" # Description: handles exiting of LGSM by running and reporting an exit code. +fn_exit_dev_debug(){ + if [ -f "${rootdir}/.dev-debug" ]; then + echo "${function_selfname} exiting with code: ${exitcode}" + fi +} + if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then - fn_script_log_fatal "Exiting with code: ${exitcode}" + fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then - fn_script_log_error "Exiting with code: ${exitcode}" + fn_script_log_error "${function_selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "3" ]; then - fn_script_log_warn "Exiting with code: ${exitcode}" + fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" else - fn_script_log_warn "Exiting with code: ${exitcode}" + fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" fi + fn_exit_dev_debug exit ${exitcode} +elif [ -n "${exitbypass}" ]; then + unset exitbypass else + fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" exitcode=0 + fn_exit_dev_debug + exit ${exitcode} fi -if [ -f "${rootdir}/.dev-debug" ]; then - sleep 0.5 - echo "${function_selfname} exiting with code: ${exitcode}" -fi \ No newline at end of file From 4716aeb182951fa42291aba3e2bf9f1b0f998bfe Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 28 Jun 2016 00:03:16 +0100 Subject: [PATCH 035/195] exitcode trap designed to give and exit code at anytime if ctrl-c is pressed --- lgsm/functions/core_exit.sh | 4 ++++ lgsm/functions/core_functions.sh | 7 +++++++ lgsm/functions/core_trap.sh | 14 ++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 lgsm/functions/core_trap.sh diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index bfef50e7b..2671bb7a2 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -23,6 +23,8 @@ if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" fi fn_exit_dev_debug + # remove trap. + trap - INT exit ${exitcode} elif [ -n "${exitbypass}" ]; then unset exitbypass @@ -30,6 +32,8 @@ else fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" exitcode=0 fn_exit_dev_debug + # remove trap. + trap - INT exit ${exitcode} fi diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 22ca78f4f..848c1f588 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -88,6 +88,11 @@ functionfile="${FUNCNAME}" fn_fetch_core_dl } +core_trap.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + core_messages.sh(){ functionfile="${FUNCNAME}" fn_fetch_core_dl @@ -471,6 +476,8 @@ functionfile="${FUNCNAME}" fn_fetch_function } +# Calls the global Ctrl-C trap +core_trap.sh # Calls on-screen messages core_messages.sh diff --git a/lgsm/functions/core_trap.sh b/lgsm/functions/core_trap.sh new file mode 100644 index 000000000..f56e329c9 --- /dev/null +++ b/lgsm/functions/core_trap.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# LGSM core_trap.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description: handles ctrl-C trap to give an exitcode. + +fn_exit_trap(){ + core_exit.sh +} + +# trap to remove lockfile on quit. +trap fn_exit_trap INT \ No newline at end of file From 3833aed5fa68a405467fd0541bbfbe046a930bd8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 28 Jun 2016 00:10:42 +0100 Subject: [PATCH 036/195] updated commend --- lgsm/functions/core_trap.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_trap.sh b/lgsm/functions/core_trap.sh index f56e329c9..966b53d09 100644 --- a/lgsm/functions/core_trap.sh +++ b/lgsm/functions/core_trap.sh @@ -7,8 +7,9 @@ lgsm_version="210516" # Description: handles ctrl-C trap to give an exitcode. fn_exit_trap(){ + echo "" core_exit.sh } -# trap to remove lockfile on quit. +# trap to give an exitcode. trap fn_exit_trap INT \ No newline at end of file From 5b71d3655a9bd7b2fee698c5abeb31389a855298 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 28 Jun 2016 00:19:03 +0100 Subject: [PATCH 037/195] added reset as goldsource broke terminal on exit --- lgsm/functions/command_debug.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index a0452f6ff..8adb7fb86 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -13,6 +13,8 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_lockfile_trap(){ # Remove lock file rm -f "${rootdir}/${lockselfname}" + # resets terminal. Servers can sometimes mess up the terminal on exit. + reset core_exit.sh } From eb949bf0cb2b2190bc171334765bc75fb113ef10 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 30 Jun 2016 21:39:48 +0100 Subject: [PATCH 038/195] Update function being improved. --- lgsm/functions/command_update.sh | 16 +++ lgsm/functions/core_getopt.sh | 4 +- lgsm/functions/update_check.sh | 1 + lgsm/functions/update_steamcmd.sh | 208 ++++++++++++++++++++++++++++++ lgsm/functions/update_ts3.sh | 148 +++++++++++++++++++++ 5 files changed, 376 insertions(+), 1 deletion(-) create mode 100644 lgsm/functions/update_steamcmd.sh create mode 100644 lgsm/functions/update_ts3.sh diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index e69de29bb..965fb934e 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# LGSM commanf_update.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description:Hangles updating of servers. + +check.sh + +fn_print_dots "Checking for update" +if [ "${gamename}" == "Teamspeak 3" ]; then + update_ts3.sh +elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then + update_steamcmd.sh +fi \ No newline at end of file diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index eb0bd3c58..42dccd373 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -6,6 +6,8 @@ lgsm_version="210516" # Description: getopt arguments. +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_getopt_generic(){ case "$getopt" in st|start) @@ -18,7 +20,7 @@ case "$getopt" in update_check.sh;; fu|force-update|update-restart) forceupdate=1; - update_check.sh;; + command_update.sh;; uf|update-functions) command_update_functions.sh;; v|validate) diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 716889b43..49af21652 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -330,6 +330,7 @@ elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then # Goldsource servers bypass checks as fn_steamcmdcheck does not work for appid 90 servers. # forceupdate bypasses checks if [ "${status}" != "0" ]; then + exitbypass=1 command_stop.sh update_dl.sh command_start.sh diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh new file mode 100644 index 000000000..08bf9cd32 --- /dev/null +++ b/lgsm/functions/update_steamcmd.sh @@ -0,0 +1,208 @@ +#!/bin/bash +# LGSM commanf_update.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description:Handles updating using steamCMD. + +fn_steamcmd_dl(){ + cd "${rootdir}" + cd "steamcmd" + + # Detects if unbuffer command is available. + if [ $(command -v stdbuf) ]; then + unbuffer="stdbuf -i0 -o0 -e0" + fi + + if [ "${engine}" == "goldsource" ]; then + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}" + else + ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}" + fi + + fix.sh +} + +fn_appmanifest_info(){ + appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf") + appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l) +} + +fn_appmanifest_check(){ + fn_appmanifest_info + # Multiple or no matching appmanifest files may sometimes be present. + # This error is corrected if required. + if [ "${appmanifestfilewc}" -ge "2" ]; then + sleep 1 + fn_print_warn "Multiple appmanifest_${appid}.acf files found" + fn_script_log_warn "Multiple appmanifest_${appid}.acf files found" + sleep 2 + fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" + sleep 1 + for appfile in ${appmanifestfile}; do + rm "${appfile}" + done + sleep 1 + appmanifestfilewc1="${appmanifestfilewc}" + fn_appmanifest_info + if [ "${appmanifestfilewc}" -ge "2" ]; then + fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" + fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" + sleep 1 + echo " * Check user permissions" + for appfile in ${appmanifestfile}; do + echo " ${appfile}" + done + core_exit.sh + else + fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" + fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" + sleep 1 + fn_print_warn_nl "Forcing update to correct issue" + fn_script_log_warn "Forcing update to correct issue" + sleep 1 + update_dl.sh + update_check.sh + fi + elif [ "${appmanifestfilewc}" -eq "0" ]; then + if [ "${forceupdate}" == "1" ]; then + fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" + fn_script_log "Warning! Still no appmanifest_${appid}.acf found: Unable to update" + exit 1 + fi + forceupdate=1 + fn_print_warn "No appmanifest_${appid}.acf found" + fn_script_log "Warning! No appmanifest_${appid}.acf found" + sleep 2 + fn_print_info_nl "Forcing update to correct issue" + fn_script_log "Forcing update to correct issue" + sleep 1 + update_dl.sh + update_check.sh + fi +} + +fn_logupdaterequest(){ + # Checks for server update requests from server logs. + fn_print_dots "Checking for update: Server logs" + fn_script_log "Checking for update: Server logs" + sleep 1 + requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") + if [ "${requestrestart}" -ge "1" ]; then + fn_print_ok_nl "Checking for update: Server logs: Update requested" + sleep 1 + echo "" + echo -ne "Applying update.\r" + sleep 1 + echo -ne "Applying update..\r" + sleep 1 + echo -ne "Applying update...\r" + sleep 1 + echo -ne "\n" + + unset updateonstart + check_status.sh + if [ "${status}" != "0" ]; then + command_stop.sh + update_dl.sh + command_start.sh + else + update_dl.sh + fi + alert="update" + alert.sh + else + fn_print_ok "Checking for update: Server logs: No update requested" + sleep 1 + fi +} + +fn_steamcmdcheck(){ + fn_appmanifest_check + # Checks for server update from SteamCMD + fn_print_dots "Checking for update: SteamCMD" + fn_script_log_info "Checking for update: SteamCMD" + sleep 1 + + # Gets currentbuild + currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) + + # Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD + cd "${rootdir}/steamcmd" + if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then + rm -f "${HOME}/Steam/appcache/appinfo.vdf" + fi + + # Set branch for updateinfo + IFS=' ' read -a branchsplits <<< "${branch}" + if [ "${#branchsplits[@]}" -gt 1 ]; then + branchname="${branchsplits[1]}" + else + branchname="public" + fi + + # Gets availablebuild info + availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) + if [ -z "${availablebuild}" ]; then + fn_print_fail "Checking for update: SteamCMD" + sleep 1 + fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info" + fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info" + core_exit.sh + else + fn_print_ok "Checking for update: SteamCMD" + fn_script_log_pass "Checking for update: SteamCMD" + sleep 1 + fi + + if [ "${currentbuild}" != "${availablebuild}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: \e[0;31m${currentbuild}\e[0;39m" + echo -e " Available build: \e[0;32m${availablebuild}\e[0;39m" + echo -e "" + echo -e " https://steamdb.info/app/${appid}/" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log_info "Update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" + fn_script_log_info "${currentbuild} > ${availablebuild}" + + unset updateonstart + check_status.sh + if [ "${status}" != "0" ]; then + exitbypass=1 + command_stop.sh + fn_steamcmd_dl + exitbypass=1 + command_start.sh + else + fn_steamcmd_dl + fi + alert="update" + alert.sh + else + echo -e "\n" + echo -e "No update available:" + echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" + echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e " https://steamdb.info/app/${appid}/" + echo -e "" + fn_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" + fi +} + + +fn_steamcmdcheck \ No newline at end of file diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh new file mode 100644 index 000000000..6d609e53d --- /dev/null +++ b/lgsm/functions/update_ts3.sh @@ -0,0 +1,148 @@ +#!/bin/bash +# LGSM commanf_update.sh function +# Author: Daniel Gibbs +# Website: https://gameservermanagers.com +lgsm_version="210516" + +# Description:Handles updating of teamspeak 3 servers. + +fn_update_ts3_dl(){ + fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" + fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${filesdir}" +} + + +fn_update_ts3_check(){ + # Checks for server update from teamspeak.com using a mirror dl.4players.de. + fn_print_dots "Checking for update: teamspeak.com" + fn_script_log_info "Checking for update: teamspeak.com" + sleep 1 + + # Gets currentbuild info + # Checks currentbuild info is available, if fails a server restart will be forced to generate logs. + if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then + fn_print_fail "Checking for update: teamspeak.com" + sleep 1 + fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" + sleep 2 + fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" + sleep 2 + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + sleep 1 + # Check again and exit on failure. + if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then + fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" + fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" + core_exit.sh + fi + fi + + currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + + # Gets the teamspeak server architecture. + info_distro.sh + if [ "${arch}" == "x86_64" ]; then + ts3arch="amd64" + elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then + ts3arch="x86" + else + echo "" + fn_print_failure "unknown or unsupported architecture: ${arch}" + fn_script_log_fatal "unknown or unsupported architecture: ${arch}" + core_exit.sh + fi + + # Gets availablebuild info. + + # Grabs all version numbers but not in correct order. + wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp + + # Sort version numbers + cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp + + # Finds directory with most recent server version. + while read ts3_version_number; do + wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" + if [ $? -eq 0 ]; then + availablebuild="${ts3_version_number}" + # Break while-loop, if the latest release could be found. + break + fi + done < .ts3_version_numbers_sorted.tmp + + # Tidy up + rm -f ".ts3_version_numbers_unsorted.tmp" + rm -f ".ts3_version_numbers_sorted.tmp" + + # Checks availablebuild info is available + if [ -z "${availablebuild}" ]; then + fn_print_fail "Checking for update: teamspeak.com" + sleep 1 + fn_print_fail "Checking for update: teamspeak.com: Not returning version info" + fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" + core_exit.sh + else + fn_print_ok "Checking for update: teamspeak.com" + fn_script_log_pass "Checking for update: teamspeak.com" + sleep 1 + fi + + # Removes dots so if can compare version numbers + currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') + availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') + + if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" + echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e "" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" + + unset updateonstart + + check_status.sh + if [ "${status}" == "0" ]; then + fn_update_ts3_dl + exitbypass=1 + command_start.sh + exitbypass=1 + command_stop.sh + else + exitbypass=1 + command_stop.sh + fn_update_ts3_dl + exitbypass=1 + command_start.sh + fi + alert="update" + alert.sh + else + echo -e "\n" + echo -e "No update available:" + echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" + echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e "" + fn_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" + fi +} From 69ff8175c0b3744f63c41fefc919ad1c7865713a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 30 Jun 2016 21:44:15 +0100 Subject: [PATCH 039/195] update change --- lgsm/functions/core_getopt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 42dccd373..db639d846 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -17,7 +17,7 @@ case "$getopt" in r|restart) command_restart.sh;; u|update) - update_check.sh;; + command_update.sh;; fu|force-update|update-restart) forceupdate=1; command_update.sh;; From 036eb31c04fe9ceb55a63dba53b56f226419d739 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 30 Jun 2016 21:49:41 +0100 Subject: [PATCH 040/195] added new update functions --- lgsm/functions/core_functions.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 848c1f588..d177ec657 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -367,17 +367,22 @@ fn_fetch_function # Update -update_check.sh(){ +command_update_functions.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -command_update_functions.sh(){ +command_update.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + +update_ts3.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } -update_dl.sh(){ +update_steamcmd.sh(){ functionfile="${FUNCNAME}" fn_fetch_function } From f7121a30e0308f0b187cb25234fbd8d0659a7cf0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 20:54:32 +0100 Subject: [PATCH 041/195] Improving update functions --- lgsm/functions/command_update.sh | 4 +- lgsm/functions/update_steamcmd.sh | 38 +++-- lgsm/functions/update_ts3.sh | 248 +++++++++++++++--------------- 3 files changed, 154 insertions(+), 136 deletions(-) diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 965fb934e..b9a1eca4b 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -13,4 +13,6 @@ if [ "${gamename}" == "Teamspeak 3" ]; then update_ts3.sh elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then update_steamcmd.sh -fi \ No newline at end of file +fi + +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 08bf9cd32..da2969356 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -6,9 +6,8 @@ lgsm_version="210516" # Description:Handles updating using steamCMD. -fn_steamcmd_dl(){ - cd "${rootdir}" - cd "steamcmd" +fn_update_steamcmd_dl(){ + cd "${rootdir}/steamcmd" # Detects if unbuffer command is available. if [ $(command -v stdbuf) ]; then @@ -83,7 +82,7 @@ fn_appmanifest_check(){ fi } -fn_logupdaterequest(){ +fn_update_request_log(){ # Checks for server update requests from server logs. fn_print_dots "Checking for update: Server logs" fn_script_log "Checking for update: Server logs" @@ -104,11 +103,13 @@ fn_logupdaterequest(){ unset updateonstart check_status.sh if [ "${status}" != "0" ]; then + exitbypass=1 command_stop.sh - update_dl.sh + fn_update_steamcmd_dl + exitbypass=1 command_start.sh else - update_dl.sh + fn_update_steamcmd_dl fi alert="update" alert.sh @@ -118,7 +119,7 @@ fn_logupdaterequest(){ fi } -fn_steamcmdcheck(){ +fn_update_steamcmd_check(){ fn_appmanifest_check # Checks for server update from SteamCMD fn_print_dots "Checking for update: SteamCMD" @@ -183,11 +184,11 @@ fn_steamcmdcheck(){ if [ "${status}" != "0" ]; then exitbypass=1 command_stop.sh - fn_steamcmd_dl + fn_update_steamcmd_dl exitbypass=1 command_start.sh else - fn_steamcmd_dl + fn_update_steamcmd_dl fi alert="update" alert.sh @@ -205,4 +206,21 @@ fn_steamcmdcheck(){ } -fn_steamcmdcheck \ No newline at end of file +if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then + # Goldsource servers bypass checks as fn_update_steamcmd_check does not work for appid 90 servers. + # forceupdate bypasses checks + check_status.sh + if [ "${status}" != "0" ]; then + exitbypass=1 + command_stop.sh + fn_update_steamcmd_dl + exitbypass=1 + command_start.sh + else + fn_update_steamcmd_dl + fi +else + fn_update_request_log + fn_update_steamcmd_check +fi +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 6d609e53d..a1ee4b913 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -12,137 +12,135 @@ fn_update_ts3_dl(){ } -fn_update_ts3_check(){ - # Checks for server update from teamspeak.com using a mirror dl.4players.de. - fn_print_dots "Checking for update: teamspeak.com" - fn_script_log_info "Checking for update: teamspeak.com" +# Checks for server update from teamspeak.com using a mirror dl.4players.de. +fn_print_dots "Checking for update: teamspeak.com" +fn_script_log_info "Checking for update: teamspeak.com" +sleep 1 + +# Gets currentbuild info +# Checks currentbuild info is available, if fails a server restart will be forced to generate logs. +if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then + fn_print_fail "Checking for update: teamspeak.com" sleep 1 - - # Gets currentbuild info - # Checks currentbuild info is available, if fails a server restart will be forced to generate logs. + fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" + sleep 2 + fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" + sleep 2 + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + sleep 1 + # Check again and exit on failure. if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" - sleep 2 - fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" - sleep 2 - exitbypass=1 - command_stop.sh - exitbypass=1 - command_start.sh - sleep 1 - # Check again and exit on failure. - if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" - core_exit.sh - fi + fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" + fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" + core_exit.sh + fi +fi + +currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + +# Gets the teamspeak server architecture. +info_distro.sh +if [ "${arch}" == "x86_64" ]; then + ts3arch="amd64" +elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then + ts3arch="x86" +else + echo "" + fn_print_failure "unknown or unsupported architecture: ${arch}" + fn_script_log_fatal "unknown or unsupported architecture: ${arch}" + core_exit.sh +fi + +# Gets availablebuild info. + +# Grabs all version numbers but not in correct order. +wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp + +# Sort version numbers +cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp + +# Finds directory with most recent server version. +while read ts3_version_number; do + wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" + if [ $? -eq 0 ]; then + availablebuild="${ts3_version_number}" + # Break while-loop, if the latest release could be found. + break fi +done < .ts3_version_numbers_sorted.tmp - currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') +# Tidy up +rm -f ".ts3_version_numbers_unsorted.tmp" +rm -f ".ts3_version_numbers_sorted.tmp" - # Gets the teamspeak server architecture. - info_distro.sh - if [ "${arch}" == "x86_64" ]; then - ts3arch="amd64" - elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then - ts3arch="x86" - else - echo "" - fn_print_failure "unknown or unsupported architecture: ${arch}" - fn_script_log_fatal "unknown or unsupported architecture: ${arch}" - core_exit.sh - fi +# Checks availablebuild info is available +if [ -z "${availablebuild}" ]; then + fn_print_fail "Checking for update: teamspeak.com" + sleep 1 + fn_print_fail "Checking for update: teamspeak.com: Not returning version info" + fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" + core_exit.sh +else + fn_print_ok "Checking for update: teamspeak.com" + fn_script_log_pass "Checking for update: teamspeak.com" + sleep 1 +fi - # Gets availablebuild info. - - # Grabs all version numbers but not in correct order. - wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp - - # Sort version numbers - cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp - - # Finds directory with most recent server version. - while read ts3_version_number; do - wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - if [ $? -eq 0 ]; then - availablebuild="${ts3_version_number}" - # Break while-loop, if the latest release could be found. - break - fi - done < .ts3_version_numbers_sorted.tmp - - # Tidy up - rm -f ".ts3_version_numbers_unsorted.tmp" - rm -f ".ts3_version_numbers_sorted.tmp" - - # Checks availablebuild info is available - if [ -z "${availablebuild}" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail "Checking for update: teamspeak.com: Not returning version info" - fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" - core_exit.sh - else - fn_print_ok "Checking for update: teamspeak.com" - fn_script_log_pass "Checking for update: teamspeak.com" - sleep 1 - fi +# Removes dots so if can compare version numbers +currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') +availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') - # Removes dots so if can compare version numbers - currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') - availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') - - if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then - echo -e "\n" - echo -e "Update available:" - sleep 1 - echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" - echo -e "" - sleep 1 - echo "" - echo -en "Applying update.\r" - sleep 1 - echo -en "Applying update..\r" - sleep 1 - echo -en "Applying update...\r" - sleep 1 - echo -en "\n" - fn_script_log "Update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fn_script_log "${currentbuild} > ${availablebuild}" - - unset updateonstart - - check_status.sh - if [ "${status}" == "0" ]; then - fn_update_ts3_dl - exitbypass=1 - command_start.sh - exitbypass=1 - command_stop.sh - else - exitbypass=1 - command_stop.sh - fn_update_ts3_dl - exitbypass=1 - command_start.sh - fi - alert="update" - alert.sh +if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" + echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e "" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" + + unset updateonstart + + check_status.sh + if [ "${status}" == "0" ]; then + fn_update_ts3_dl + exitbypass=1 + command_start.sh + exitbypass=1 + command_stop.sh else - echo -e "\n" - echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" - echo -e "" - fn_print_ok_nl "No update available" - fn_script_log_info "Current build: ${currentbuild}" - fn_script_log_info "Available build: ${availablebuild}" + exitbypass=1 + command_stop.sh + fn_update_ts3_dl + exitbypass=1 + command_start.sh fi -} + alert="update" + alert.sh +else + echo -e "\n" + echo -e "No update available:" + echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" + echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e "" + fn_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" +fi From 9a927665eec898ec1b8656f4eba0fcd63ae6eefd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:00:31 +0100 Subject: [PATCH 042/195] added more screen info --- lgsm/functions/update_steamcmd.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index da2969356..2cc72e72d 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -7,6 +7,14 @@ lgsm_version="210516" # Description:Handles updating using steamCMD. fn_update_steamcmd_dl(){ + + check.sh + info_config.sh + fn_print_dots "Updating ${servername}" + sleep 1 + fn_print_ok_nl "Updating ${servername}" + fn_script_log_info "Updating ${servername}" + cd "${rootdir}/steamcmd" # Detects if unbuffer command is available. @@ -222,5 +230,4 @@ if [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then else fn_update_request_log fn_update_steamcmd_check -fi -core_exit.sh \ No newline at end of file +fi \ No newline at end of file From 0e94e2bb7e77636ac6b8f7a5af2925a3b13b14e0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:08:31 +0100 Subject: [PATCH 043/195] added function name --- lgsm/functions/command_update.sh | 3 +++ lgsm/functions/update_ts3.sh | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index b9a1eca4b..9612651bb 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -6,6 +6,9 @@ lgsm_version="210516" # Description:Hangles updating of servers. +local modulename="Update" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + check.sh fn_print_dots "Checking for update" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index a1ee4b913..c11f73dd1 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -6,6 +6,9 @@ lgsm_version="210516" # Description:Handles updating of teamspeak 3 servers. +local modulename="Update" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_update_ts3_dl(){ fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${filesdir}" From 73213d64398d688469a74df5156dd7e7c5dfa809 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:30:10 +0100 Subject: [PATCH 044/195] Streamlining ts3 installer --- lgsm/functions/command_install.sh | 5 +- lgsm/functions/install_server_files.sh | 4 + lgsm/functions/update_ts3.sh | 169 ++++++++++++++----------- 3 files changed, 99 insertions(+), 79 deletions(-) diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index fbf209b81..c9619e210 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -18,10 +18,9 @@ check_deps.sh if [ "${gamename}" == "Unreal Tournament 2004" ]; then install_server_files.sh install_ut2k4_key.sh -elif [ "${gamename}" == "Unreal Tournament 99" ]; then +elif [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Teamspeak 3" ]; then + installer=1 install_server_files.sh -elif [ "${gamename}" == "Teamspeak 3" ]; then - install_ts3.sh elif [ -n "${appid}" ]; then install_steamcmd.sh install_server_files.sh diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index eeef6fd54..88d89486e 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -98,6 +98,10 @@ if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then fn_install_server_files fi +if [ "${gamename}" == "Teamspeak 3" ]; then + update_ts3.sh +fi + if [ -z "${autoinstall}" ]; then echo "" echo "=================================" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index c11f73dd1..e2344da6b 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -20,32 +20,35 @@ fn_print_dots "Checking for update: teamspeak.com" fn_script_log_info "Checking for update: teamspeak.com" sleep 1 -# Gets currentbuild info -# Checks currentbuild info is available, if fails a server restart will be forced to generate logs. -if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" - sleep 2 - fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" - sleep 2 - exitbypass=1 - command_stop.sh - exitbypass=1 - command_start.sh - sleep 1 - # Check again and exit on failure. +fn_update_ts3_currentbuild(){ + # Gets currentbuild info + # Checks currentbuild info is available, if fails a server restart will be forced to generate logs. if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" - core_exit.sh + fn_print_fail "Checking for update: teamspeak.com" + sleep 1 + fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" + sleep 2 + fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" + sleep 2 + exitbypass=1 + command_stop.sh + exitbypass=1 + command_start.sh + sleep 1 + # Check again and exit on failure. + if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then + fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" + fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" + core_exit.sh + fi fi -fi -currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') + currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') +} +fn_update_ts3_arch(){ # Gets the teamspeak server architecture. info_distro.sh if [ "${arch}" == "x86_64" ]; then @@ -58,14 +61,16 @@ else fn_script_log_fatal "unknown or unsupported architecture: ${arch}" core_exit.sh fi +} +fn_update_ts3_availablebuild(){ # Gets availablebuild info. # Grabs all version numbers but not in correct order. wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp # Sort version numbers -cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp +cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" # Finds directory with most recent server version. while read ts3_version_number; do @@ -75,11 +80,11 @@ while read ts3_version_number; do # Break while-loop, if the latest release could be found. break fi -done < .ts3_version_numbers_sorted.tmp +done < "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp" # Tidy up -rm -f ".ts3_version_numbers_unsorted.tmp" -rm -f ".ts3_version_numbers_sorted.tmp" +rm -f "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" +rm -f "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp" # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then @@ -93,57 +98,69 @@ else fn_script_log_pass "Checking for update: teamspeak.com" sleep 1 fi +} -# Removes dots so if can compare version numbers -currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') -availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') - -if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then - echo -e "\n" - echo -e "Update available:" - sleep 1 - echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" - echo -e "" - sleep 1 - echo "" - echo -en "Applying update.\r" - sleep 1 - echo -en "Applying update..\r" - sleep 1 - echo -en "Applying update...\r" - sleep 1 - echo -en "\n" - fn_script_log "Update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fn_script_log "${currentbuild} > ${availablebuild}" - - unset updateonstart - - check_status.sh - if [ "${status}" == "0" ]; then - fn_update_ts3_dl - exitbypass=1 - command_start.sh - exitbypass=1 - command_stop.sh +fn_update_ts3_compare(){ + # Removes dots so if can compare version numbers + currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') + availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') + + if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then + echo -e "\n" + echo -e "Update available:" + sleep 1 + echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" + echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e "" + sleep 1 + echo "" + echo -en "Applying update.\r" + sleep 1 + echo -en "Applying update..\r" + sleep 1 + echo -en "Applying update...\r" + sleep 1 + echo -en "\n" + fn_script_log "Update available" + fn_script_log "Current build: ${currentbuild}" + fn_script_log "Available build: ${availablebuild}" + fn_script_log "${currentbuild} > ${availablebuild}" + + unset updateonstart + + check_status.sh + if [ "${status}" == "0" ]; then + fn_update_ts3_dl + exitbypass=1 + command_start.sh + exitbypass=1 + command_stop.sh + else + exitbypass=1 + command_stop.sh + fn_update_ts3_dl + exitbypass=1 + command_start.sh + fi + alert="update" + alert.sh else - exitbypass=1 - command_stop.sh - fn_update_ts3_dl - exitbypass=1 - command_start.sh + echo -e "\n" + echo -e "No update available:" + echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" + echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e "" + fn_print_ok_nl "No update available" + fn_script_log_info "Current build: ${currentbuild}" + fn_script_log_info "Available build: ${availablebuild}" fi - alert="update" - alert.sh +} + +if [ "${installer}" == "1"]; then + fn_update_ts3_availablebuild + fn_update_ts3_dl else - echo -e "\n" - echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" - echo -e "" - fn_print_ok_nl "No update available" - fn_script_log_info "Current build: ${currentbuild}" - fn_script_log_info "Available build: ${availablebuild}" -fi + fn_update_ts3_currentbuild + fn_update_ts3_availablebuild + fn_update_ts3_compare +fi \ No newline at end of file From 5b10275c45d7333a26076bddea9f59f35da45ed3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:46:23 +0100 Subject: [PATCH 045/195] re ordered if statements --- lgsm/functions/install_server_files.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 88d89486e..aa7da151b 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -90,16 +90,15 @@ echo "" echo "Installing ${gamename} Server" echo "=================================" sleep 1 -if [ -n "${appid}" ]; then - fn_install_server_files_steamcmd -fi -if [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then +if [ "${gamename}" == "Teamspeak 3" ]; then + update_ts3.sh +elif [ -z "${appid}" ]||[ "${gamename}" == "GoldenEye: Source" ]; then fn_install_server_files fi -if [ "${gamename}" == "Teamspeak 3" ]; then - update_ts3.sh +if [ -n "${appid}" ]; then + fn_install_server_files_steamcmd fi if [ -z "${autoinstall}" ]; then From 60ca35600c97b78bc503634981595496e8886633 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 1 Jul 2016 21:55:39 +0100 Subject: [PATCH 046/195] bug --- lgsm/functions/update_ts3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index e2344da6b..e661bcb9b 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -156,7 +156,7 @@ fn_update_ts3_compare(){ fi } -if [ "${installer}" == "1"]; then +if [ "${installer}" == "1" ]; then fn_update_ts3_availablebuild fn_update_ts3_dl else From 2622c7adf90bad2b2fbf307bbccd48abdb4e2bb1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 07:15:06 +0100 Subject: [PATCH 047/195] added function update function --- lgsm/functions/core_dl.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 832ae7fbf..46b5e289d 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -202,4 +202,18 @@ fn_fetch_function(){ force="noforce" md5="nomd5" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" +} + +fn_update_function(){ + github_file_url_dir="lgsm/functions" # github dir containing the file + github_file_url_name="${functionfile}" # name of the github file + githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" + fileurl="${githuburl}" + filedir="${functionsdir}" + filename="${github_file_url_name}" + executecmd="noexecute" + run="run" + force="noforce" + md5="nomd5" + fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" } \ No newline at end of file From 3942272e12e79874f15cc3f8277b26743957fc2b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 07:16:38 +0100 Subject: [PATCH 048/195] new updater compares files and updates them compares against the repo files and downloads if required --- lgsm/functions/command_update_functions.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 5069c43f9..1c4826e93 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -23,8 +23,20 @@ fi if [ -n "${functionsdir}" ]; then if [ -d "${functionsdir}" ]; then - rm -rfv "${functionsdir}/"* - exitcode=$? + + cd "${functionsdir}" + for functionfile in * + do + #functionfile=core_exit.sh + echo "FUNCTIONFILE: ${functionfile}" + function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl -s https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile})) + if [ "${function_file_diff}" != "" ]; then + echo "rm -rfv ${functionsdir}/${functionfile}" + rm -rfv "${functionsdir}/${functionfile}" + fn_update_function + core_exit.sh + fi + done fi fi From 11e97f0a1c0207d7f3bd0892aaa61f56e7827103 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 07:46:29 +0100 Subject: [PATCH 049/195] executable norun --- lgsm/functions/core_dl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 46b5e289d..d229fc7ba 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -211,8 +211,8 @@ fn_update_function(){ fileurl="${githuburl}" filedir="${functionsdir}" filename="${github_file_url_name}" - executecmd="noexecute" - run="run" + executecmd="execute" + run="norun" force="noforce" md5="nomd5" fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" From 3942cc3d4a9f9189b0a2f8ea9284241a5aceae9b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 07:49:48 +0100 Subject: [PATCH 050/195] bug --- lgsm/functions/core_dl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index d229fc7ba..91cacd7e2 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -211,7 +211,7 @@ fn_update_function(){ fileurl="${githuburl}" filedir="${functionsdir}" filename="${github_file_url_name}" - executecmd="execute" + executecmd="executecmd" run="norun" force="noforce" md5="nomd5" From 7f8cae0c418c87ce00831449fa087372d613dc2f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 07:54:42 +0100 Subject: [PATCH 051/195] removed exit --- lgsm/functions/command_update_functions.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 1c4826e93..14c7384c7 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -34,7 +34,6 @@ if [ -n "${functionsdir}" ]; then echo "rm -rfv ${functionsdir}/${functionfile}" rm -rfv "${functionsdir}/${functionfile}" fn_update_function - core_exit.sh fi done fi From 860e3e4ee598294a84f77d82ff98ca262c043e75 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 08:10:24 +0100 Subject: [PATCH 052/195] added check for missing remote file --- lgsm/functions/command_update_functions.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 14c7384c7..e8d423b2f 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -27,13 +27,21 @@ if [ -n "${functionsdir}" ]; then cd "${functionsdir}" for functionfile in * do - #functionfile=core_exit.sh - echo "FUNCTIONFILE: ${functionfile}" - function_file_diff=$(diff "${functionsdir}/${functionfile}" <(curl -s https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile})) + echo -ne " checking ${functionfile}...\c" + function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - echo "rm -rfv ${functionsdir}/${functionfile}" - rm -rfv "${functionsdir}/${functionfile}" - fn_update_function + ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + local exitcode=$? + if [ "${exitcode}" != "0" ]; then + echo -ne " checking ${functionfile}...FAIL" + rm -rfv "${functionsdir}/${functionfile}" + else + echo -ne " checking ${functionfile}...UPDATE" + rm -rfv "${functionsdir}/${functionfile}" + fn_update_function + fi + else + echo -ne " checking ${functionfile}...OK" fi done fi From 81333051b5af82aeff36de1053fb660104364c1e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 19:44:37 +0100 Subject: [PATCH 053/195] Added curl checking --- lgsm/functions/command_update_functions.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index e8d423b2f..f7f1fc2d7 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -23,7 +23,14 @@ fi if [ -n "${functionsdir}" ]; then if [ -d "${functionsdir}" ]; then - + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done cd "${functionsdir}" for functionfile in * do @@ -33,7 +40,8 @@ if [ -n "${functionsdir}" ]; then ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then - echo -ne " checking ${functionfile}...FAIL" + echo -ne " checking ${functionfile}...\c" + fn_print_fail_eol_nl rm -rfv "${functionsdir}/${functionfile}" else echo -ne " checking ${functionfile}...UPDATE" @@ -41,7 +49,8 @@ if [ -n "${functionsdir}" ]; then fn_update_function fi else - echo -ne " checking ${functionfile}...OK" + echo -ne " checking ${functionfile}...\c" + fn_print_fail_eol_nl fi done fi From 0662b97c07b42a85e18f55a3bfd84511115302ad Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 19:54:11 +0100 Subject: [PATCH 054/195] testing code --- lgsm/functions/command_update_functions.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index f7f1fc2d7..36f87421b 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -28,16 +28,22 @@ if [ -n "${functionsdir}" ]; then for curlcmd in ${curlpaths} do if [ -x "${curlcmd}" ]; then + echo "CURL CMD 1: ${curlcmd}" break fi done + echo "CURL CMD 2: ${curlcmd}" cd "${functionsdir}" for functionfile in * do echo -ne " checking ${functionfile}...\c" + echo "CURL CMD 3: ${curlcmd}" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then + echo "CURL CMD 4: ${curlcmd}" ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + local exitcode=$? if [ "${exitcode}" != "0" ]; then echo -ne " checking ${functionfile}...\c" From a535c2dca3874cdd821ab7fa08757f5e51926819 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 19:57:43 +0100 Subject: [PATCH 055/195] removed some testing code --- lgsm/functions/command_update_functions.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 36f87421b..4b81558de 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -28,22 +28,17 @@ if [ -n "${functionsdir}" ]; then for curlcmd in ${curlpaths} do if [ -x "${curlcmd}" ]; then - echo "CURL CMD 1: ${curlcmd}" break fi done - echo "CURL CMD 2: ${curlcmd}" cd "${functionsdir}" for functionfile in * do echo -ne " checking ${functionfile}...\c" - echo "CURL CMD 3: ${curlcmd}" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - echo "CURL CMD 4: ${curlcmd}" - ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" - + ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then echo -ne " checking ${functionfile}...\c" From 98d77fea1165bf083d747beef548c5f0234e0af7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 20:02:22 +0100 Subject: [PATCH 056/195] testing code --- lgsm/functions/command_update_functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 4b81558de..4ac54adf7 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -36,6 +36,7 @@ if [ -n "${functionsdir}" ]; then do echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) + echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" if [ "${function_file_diff}" != "" ]; then echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" From 406a806ffcae5db0cd09c8fc89f0c6556bc42620 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 20:10:02 +0100 Subject: [PATCH 057/195] defined curlcmd as seems to forget it --- lgsm/functions/command_update_functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 4ac54adf7..ec6c709e0 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -28,6 +28,7 @@ if [ -n "${functionsdir}" ]; then for curlcmd in ${curlpaths} do if [ -x "${curlcmd}" ]; then + curlcmd=${curlcmd} break fi done From 52c2a1a46dba8e966fdd37d3ffae9e6c8dcb9c20 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 20:18:52 +0100 Subject: [PATCH 058/195] fixes --- lgsm/functions/command_update_functions.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index ec6c709e0..ba4f7d170 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -36,16 +36,18 @@ if [ -n "${functionsdir}" ]; then for functionfile in * do echo -ne " checking ${functionfile}...\c" - function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + + function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + echo "files are different!!" ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then echo -ne " checking ${functionfile}...\c" fn_print_fail_eol_nl rm -rfv "${functionsdir}/${functionfile}" + exitcode=2 else echo -ne " checking ${functionfile}...UPDATE" rm -rfv "${functionsdir}/${functionfile}" @@ -53,20 +55,20 @@ if [ -n "${functionsdir}" ]; then fi else echo -ne " checking ${functionfile}...\c" - fn_print_fail_eol_nl + fn_print_ok_eol_nl fi done fi fi -if [ "${exitcode}" == "0" ]; then - fn_print_ok "Updating functions" - fn_script_log_pass "Success! Updating functions" - exitcode=0 -else +if [ "${exitcode}" != "0" ]; then fn_print_fail "Updating functions" fn_script_log_fatal "Failure! Updating functions" exitcode=1 +else + fn_print_ok "Updating functions" + fn_script_log_pass "Success! Updating functions" + exitcode=0 fi echo -ne "\n" core_exit.sh \ No newline at end of file From 4802187fae5bf47f52f5625f6b704c9e7d954dce Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 2 Jul 2016 20:24:17 +0100 Subject: [PATCH 059/195] removed some test code --- lgsm/functions/command_update_functions.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index ba4f7d170..b0b65e2ae 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -36,8 +36,6 @@ if [ -n "${functionsdir}" ]; then for functionfile in * do echo -ne " checking ${functionfile}...\c" - echo "${curlcmd} -s --fail https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" - function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then echo "files are different!!" @@ -64,7 +62,6 @@ fi if [ "${exitcode}" != "0" ]; then fn_print_fail "Updating functions" fn_script_log_fatal "Failure! Updating functions" - exitcode=1 else fn_print_ok "Updating functions" fn_script_log_pass "Success! Updating functions" From cefdbf7d426060f3e4ebd1edce26dd57f0bc61d6 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 00:43:56 +0100 Subject: [PATCH 060/195] updated curl and message --- lgsm/functions/command_update_functions.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index b0b65e2ae..e6cd6ffaa 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -35,11 +35,10 @@ if [ -n "${functionsdir}" ]; then cd "${functionsdir}" for functionfile in * do - echo -ne " checking ${functionfile}...\c" + echo -ne " checking ${functionfile}..." function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - echo "files are different!!" - ${curlcmd} -s --fail "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then echo -ne " checking ${functionfile}...\c" @@ -47,7 +46,7 @@ if [ -n "${functionsdir}" ]; then rm -rfv "${functionsdir}/${functionfile}" exitcode=2 else - echo -ne " checking ${functionfile}...UPDATE" + echo -ne " checking ${functionfile}...\e[0;33mUPDATE\e[0m" rm -rfv "${functionsdir}/${functionfile}" fn_update_function fi From dd19587e3eba378cb837095c6013e557303e0d61 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 00:56:40 +0100 Subject: [PATCH 061/195] messages --- lgsm/functions/command_update_functions.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index e6cd6ffaa..c45208fcb 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -35,23 +35,21 @@ if [ -n "${functionsdir}" ]; then cd "${functionsdir}" for functionfile in * do - echo -ne " checking ${functionfile}..." + echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then - echo -ne " checking ${functionfile}...\c" fn_print_fail_eol_nl rm -rfv "${functionsdir}/${functionfile}" exitcode=2 else - echo -ne " checking ${functionfile}...\e[0;33mUPDATE\e[0m" + echo -ne "\e[0;33mUPDATE\e[0m" rm -rfv "${functionsdir}/${functionfile}" fn_update_function fi else - echo -ne " checking ${functionfile}...\c" fn_print_ok_eol_nl fi done From e649c64b67908d0d9a6836c762c646e6077cf90f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 01:01:30 +0100 Subject: [PATCH 062/195] messages --- lgsm/functions/command_update_functions.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index c45208fcb..8e2d6dbc3 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -35,18 +35,18 @@ if [ -n "${functionsdir}" ]; then cd "${functionsdir}" for functionfile in * do - echo -ne " checking ${functionfile}...\c" + echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + #${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then fn_print_fail_eol_nl - rm -rfv "${functionsdir}/${functionfile}" + rm -rf "${functionsdir}/${functionfile}" exitcode=2 else echo -ne "\e[0;33mUPDATE\e[0m" - rm -rfv "${functionsdir}/${functionfile}" + rm -rf "${functionsdir}/${functionfile}" fn_update_function fi else From 6dc274dddf2a83fe5017732cf19d9a4ed2057612 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 01:03:30 +0100 Subject: [PATCH 063/195] removed comment --- lgsm/functions/command_update_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 8e2d6dbc3..0e3542099 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -38,7 +38,7 @@ if [ -n "${functionsdir}" ]; then echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - #${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" + ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" local exitcode=$? if [ "${exitcode}" != "0" ]; then fn_print_fail_eol_nl From a3bd7ffcd9e14e2570ab54c5768f1cc2d37af5f8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 01:08:06 +0100 Subject: [PATCH 064/195] moved curl checking loop --- lgsm/functions/command_update_functions.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 0e3542099..3cc9508c7 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -23,18 +23,19 @@ fi if [ -n "${functionsdir}" ]; then if [ -d "${functionsdir}" ]; then - # Check curl exists and use available path - curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" - for curlcmd in ${curlpaths} - do - if [ -x "${curlcmd}" ]; then - curlcmd=${curlcmd} - break - fi - done cd "${functionsdir}" for functionfile in * do + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + curlcmd=${curlcmd} + break + fi + done + echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then From d1e7b340b81ac7231dfd062f380ceae523270b94 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 01:14:57 +0100 Subject: [PATCH 065/195] if not empty --- lgsm/functions/command_update_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 3cc9508c7..790b3e4c6 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -57,7 +57,7 @@ if [ -n "${functionsdir}" ]; then fi fi -if [ "${exitcode}" != "0" ]; then +if [ "${exitcode}" != "0" ]||[ -n "${exitcode}" ]; then fn_print_fail "Updating functions" fn_script_log_fatal "Failure! Updating functions" else From 4dc5f4b199fea9dcdb4ec5e676ebc35232d96f53 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 01:16:04 +0100 Subject: [PATCH 066/195] && --- lgsm/functions/command_update_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 790b3e4c6..318dcbc6b 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -57,7 +57,7 @@ if [ -n "${functionsdir}" ]; then fi fi -if [ "${exitcode}" != "0" ]||[ -n "${exitcode}" ]; then +if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then fn_print_fail "Updating functions" fn_script_log_fatal "Failure! Updating functions" else From c9c6c10d1b1b830bcc5a00a0b17710de327120e7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 15:56:13 +0100 Subject: [PATCH 067/195] using core_dl.sh to download the file --- lgsm/functions/command_update_functions.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 318dcbc6b..7c9ad6a5e 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -39,19 +39,7 @@ if [ -n "${functionsdir}" ]; then echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - ${curlcmd} -s --fail -o "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}" - local exitcode=$? - if [ "${exitcode}" != "0" ]; then - fn_print_fail_eol_nl - rm -rf "${functionsdir}/${functionfile}" - exitcode=2 - else - echo -ne "\e[0;33mUPDATE\e[0m" - rm -rf "${functionsdir}/${functionfile}" - fn_update_function - fi - else - fn_print_ok_eol_nl + fn_update_function # located in core_dl.sh fi done fi @@ -63,7 +51,7 @@ if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then else fn_print_ok "Updating functions" fn_script_log_pass "Success! Updating functions" - exitcode=0 + 20 fi echo -ne "\n" core_exit.sh \ No newline at end of file From 20189fcdc8d9b184faba64494e1b5a1cfca8cc5b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 15:59:23 +0100 Subject: [PATCH 068/195] OK --- lgsm/functions/command_update_functions.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 7c9ad6a5e..b1dcc2e2f 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -39,7 +39,9 @@ if [ -n "${functionsdir}" ]; then echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then - fn_update_function # located in core_dl.sh + fn_update_function + else + fn_print_ok_eol_nl fi done fi From eb44ca040ed7d91be0062b4847545c64c9824e12 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 16:01:07 +0100 Subject: [PATCH 069/195] removed "20" --- lgsm/functions/command_update_functions.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index b1dcc2e2f..1d38d12e5 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -53,7 +53,6 @@ if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then else fn_print_ok "Updating functions" fn_script_log_pass "Success! Updating functions" - 20 fi echo -ne "\n" core_exit.sh \ No newline at end of file From 431abd84b1c8d3caea8d42d81966ea5699a2c041 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 16:04:57 +0100 Subject: [PATCH 070/195] UPDATE eol --- lgsm/functions/core_messages.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 7cbb2d1cb..8effd7910 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -245,4 +245,15 @@ fn_print_removed_eol(){ fn_print_removed_eol_nl(){ echo -e "\e[0;31mREMOVED\e[0m" -} \ No newline at end of file +} + +# UPDATE for end of line + +fn_print_update_eol(){ + echo -en "\e[0;36mUPATE\e[0m" +} + +fn_print_update_eol_nl(){ + echo -e "\e[0;36mUPATE\e[0m" +} + From b2d72dd1ae7f35543baaef9ac386681e1af7eb01 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 16:05:05 +0100 Subject: [PATCH 071/195] added update eol --- lgsm/functions/command_update_functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 1d38d12e5..51eb25665 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -39,6 +39,7 @@ if [ -n "${functionsdir}" ]; then echo -ne " checking ${functionfile}...\c" function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then + fn_print_update_eol_nl fn_update_function else fn_print_ok_eol_nl From 7a651538100ebb053a736b6892e653d7e3937f6d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 16:07:47 +0100 Subject: [PATCH 072/195] cannot spell --- lgsm/functions/core_messages.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 8effd7910..e0eef7f0d 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -250,10 +250,10 @@ fn_print_removed_eol_nl(){ # UPDATE for end of line fn_print_update_eol(){ - echo -en "\e[0;36mUPATE\e[0m" + echo -en "\e[0;36mUPDATE\e[0m" } fn_print_update_eol_nl(){ - echo -e "\e[0;36mUPATE\e[0m" + echo -e "\e[0;36mUPDATE\e[0m" } From 04aadbc039502d08ff3912fbe16a3eaeb8ad0dd2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 16:56:28 +0100 Subject: [PATCH 073/195] remove function before dl --- lgsm/functions/command_update_functions.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 51eb25665..cf8c97272 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -40,6 +40,7 @@ if [ -n "${functionsdir}" ]; then function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then fn_print_update_eol_nl + rm -rf "${functionsdir}/${functionfile}" fn_update_function else fn_print_ok_eol_nl From aaf346a9f4e658aa07660011908e544664bedb01 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 17:15:47 +0100 Subject: [PATCH 074/195] log message --- lgsm/functions/command_update_functions.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index cf8c97272..8fe1c17bd 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -40,10 +40,12 @@ if [ -n "${functionsdir}" ]; then function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then fn_print_update_eol_nl + fn_script_log_pass "${functionfile}: UPDATE" rm -rf "${functionsdir}/${functionfile}" fn_update_function else fn_print_ok_eol_nl + fn_script_log_pass "${functionfile}: NO UPDATE" fi done fi From ecc920581e3c7f6b4a79f724c219999163cff762 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 17:19:02 +0100 Subject: [PATCH 075/195] only logs is update required --- lgsm/functions/command_update_functions.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 8fe1c17bd..8b43eb940 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -45,7 +45,6 @@ if [ -n "${functionsdir}" ]; then fn_update_function else fn_print_ok_eol_nl - fn_script_log_pass "${functionfile}: NO UPDATE" fi done fi @@ -53,10 +52,10 @@ fi if [ "${exitcode}" != "0" ]&&[ -n "${exitcode}" ]; then fn_print_fail "Updating functions" - fn_script_log_fatal "Failure! Updating functions" + fn_script_log_fatal "Updating functions" else fn_print_ok "Updating functions" - fn_script_log_pass "Success! Updating functions" + fn_script_log_pass "Updating functions" fi echo -ne "\n" core_exit.sh \ No newline at end of file From f2d673a070a4bbb4d18873226d446626b0a73269 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 17:31:40 +0100 Subject: [PATCH 076/195] bug --- lgsm/functions/core_exit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 2671bb7a2..0eb19c753 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -29,8 +29,8 @@ if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then elif [ -n "${exitbypass}" ]; then unset exitbypass else - fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" exitcode=0 + fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" fn_exit_dev_debug # remove trap. trap - INT From 56e5a1f03b144dbb1df7f6bea3bfc2064e820a9d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 17:36:46 +0100 Subject: [PATCH 077/195] added modulename --- lgsm/functions/command_update_functions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 8b43eb940..8d10b8207 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -6,6 +6,7 @@ lgsm_version="210516" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. +local modulename="Updating LGSM" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" @@ -40,7 +41,7 @@ if [ -n "${functionsdir}" ]; then function_file_diff=$(diff "${functionsdir}/${functionfile}" <(${curlcmd} -s "https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${functionfile}")) if [ "${function_file_diff}" != "" ]; then fn_print_update_eol_nl - fn_script_log_pass "${functionfile}: UPDATE" + fn_script_log_info "checking ${functionfile}: UPDATE" rm -rf "${functionsdir}/${functionfile}" fn_update_function else From 97864ef7691ebb2486061554f202db3ce7a370ab Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:16:30 +0100 Subject: [PATCH 078/195] updated log messages --- lgsm/functions/alert.sh | 14 ++++----- lgsm/functions/alert_email.sh | 4 +-- lgsm/functions/alert_pushbullet.sh | 4 +-- lgsm/functions/check_config.sh | 4 +-- lgsm/functions/check_deps.sh | 4 +-- lgsm/functions/command_fastdl.sh | 2 +- lgsm/functions/command_monitor.sh | 1 - lgsm/functions/command_stop.sh | 5 ++- lgsm/functions/core_dl.sh | 2 +- lgsm/functions/fn_update_functions | 1 - lgsm/functions/install_gslt.sh | 10 +++--- lgsm/functions/install_logs.sh | 2 +- lgsm/functions/install_ut2k4_key.sh | 2 +- lgsm/functions/logs.sh | 5 ++- lgsm/functions/update_check.sh | 49 +++++++++++++++-------------- lgsm/functions/update_steamcmd.sh | 12 +++---- 16 files changed, 59 insertions(+), 62 deletions(-) diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index d231a90ce..758a16226 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -7,25 +7,25 @@ lgsm_version="210516" # Description: Overall function for managing alerts. fn_alert_test(){ - fn_script_log "Sending test alert" + fn_script_log_info "Sending test alert" alertsubject="LGSM - Test Alert - ${servername}" alertbody="LGSM test alert, how you read?" } fn_alert_restart(){ - fn_script_log "Sending restart alert: ${executable} process not running" + fn_script_log_info "Sending restart alert: ${executable} process not running" alertsubject="LGSM - Restarted - ${servername}" alertbody="${servicename} ${executable} process not running" } fn_alert_restart_query(){ - fn_script_log "Sending restart alert: ${gsquerycmd}" + fn_script_log_info "Sending restart alert: ${gsquerycmd}" alertsubject="LGSM - Restarted - ${servername}" alertbody="gsquery.py failed to query: ${gsquerycmd}" } fn_alert_update(){ - fn_script_log "Sending update alert" + fn_script_log_info "Sending update alert" alertsubject="LGSM - Updated - ${servername}" alertbody="${servicename} recieved update" } @@ -44,7 +44,7 @@ if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${emai alert_email.sh elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Email alerts not enabled" - fn_script_log "Email alerts not enabled" + fn_script_log_info "Email alerts not enabled" elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Email not set" fn_script_log "Email not set" @@ -54,8 +54,8 @@ if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Pushbullet alerts not enabled" - fn_script_log "Pushbullet alerts not enabled" + fn_script_log_info "Pushbullet alerts not enabled" elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Pushbullet token not set" - fn_script_log "Pushbullet token not set" + fn_script_log_warn "Pushbullet token not set" fi \ No newline at end of file diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 3f29219e1..28488f77b 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -234,8 +234,8 @@ mail -s "${alertsubject}" "${email}" < "${emaillog}" exitcode=$? if [ "${exitcode}" == "0" ]; then fn_print_ok_nl "Sending alert to ${email}" - fn_script_log "Success! Sending alert to ${email}" + fn_script_log_pass "Sending alert to ${email}" else fn_print_fail_nl "Sending alert to ${email}" - fn_script_log "Failure! Sending alert to ${email}" + fn_script_log_fatal "Sending alert to ${email}" fi \ No newline at end of file diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 10a704190..cc85be8d4 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -15,8 +15,8 @@ pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d bo if [ "${pushbulletsend}" == "invalid_access_token" ]; then fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token" - fn_script_log "Failure! Sending Pushbullet alert: invalid_access_token" + fn_script_log_fatal "Sending Pushbullet alert: invalid_access_token" else fn_print_ok_nl "Sending Pushbullet alert" - fn_script_log "Complete! Sent Pushbullet alert" + fn_script_log_pass "Sent Pushbullet alert" fi \ No newline at end of file diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index b379f8079..b5dc757c9 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -10,8 +10,8 @@ if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then fn_print_warn_nl "Config file missing!" echo "${servercfgfullpath}" - fn_script_log "Configuration file missing!" - fn_script_log "${servercfgfullpath}" + fn_script_log_warn "Configuration file missing!" + fn_script_log_warn "${servercfgfullpath}" sleep 2 fi fi \ No newline at end of file diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index dc5b0ef31..ac8e77771 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -65,7 +65,7 @@ fn_found_missing_deps(){ fn_print_dots "Checking dependencies" sleep 2 fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" - fn_script_log "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_script_log_info "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" sleep 1 echo -e "" sudo -n true > /dev/null 2>&1 @@ -88,7 +88,7 @@ fn_found_missing_deps(){ else echo "" fn_print_infomation_nl "$(whoami) does not have sudo access. Please manually install dependencies" - fn_script_log "$(whoami) does not have sudo access. Please manually install dependencies" + fn_script_log_info "$(whoami) does not have sudo access. Please manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 2a11050c4..f771cea95 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -26,7 +26,7 @@ fn_check_bzip2(){ if [ -z "$(command -v bzip2)" ]; then bzip2installed="0" fn_print_info "bzip2 is not installed !" - fn_script_log "bzip2 is not installed" + fn_script_log_info "bzip2 is not installed" echo -en "\n" sleep 1 echo "We advise using it" diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index c903b463c..076016146 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -85,7 +85,6 @@ check.sh logs.sh info_config.sh fn_print_dots "${servername}" -fn_script_log "${servername}" sleep 1 fn_monitor_check_lockfile fn_monitor_check_update diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index a24833bbf..e8195f351 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -242,7 +242,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_script_log "${servername} is already stopped" + fn_script_log_pass "${servername} is already stopped" else fn_stop_teamspeak3 fi @@ -250,7 +250,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_script_log "${servername} is already stopped" + fn_script_log_pass "${servername} is already stopped" else fn_stop_graceful_select fi @@ -260,7 +260,6 @@ fn_stop_pre_check(){ check.sh info_config.sh fn_print_dots "${servername}" -fn_script_log "${servername}" sleep 1 fn_stop_pre_check core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 91cacd7e2..05a9f7e50 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -51,7 +51,7 @@ fn_dl_extract(){ extractdir="${3}" # extracts archives echo -ne "extracting ${filename}..." - fn_script_log "extracting download" + fn_script_log_info "extracting download" mime=$(file -b --mime-type "${filedir}/${filename}") if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then diff --git a/lgsm/functions/fn_update_functions b/lgsm/functions/fn_update_functions index 22ebf0548..6ebee6652 100644 --- a/lgsm/functions/fn_update_functions +++ b/lgsm/functions/fn_update_functions @@ -7,7 +7,6 @@ lgsm_version="210516" # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub. fn_print_dots "Updating functions" -fn_script_log "Updating functions" sleep 1 echo -ne "\n" rm -rfv "${rootdir}/functions/"* diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index f7dc596ef..86ab78d06 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -14,16 +14,16 @@ echo "=================================" sleep 1 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then echo "GSLT is required to run a public ${gamename} server" - fn_script_log "GSLT is required to run a public ${gamename} server" + fn_script_log_info "GSLT is required to run a public ${gamename} server" else echo "GSLT is an optional feature for ${gamename} server" - fn_script_log "GSLT is an optional feature for ${gamename} server" + fn_script_log_info "GSLT is an optional feature for ${gamename} server" fi echo "Get more info and a token here:" echo "https://gameservermanagers.com/gslt" -fn_script_log "Get more info and a token here:" -fn_script_log "https://gameservermanagers.com/gslt" +fn_script_log_info "Get more info and a token here:" +fn_script_log_info "https://gameservermanagers.com/gslt" echo "" if [ -z "${autoinstall}" ]; then echo "Enter token below (Can be blank)." @@ -33,5 +33,5 @@ if [ -z "${autoinstall}" ]; then fi sleep 1 echo "The GSLT can be changed by editing ${selfname}." -fn_script_log "The GSLT can be changed by editing ${selfname}." +fn_script_log_info "The GSLT can be changed by editing ${selfname}." echo "" \ No newline at end of file diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index e077ee8ab..f46a197e5 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -40,4 +40,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then fi fi sleep 1 -fn_script_log "logs installed" \ No newline at end of file +fn_script_log_info "logs installed" \ No newline at end of file diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 212cfba25..32e80728a 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -20,7 +20,7 @@ if [ -z "${autoinstall}" ]; then read CODE echo ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey" if [ -f "${systemdir}/cdkey" ]; then - fn_script_log "UT2K4 Server CD Key created" + fn_script_log_info "UT2K4 Server CD Key created" fi else echo "You can add your key using the following command" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index 03682368e..de29bf8f0 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -20,7 +20,7 @@ fi if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then fn_print_info "Moving game logs to ${gamelogdir}" - fn_script_log "Moving game logs to ${gamelogdir}" + fn_script_log_info "Moving game logs to ${gamelogdir}" echo -en "\n" sleep 1 mv "${systemdir}"/gamelog*.log "${gamelogdir}" @@ -39,9 +39,8 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th scriptcount="0" ; consolecount="0" ; gamecount="0" ; srcdscount="0" ; smcount="0" ; ulxcount="0" ; darkrpcount="0" ; legacycount="0" sleep 1 fn_print_ok_nl "Starting" - fn_script_log "Starting" fn_print_info_nl "Removing logs older than "${logdays}" days" - fn_script_log "Removing logs older than "${logdays}" days" + fn_script_log_info "Removing logs older than "${logdays}" days" # Logging logfiles to be removed according to "${logdays}", counting and removing them # Script logfiles find "${scriptlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}" diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 49af21652..3bddacd65 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -23,7 +23,7 @@ fn_appmanifestcheck(){ if [ "${appmanifestfilewc}" -ge "2" ]; then sleep 1 fn_print_warn "Multiple appmanifest_${appid}.acf files found" - fn_script_log "Warning! Multiple appmanifest_${appid}.acf files found" + fn_script_log_warn "Multiple appmanifest_${appid}.acf files found" sleep 2 fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 @@ -34,7 +34,7 @@ fn_appmanifestcheck(){ fn_appmanifestinfo if [ "${appmanifestfilewc}" -ge "2" ]; then fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - fn_script_log "Failure! Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" + fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 echo "" echo " Check user permissions" @@ -45,10 +45,10 @@ fn_appmanifestcheck(){ else sleep 1 fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" - fn_script_log "Success! Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" + fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" sleep 1 fn_print_info_nl "Forcing update to correct issue" - fn_script_log "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -56,15 +56,15 @@ fn_appmanifestcheck(){ elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" == "1" ]; then fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" - fn_script_log "Warning! Still no appmanifest_${appid}.acf found: Unable to update" - exit 1 + fn_script_log_fatal "Still no appmanifest_${appid}.acf found: Unable to update" + core_exit.sh fi forceupdate=1 fn_print_warn "No appmanifest_${appid}.acf found" - fn_script_log "Warning! No appmanifest_${appid}.acf found" + fn_script_log_warn "No appmanifest_${appid}.acf found" sleep 2 fn_print_info_nl "Forcing update to correct issue" - fn_script_log "Forcing update to correct issue" + fn_script_log_warn "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -74,7 +74,7 @@ fn_appmanifestcheck(){ fn_logupdaterequest(){ # Checks for server update requests from server logs. fn_print_dots "Checking for update: Server logs" - fn_script_log "Checking for update: Server logs" + fn_script_log_info "Checking for update: Server logs" sleep 1 requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") if [ "${requestrestart}" -ge "1" ]; then @@ -110,7 +110,7 @@ fn_steamcmdcheck(){ fn_appmanifestcheck # Checks for server update from SteamCMD fn_print_dots "Checking for update: SteamCMD" - fn_script_log "Checking for update: SteamCMD" + fn_script_log_info "Checking for update: SteamCMD" sleep 1 # Gets currentbuild @@ -135,14 +135,14 @@ fn_steamcmdcheck(){ availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) if [ -z "${availablebuild}" ]; then fn_print_fail "Checking for update: SteamCMD" - fn_script_log "Failure! Checking for update: SteamCMD" + fn_script_log_fatal "Checking for update: SteamCMD" sleep 1 fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info" - fn_script_log "Failure! Checking for update: SteamCMD: Not returning version info" - exit 1 + fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info" + core_exit.sh else fn_print_ok "Checking for update: SteamCMD" - fn_script_log "Success! Checking for update: SteamCMD" + fn_script_log_pass "Checking for update: SteamCMD" sleep 1 fi @@ -197,7 +197,7 @@ fn_steamcmdcheck(){ fn_teamspeak3_check(){ # Checks for server update from teamspeak.com using a mirror dl.4players.de fn_print_dots "Checking for update: teamspeak.com" - fn_script_log "Checking for update: teamspeak.com" + fn_script_log_info "Checking for update: teamspeak.com" sleep 1 # Gets currentbuild info @@ -206,10 +206,10 @@ fn_teamspeak3_check(){ fn_print_fail "Checking for update: teamspeak.com" sleep 1 fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log "Failure! Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found" sleep 2 fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart" sleep 2 command_stop.sh command_start.sh @@ -217,8 +217,10 @@ fn_teamspeak3_check(){ # If still failing will exit if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_script_log "Failure! Checking for update: teamspeak.com: Still No logs with server version found" - exit 1 + fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" + core_exit.sh + else + exitcode=0 fi fi currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') @@ -260,15 +262,14 @@ fn_teamspeak3_check(){ # Checks availablebuild info is available if [ -z "${availablebuild}" ]; then fn_print_fail "Checking for update: teamspeak.com" - fn_script_log "Checking for update: teamspeak.com" sleep 1 fn_print_fail "Checking for update: teamspeak.com: Not returning version info" - fn_script_log "Failure! Checking for update: teamspeak.com: Not returning version info" - sleep 2 - exit 1 + fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" + sleep 1 + core_exit.sh else fn_print_ok "Checking for update: teamspeak.com" - fn_script_log "Success! Checking for update: teamspeak.com" + fn_script_log_pass "Checking for update: teamspeak.com" sleep 1 fi diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 2cc72e72d..9bfabc050 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -75,15 +75,15 @@ fn_appmanifest_check(){ elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" == "1" ]; then fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" - fn_script_log "Warning! Still no appmanifest_${appid}.acf found: Unable to update" - exit 1 + fn_script_log_fatal "Warning! Still no appmanifest_${appid}.acf found: Unable to update" + core_exit.sh fi forceupdate=1 fn_print_warn "No appmanifest_${appid}.acf found" - fn_script_log "Warning! No appmanifest_${appid}.acf found" - sleep 2 + fn_script_log_warn "No appmanifest_${appid}.acf found" + sleep 1 fn_print_info_nl "Forcing update to correct issue" - fn_script_log "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -93,7 +93,7 @@ fn_appmanifest_check(){ fn_update_request_log(){ # Checks for server update requests from server logs. fn_print_dots "Checking for update: Server logs" - fn_script_log "Checking for update: Server logs" + fn_script_log_info "Checking for update: Server logs" sleep 1 requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") if [ "${requestrestart}" -ge "1" ]; then From 7c66cb0588142a43f2c5660ff58ddb13d1d6ffb9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:18:17 +0100 Subject: [PATCH 079/195] exitbypass --- lgsm/functions/command_validate.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index c6d023bc3..3f0b8e289 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -38,9 +38,12 @@ fn_validation(){ check_status.sh if [ "${status}" != "0" ]; then + exitbypass=1 command_stop.sh fn_validation + exitbypass=1 command_start.sh else fn_validation fi +core_exit.sh \ No newline at end of file From 62a07a4a02611db51bb572f22f3012ed8e9989b0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:23:40 +0100 Subject: [PATCH 080/195] messages --- lgsm/functions/core_dl.sh | 12 ++++++------ lgsm/functions/fix.sh | 4 ++-- lgsm/functions/install_logs.sh | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 05a9f7e50..32f3e9ec5 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -28,15 +28,15 @@ fn_dl_md5(){ fn_print_fail_eol_nl echo "${filename} returned MD5 checksum: ${md5sumcmd}" echo "expected MD5 checksum: ${md5}" - fn_script_log_fatal "verifying ${filename} with MD5: FAIL" + fn_script_log_fatal "Verifying ${filename} with MD5: FAIL" fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_script_log_info "expected MD5 checksum: ${md5}" + fn_script_log_info "Expected MD5 checksum: ${md5}" exit 1 else fn_print_ok_eol_nl - fn_script_log_pass "verifying ${filename} with MD5: OK" + fn_script_log_pass "Verifying ${filename} with MD5: OK" fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}" - fn_script_log_info "expected MD5 checksum: ${md5}" + fn_script_log_info "Expected MD5 checksum: ${md5}" fi fi } @@ -51,7 +51,7 @@ fn_dl_extract(){ extractdir="${3}" # extracts archives echo -ne "extracting ${filename}..." - fn_script_log_info "extracting download" + fn_script_log_info "Extracting download" mime=$(file -b --mime-type "${filedir}/${filename}") if [ "${mime}" == "application/gzip" ]||[ "${mime}" == "application/x-gzip" ]; then @@ -62,7 +62,7 @@ fn_dl_extract(){ local exitcode=$? if [ ${exitcode} -ne 0 ]; then fn_print_fail_eol_nl - fn_script_log_fatal "extracting download: FAIL" + fn_script_log_fatal "Extracting download: FAIL" echo "${tarcmd}" | tee -a "${scriptlog}" core_exit.sh else diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index f012b706f..041c6c151 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -19,11 +19,11 @@ fn_fix_msg_start(){ fn_fix_msg_end(){ if [ $? -ne 0 ]; then fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" - fn_script_log_error "Failure! Applying ${fixname} fix: ${gamename}" + fn_script_log_error "Applying ${fixname} fix: ${gamename}" exitcode=2 else fn_print_ok_nl "Applying ${fixname} fix: ${gamename}" - fn_script_log_pass "Complete! Applying ${fixname} fix: ${gamename}" + fn_script_log_pass "Applying ${fixname} fix: ${gamename}" fi } diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index f46a197e5..4110e6c04 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -40,4 +40,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then fi fi sleep 1 -fn_script_log_info "logs installed" \ No newline at end of file +fn_script_log_info "Logs installed" \ No newline at end of file From 3b2e246d46bf9785114396cd9bcabdd3c79cb673 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:34:41 +0100 Subject: [PATCH 081/195] added Unknown command message --- lgsm/functions/core_getopt.sh | 42 +++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index db639d846..cac791262 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -9,7 +9,7 @@ lgsm_version="210516" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_getopt_generic(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -46,6 +46,10 @@ case "$getopt" in dd|depsdetect) command_dev_detect_deps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -72,7 +76,7 @@ case "$getopt" in } fn_getopt_teamspeak3(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -102,6 +106,10 @@ case "$getopt" in dd|depsdetect) command_dev_detect_deps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -125,7 +133,7 @@ case "$getopt" in } fn_getopt_mumble(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -149,6 +157,10 @@ case "$getopt" in dd|depsdetect) command_dev_detect_deps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -169,7 +181,7 @@ case "$getopt" in } fn_getopt_gmodserver(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -208,6 +220,10 @@ case "$getopt" in fd|fastdl) command_fastdl.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -235,7 +251,7 @@ case "$getopt" in } fn_getopt_unreal(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -267,6 +283,10 @@ case "$getopt" in dd|depsdetect) command_dev_detect_deps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -292,7 +312,7 @@ case "$getopt" in fn_getopt_unreal2(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -331,6 +351,10 @@ case "$getopt" in mc|map-compressor) compress_unreal2_maps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" @@ -359,7 +383,7 @@ case "$getopt" in fn_getopt_ut2k4(){ -case "$getopt" in +case "${getopt}" in st|start) command_start.sh;; sp|stop) @@ -393,6 +417,10 @@ case "$getopt" in dd|depsdetect) command_dev_detect_deps.sh;; *) + if [ -n "${getopt}" ]; then + echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + exitcode=2 + fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" From cc700e69bd3f816b3f4b2f4381d273db40792c6e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:36:59 +0100 Subject: [PATCH 082/195] already stopped returned code 2 --- lgsm/functions/command_stop.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index e8195f351..31e9781b4 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -242,7 +242,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_script_log_pass "${servername} is already stopped" + fn_script_log_error "${servername} is already stopped" else fn_stop_teamspeak3 fi @@ -250,7 +250,7 @@ fn_stop_pre_check(){ check_status.sh if [ "${status}" == "0" ]; then fn_print_ok_nl "${servername} is already stopped" - fn_script_log_pass "${servername} is already stopped" + fn_script_log_error "${servername} is already stopped" else fn_stop_graceful_select fi From f1ee3aacfd56de25300c06cd16b75e8387624986 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:37:54 +0100 Subject: [PATCH 083/195] OK to info --- lgsm/functions/command_stop.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 31e9781b4..13c2a6b98 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -241,7 +241,7 @@ fn_stop_pre_check(){ if [ "${gamename}" == "Teamspeak 3" ]; then check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok_nl "${servername} is already stopped" + fn_print_info_nl "${servername} is already stopped" fn_script_log_error "${servername} is already stopped" else fn_stop_teamspeak3 @@ -249,7 +249,7 @@ fn_stop_pre_check(){ else check_status.sh if [ "${status}" == "0" ]; then - fn_print_ok_nl "${servername} is already stopped" + fn_print_info_nl "${servername} is already stopped" fn_script_log_error "${servername} is already stopped" else fn_stop_graceful_select From ba8edcc9b6aaa74e1003ee88362857afec1769f7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:40:45 +0100 Subject: [PATCH 084/195] error not fatal --- lgsm/functions/command_console.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index e12234f9d..bb53c20d1 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -35,7 +35,7 @@ if [ "${status}" != "0" ]; then tmux attach-session -t ${servicename} else fn_print_fail_nl "Server not running" - fn_script_log_fatal "Failed to access: Server not running" + fn_script_log_error "Failed to access: Server not running" sleep 1 while true; do read -p "Do you want to start the server? [y/N]" yn From d04fd54ea5c35ce26f473b70868e4f6a6f706b8e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:44:00 +0100 Subject: [PATCH 085/195] console will attempt access after starting --- lgsm/functions/command_console.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index bb53c20d1..67096e9fc 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -9,6 +9,13 @@ lgsm_version="210516" local modulename="Console" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +fn_console_access(){ + fn_print_ok_nl "Starting" + fn_script_log_info "Accessed" + sleep 1 + tmux attach-session -t ${servicename} +} + check.sh echo "" echo "${gamename} Console" @@ -29,10 +36,7 @@ fn_print_dots "Starting" sleep 1 check_status.sh if [ "${status}" != "0" ]; then - fn_print_ok_nl "Starting" - fn_script_log_info "Accessed" - sleep 1 - tmux attach-session -t ${servicename} + fn_console_access else fn_print_fail_nl "Server not running" fn_script_log_error "Failed to access: Server not running" @@ -40,10 +44,11 @@ else while true; do read -p "Do you want to start the server? [y/N]" yn case $yn in - [Yy]* ) command_start.sh; break;; + [Yy]* ) exitbypass=1; command_start.sh; break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done + fn_console_access fi core_exit.sh From efaa25293efac32ebed73c7515eb70a948172400 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:45:49 +0100 Subject: [PATCH 086/195] revert to exitbypass only --- lgsm/functions/command_console.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 67096e9fc..ffb7ebb3a 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -9,13 +9,6 @@ lgsm_version="210516" local modulename="Console" function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_console_access(){ - fn_print_ok_nl "Starting" - fn_script_log_info "Accessed" - sleep 1 - tmux attach-session -t ${servicename} -} - check.sh echo "" echo "${gamename} Console" @@ -36,7 +29,10 @@ fn_print_dots "Starting" sleep 1 check_status.sh if [ "${status}" != "0" ]; then - fn_console_access + fn_print_ok_nl "Starting" + fn_script_log_info "Accessed" + sleep 1 + tmux attach-session -t ${servicename} else fn_print_fail_nl "Server not running" fn_script_log_error "Failed to access: Server not running" @@ -49,6 +45,5 @@ else * ) echo "Please answer yes or no.";; esac done - fn_console_access fi core_exit.sh From 621c3d7cdebd96860a538be36cdd89ab09740986 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:48:13 +0100 Subject: [PATCH 087/195] added default option --- lgsm/functions/command_console.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index ffb7ebb3a..1e888155c 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -38,7 +38,7 @@ else fn_script_log_error "Failed to access: Server not running" sleep 1 while true; do - read -p "Do you want to start the server? [y/N]" yn + read -e -i "y" -p "Do you want to start the server? [Y/n]" yn case $yn in [Yy]* ) exitbypass=1; command_start.sh; break;; [Nn]* ) break;; From eed7bbacbabc5b9fbf403431cf57c6c6cdb1725d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 21:50:48 +0100 Subject: [PATCH 088/195] added modulename --- lgsm/functions/core_dl.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 32f3e9ec5..d0208552c 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -18,6 +18,9 @@ lgsm_version="210516" # fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" +local modulename="Download" +function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_dl_md5(){ # Runs MD5 Check if available if [ "${md5}" != "0" ]&&[ "${md5}" != "nomd5" ]; then From dfafa3364eee5615c56e02f37bcca13ebc0402a7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 22:09:47 +0100 Subject: [PATCH 089/195] added selfname to bottom --- lgsm/functions/command_console.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 1e888155c..3d3873f0d 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -45,5 +45,7 @@ else * ) echo "Please answer yes or no.";; esac done + function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fi + core_exit.sh From b013b20aa865cfc6822f875fc3b1f526e9dca205 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 22:18:08 +0100 Subject: [PATCH 090/195] function_selfname is now local --- functions/command_update_functions.sh | 2 +- lgsm/functions/alert_pushbullet.sh | 2 +- lgsm/functions/command_backup.sh | 2 +- lgsm/functions/command_console.sh | 3 +-- lgsm/functions/command_debug.sh | 2 +- lgsm/functions/command_details.sh | 2 +- lgsm/functions/command_dev_debug.sh | 2 +- lgsm/functions/command_dev_detect_deps.sh | 2 +- lgsm/functions/command_fastdl.sh | 2 +- lgsm/functions/command_install.sh | 2 +- lgsm/functions/command_monitor.sh | 2 +- lgsm/functions/command_restart.sh | 2 +- lgsm/functions/command_start.sh | 2 +- lgsm/functions/command_stop.sh | 2 +- lgsm/functions/command_test_alert.sh | 2 +- lgsm/functions/command_ts3_server_pass.sh | 2 +- lgsm/functions/command_update.sh | 2 +- lgsm/functions/command_update_functions.sh | 2 +- lgsm/functions/command_validate.sh | 2 +- lgsm/functions/compress_unreal2_maps.sh | 2 +- lgsm/functions/compress_ut99_maps.sh | 2 +- lgsm/functions/core_dl.sh | 2 +- lgsm/functions/core_getopt.sh | 2 +- lgsm/functions/update_check.sh | 2 +- lgsm/functions/update_dl.sh | 2 +- lgsm/functions/update_ts3.sh | 2 +- 26 files changed, 26 insertions(+), 27 deletions(-) diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index d97bdc4e8..0c35eb1f0 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" fn_script_log "Updating functions" diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index cc85be8d4..ae35b8f4a 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: alerts using pushbullet. local modulename="Alert" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index a9f8f74eb..713a931c8 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Creates a .tar.gz file in the backup directory. local modulename="Backup" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_distro.sh diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 3d3873f0d..54adb8443 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Gives access to the server tmux console. local modulename="Console" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh echo "" @@ -45,7 +45,6 @@ else * ) echo "Please answer yes or no.";; esac done - function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fi core_exit.sh diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 8adb7fb86..94bca69ba 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Runs the server without tmux. Runs direct from the terminal. local modulename="Debug" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Trap to remove lockfile on quit. fn_lockfile_trap(){ diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index e1a7e2ee7..4cf92c14c 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -6,7 +6,7 @@ lgsm_version="190616" # Description: Displays server infomation. -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Standard Details # This applies to all engines diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index fe704d146..4ff0f7eb9 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Dev only: enables debuging log to be saved to dev-debug.log. -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then rm .dev-debug diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index a80fdb4c9..0db640a5a 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Detects dependencies the server binary requires. local modulename="Backup" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh cd "${executabledir}" diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index f771cea95..7d84aaba8 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -8,7 +8,7 @@ lgsm_version="060616" # Description: Creates a FastDL folder local modulename="FastDL" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index c9619e210..cdd7cd564 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Overall function for the installer. local modulename="Install" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 076016146..aa6ff3868 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -8,7 +8,7 @@ lgsm_version="210516" # then passes to monitor_gsquery.sh. local modulename="Monitor" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 23a9d6e60..6a08c2e97 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Starts the server. local modulename="Restarting" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" exitbypass=1 info_config.sh diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 9dbdca200..29b6d4db6 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Starts the server. local modulename="Starting" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ if [ ! -e "${servercfgfullpath}" ]; then diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 13c2a6b98..cee5bca36 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -7,7 +7,7 @@ lgsm_version="050616" # Description: Stops the server. local modulename="Stopping" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index c1c105a01..ea477fadb 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Sends a test email alert. local modulename="Alert" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_config.sh diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 2ec6d52d8..43892b8e8 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -8,7 +8,7 @@ lgsm_version="210516" # Description: Changes TS3 serveradmin password local modulename="Change password" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_serveradmin_password_prompt(){ diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 9612651bb..551e8cb7c 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description:Hangles updating of servers. local modulename="Update" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 8d10b8207..28fb96f30 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. local modulename="Updating LGSM" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" fn_script_log_info "Updating functions" diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 3f0b8e289..a5d1aaebb 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Runs a server validation. local modulename="Validate" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ fn_print_warn_nl "Validating may overwrite some customised files." diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 1952dbcad..7cf6f1c45 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index ac52a9e4e..5c1d8c656 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com lgsm_version="210516" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index d0208552c..3743a68f0 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -19,7 +19,7 @@ lgsm_version="210516" # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" local modulename="Download" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dl_md5(){ # Runs MD5 Check if available diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index cac791262..0542b307e 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: getopt arguments. -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_getopt_generic(){ case "${getopt}" in diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 3bddacd65..ac05d7ae4 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Checks if a server update is available. local modulename="Update" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### SteamCMD Update Checker ### diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index 02437aa00..047d80aec 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description: Runs a server update. local modulename="Update" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ cd "${rootdir}" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index e661bcb9b..92665bd99 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -7,7 +7,7 @@ lgsm_version="210516" # Description:Handles updating of teamspeak 3 servers. local modulename="Update" -function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_ts3_dl(){ fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" From 14e9bcbb4dc7fc4dce01c569f94d18207ab56169 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 22:28:26 +0100 Subject: [PATCH 091/195] messages --- lgsm/functions/command_console.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 54adb8443..80de43d13 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -25,14 +25,16 @@ while true; do * ) echo "Please answer yes or no.";; esac done -fn_print_dots "Starting" +fn_print_dots "Accessing console" sleep 1 check_status.sh if [ "${status}" != "0" ]; then - fn_print_ok_nl "Starting" - fn_script_log_info "Accessed" + fn_print_ok_nl "Accessing console" + fn_script_log_info "Console accessed" sleep 1 tmux attach-session -t ${servicename} + fn_print_ok_nl "Console closed" + fn_script_log_info "Console closed" else fn_print_fail_nl "Server not running" fn_script_log_error "Failed to access: Server not running" From 7791e097acfd1e234584260766196bedd1e36d35 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 22:30:15 +0100 Subject: [PATCH 092/195] messages --- lgsm/functions/command_console.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 80de43d13..52bdcd967 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -33,7 +33,7 @@ if [ "${status}" != "0" ]; then fn_script_log_info "Console accessed" sleep 1 tmux attach-session -t ${servicename} - fn_print_ok_nl "Console closed" + fn_print_ok_nl "Closing console" fn_script_log_info "Console closed" else fn_print_fail_nl "Server not running" From 974cc90121e1a909a59fa6477615c8157a77d41e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 22:32:19 +0100 Subject: [PATCH 093/195] messages --- lgsm/functions/command_debug.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 94bca69ba..04c4baf5a 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -15,6 +15,8 @@ fn_lockfile_trap(){ rm -f "${rootdir}/${lockselfname}" # resets terminal. Servers can sometimes mess up the terminal on exit. reset + fn_print_ok_nl "Closing debug" + fn_script_log_info "Debug closed" core_exit.sh } From b8f44749a0ff6d1d4a989db0419e4f961712684f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 23:20:37 +0100 Subject: [PATCH 094/195] Ditched lgsm_version as not used added local modulename="Function" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" to all functions --- lgsm/functions/alert.sh | 5 +++-- lgsm/functions/alert_email.sh | 4 +--- lgsm/functions/alert_pushbullet.sh | 3 +-- lgsm/functions/check.sh | 4 +++- lgsm/functions/check_config.sh | 5 +++-- lgsm/functions/check_deps.sh | 4 ++-- lgsm/functions/check_glibc.sh | 5 +++-- lgsm/functions/check_ip.sh | 5 +++-- lgsm/functions/check_logs.sh | 7 ++++--- lgsm/functions/check_permissions.sh | 5 +++-- lgsm/functions/check_root.sh | 4 +++- lgsm/functions/check_status.sh | 5 +++-- lgsm/functions/check_steamcmd.sh | 4 ++-- lgsm/functions/check_system_dir.sh | 7 ++++--- lgsm/functions/check_tmux.sh | 5 +++-- lgsm/functions/command_backup.sh | 2 -- lgsm/functions/command_console.sh | 2 -- lgsm/functions/command_debug.sh | 2 -- lgsm/functions/command_details.sh | 3 +-- lgsm/functions/command_dev_debug.sh | 4 ++-- lgsm/functions/command_dev_detect_deps.sh | 4 +--- lgsm/functions/command_fastdl.sh | 2 -- lgsm/functions/command_install.sh | 2 -- lgsm/functions/command_monitor.sh | 2 -- lgsm/functions/command_restart.sh | 2 -- lgsm/functions/command_start.sh | 2 -- lgsm/functions/command_stop.sh | 2 -- lgsm/functions/command_test_alert.sh | 4 +--- lgsm/functions/command_ts3_server_pass.sh | 6 ++---- lgsm/functions/command_update.sh | 6 ++---- lgsm/functions/command_update_functions.sh | 2 -- lgsm/functions/command_validate.sh | 2 -- lgsm/functions/compress_unreal2_maps.sh | 4 +++- lgsm/functions/compress_ut99_maps.sh | 3 ++- lgsm/functions/core_dl.sh | 2 -- lgsm/functions/core_exit.sh | 2 -- lgsm/functions/core_functions.sh | 4 +--- lgsm/functions/core_getopt.sh | 2 -- lgsm/functions/core_messages.sh | 2 -- lgsm/functions/core_trap.sh | 2 -- lgsm/functions/fix.sh | 5 +++-- lgsm/functions/fix_arma3.sh | 5 ++++- lgsm/functions/fix_csgo.sh | 2 -- lgsm/functions/fix_dst.sh | 5 +++-- lgsm/functions/fix_glibc.sh | 5 +++-- lgsm/functions/fix_ins.sh | 9 +++++---- lgsm/functions/fix_kf.sh | 5 ++++- lgsm/functions/fix_ro.sh | 5 +++-- lgsm/functions/fix_steamcmd.sh | 5 +++-- lgsm/functions/fix_ut2k4.sh | 5 +++-- lgsm/functions/fix_ut99.sh | 6 +++++- lgsm/functions/gsquery.py | 7 +++++-- lgsm/functions/info_config.sh | 4 ++-- lgsm/functions/info_distro.sh | 3 +-- lgsm/functions/info_glibc.sh | 4 ++-- lgsm/functions/info_parms.sh | 4 ++-- lgsm/functions/install_complete.sh | 2 +- lgsm/functions/install_config.sh | 2 +- lgsm/functions/install_gslt.sh | 3 +-- lgsm/functions/install_gsquery.sh | 4 +++- lgsm/functions/install_header.sh | 2 +- lgsm/functions/install_logs.sh | 2 +- lgsm/functions/install_retry.sh | 2 +- lgsm/functions/install_server_dir.sh | 2 +- lgsm/functions/install_server_files.sh | 2 +- lgsm/functions/install_steamcmd.sh | 3 +-- lgsm/functions/install_ts3.sh | 2 +- lgsm/functions/install_ts3db.sh | 2 +- lgsm/functions/install_ut2k4_key.sh | 2 +- lgsm/functions/logs.sh | 3 +-- lgsm/functions/monitor_gsquery.sh | 3 +-- lgsm/functions/update_check.sh | 2 -- lgsm/functions/update_dl.sh | 2 -- lgsm/functions/update_steamcmd.sh | 5 +++-- lgsm/functions/update_ts3.sh | 2 -- 75 files changed, 124 insertions(+), 144 deletions(-) diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 758a16226..6b12cd5fc 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -2,10 +2,11 @@ # LGSM alert.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Overall function for managing alerts. +local modulename="Alert" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_alert_test(){ fn_script_log_info "Sending test alert" alertsubject="LGSM - Test Alert - ${servername}" diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 28488f77b..98003ec3c 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -2,12 +2,10 @@ # LGSM email.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Sends email alert if monitor picks up a failure. local modulename="Alert" - +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_details_email(){ # diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index ae35b8f4a..5aa342601 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -2,12 +2,11 @@ # LGSM alert_pushbullet.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: alerts using pushbullet. local modulename="Alert" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 316e6b3f3..bffa22a13 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -2,11 +2,13 @@ # LGSM fn_check function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" # Description: Overall function for managing checks. # Runs checks that will either halt on or fix an issue. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Every command that requires checks just references check.sh # check.sh selects which checks to run by using arrays diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index b5dc757c9..2324210a5 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -2,10 +2,11 @@ # LGSM check_config.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: If server config missing warn user. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then fn_print_warn_nl "Config file missing!" diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index ac8e77771..4fb5a0822 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -2,10 +2,10 @@ # LGSM check_deps.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="090616" - # Description: Checks that the requires dependencies are installed for LGSM. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_deps_detector(){ # Checks if dependency is missing diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 65462d035..e1239d281 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -2,10 +2,11 @@ # LGSM check_glibc.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks if server has correct glibc or has a fix available. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + info_glibc.sh info_distro.sh diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index 70ee81d31..438bb880c 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -2,11 +2,12 @@ # LGSM check_ip.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Automatically identifies the server interface IP. # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0". +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ "${gamename}" != "Teamspeak 3" ]; then if [ ! -f "/bin/ip" ]; then ipcommand="/sbin/ip" diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index 0ab22fb3b..14c8e7c47 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -2,12 +2,13 @@ # LGSM check_logs.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks that log files exist on server start +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Create dir's for the script and console logs -if [ ! -d "${scriptlogdir}" ]; then +if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]; then fn_print_dots "Checking for log files" sleep 1 fn_print_info_nl "Checking for log files: Creating log files" diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 7de6ab228..013846515 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -3,10 +3,11 @@ # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks script, files and folders ownership and permissions. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Useful variables currentuser="$(whoami)" currentgroups="$(groups)" diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index d7a0eb100..37d3a6710 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -2,7 +2,9 @@ # LGSM check_root.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" + +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" diff --git a/lgsm/functions/check_status.sh b/lgsm/functions/check_status.sh index 7eb35ba7b..355ce9dd6 100644 --- a/lgsm/functions/check_status.sh +++ b/lgsm/functions/check_status.sh @@ -2,10 +2,11 @@ # LGSM check_status function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks the proccess status of the server. Either online or offline. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ "${gamename}" == "Teamspeak 3" ]; then # 1: Server is running # 0: Server seems to have died diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 28a5973a9..57f1f5343 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -2,10 +2,10 @@ # LGSM check_steamcmd.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks SteamCMD is installed and correct. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_steamcmd(){ if [ ! -d "${steamcmddir}" ]; then diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index 54ca646ae..b4eb92559 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -2,13 +2,14 @@ # LGSM check_system_dir.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" + +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -d "${systemdir}" ]; then fn_print_fail_nl "Cannot access ${systemdir}: No such directory" if [ -d "${scriptlogdir}" ]; then - fn_script_log_failure "Cannot access ${systemdir}: No such directory." + fn_script_log_fatal "Cannot access ${systemdir}: No such directory." fi - exitcode=1 core_exit.sh fi diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index 441ad177a..63ddf80c4 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -2,9 +2,10 @@ # LGSM check_tmux.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google. -# Checks if tmux is installed as too many users do not RTFM or know how to use Google. +local modulename="Checking" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then : diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 713a931c8..a71ee8339 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -2,8 +2,6 @@ # LGSM command_backup.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Creates a .tar.gz file in the backup directory. local modulename="Backup" diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 52bdcd967..b7d9a10d6 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -2,8 +2,6 @@ # LGSM command_console.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Gives access to the server tmux console. local modulename="Console" diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 04c4baf5a..d81166245 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -2,8 +2,6 @@ # LGSM command_debug.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Runs the server without tmux. Runs direct from the terminal. local modulename="Debug" diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 4cf92c14c..4cdad4d4a 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -2,10 +2,9 @@ # LGSM command_details.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="190616" - # Description: Displays server infomation. +local modulename="Details" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Standard Details diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 4ff0f7eb9..abfd9795f 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -2,12 +2,12 @@ # LGSM dev_debug.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Dev only: enables debuging log to be saved to dev-debug.log. +local modulename="Dev Debug" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ -f ".dev-debug" ]; then rm .dev-debug fn_print_ok_nl "Disabled dev-debug" diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index 0db640a5a..2dca148ef 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -2,11 +2,9 @@ # LGSM fn_dep_detect function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Detects dependencies the server binary requires. -local modulename="Backup" +local modulename="Deps Detect" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 7d84aaba8..de00c8902 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -3,8 +3,6 @@ # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com -lgsm_version="060616" - # Description: Creates a FastDL folder local modulename="FastDL" diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index cdd7cd564..87ddac2c3 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -2,8 +2,6 @@ # LGSM fn_install function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Overall function for the installer. local modulename="Install" diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index aa6ff3868..354ba8a64 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -2,8 +2,6 @@ # LGSM command_monitor.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Monitors server by checking for running proccesses # then passes to monitor_gsquery.sh. diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 6a08c2e97..528737f7d 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -2,8 +2,6 @@ # LGSM command_start.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Starts the server. local modulename="Restarting" diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 29b6d4db6..c7882ae44 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -2,8 +2,6 @@ # LGSM command_start.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Starts the server. local modulename="Starting" diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index cee5bca36..8ff3c2859 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -2,8 +2,6 @@ # LGSM command_stop.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="050616" - # Description: Stops the server. local modulename="Stopping" diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index ea477fadb..2fe73ee31 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -1,9 +1,7 @@ #!/bin/bash -# LGSM command_email_test.sh function +# LGSM command_test_alert.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Sends a test email alert. local modulename="Alert" diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 43892b8e8..6386b8f08 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -1,13 +1,11 @@ #!/bin/bash -# LGSM command_serveradmin_password.sh function +# LGSM command_ts3_server_pass.sh function # Author: Daniel Gibbs # Contributor : UltimateByte # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Changes TS3 serveradmin password -local modulename="Change password" +local modulename="TS3 Change Password" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 551e8cb7c..6bc1c75c4 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -1,10 +1,8 @@ #!/bin/bash -# LGSM commanf_update.sh function +# LGSM command_update.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - -# Description:Hangles updating of servers. +# Description: Handles updating of servers. local modulename="Update" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 28fb96f30..d599c807c 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -2,8 +2,6 @@ # LGSM command_update_functions.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. local modulename="Updating LGSM" diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index a5d1aaebb..ca9bbcfee 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -2,8 +2,6 @@ # LGSM command_validate.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Runs a server validation. local modulename="Validate" diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 7cf6f1c45..3fa752867 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -2,8 +2,9 @@ # LGSM compress_unreal2_maps.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: compresses unreal maps +local modulename="Unreal Map Compressor" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh @@ -33,3 +34,4 @@ for map in "${filesdir}/Maps/"*; do ./ucc-bin compress "${map}" --nohomedir done mv -fv "${filesdir}/Maps/"*.ut2.uz2 "${compressedmapsdir}" +core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index 5c1d8c656..f5414125d 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -2,8 +2,9 @@ # LGSM compress_ut99_maps.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: compresses unreal maps +local modulename="Unreal Map Compressor" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 3743a68f0..d505cc1a4 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -2,8 +2,6 @@ # LGSM core_dl.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Deals with all downloads for LGSM. # fileurl: The URL of the file: http://example.com/dl/File.tar.bz2 diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 0eb19c753..d7994ca2e 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -2,8 +2,6 @@ # LGSM core_exit.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: handles exiting of LGSM by running and reporting an exit code. fn_exit_dev_debug(){ diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index d177ec657..9a5706344 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -2,10 +2,8 @@ # LGSM core_functions.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Defines all functions to allow download and execution of functions using fn_fetch_function. -# This function is called first before any other function. Without this file other functions would not load. +# This function is called first before any other function. Without this file other functions will not load. # Code/functions for legacy servers diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 0542b307e..2a2abbc9f 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -2,8 +2,6 @@ # LGSM core_getopt.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: getopt arguments. local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index e0eef7f0d..34ca1f8ee 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -2,8 +2,6 @@ # LGSM fn_messages function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Defines on-screen messages such as [ OK ] and how script logs look. # nl: new line: message is following by a new line diff --git a/lgsm/functions/core_trap.sh b/lgsm/functions/core_trap.sh index 966b53d09..e53236410 100644 --- a/lgsm/functions/core_trap.sh +++ b/lgsm/functions/core_trap.sh @@ -2,8 +2,6 @@ # LGSM core_trap.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: handles ctrl-C trap to give an exitcode. fn_exit_trap(){ diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 041c6c151..d1d436432 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -2,11 +2,12 @@ # LGSM fix.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Overall function for managing fixes. # Runs functions that will fix an issue. +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Messages that are displayed for some fixes fn_fix_msg_start(){ fn_print_dots "Applying ${fixname} fix: ${gamename}" diff --git a/lgsm/functions/fix_arma3.sh b/lgsm/functions/fix_arma3.sh index cc3c2aaf0..f788b85b9 100644 --- a/lgsm/functions/fix_arma3.sh +++ b/lgsm/functions/fix_arma3.sh @@ -2,7 +2,10 @@ # LGSM fix_arma3.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="240516" +# Description: Resolves an issue with ARMA3. + +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: 20150 Segmentation fault (core dumped) error. if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then diff --git a/lgsm/functions/fix_csgo.sh b/lgsm/functions/fix_csgo.sh index 0f8a4b8fb..a2a75bed6 100644 --- a/lgsm/functions/fix_csgo.sh +++ b/lgsm/functions/fix_csgo.sh @@ -2,8 +2,6 @@ # LGSM fix_csgo.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Resolves various issues with csgo. # Fixes: server not always creating steam_appid.txt file. diff --git a/lgsm/functions/fix_dst.sh b/lgsm/functions/fix_dst.sh index 1106b58e0..25fb8175b 100644 --- a/lgsm/functions/fix_dst.sh +++ b/lgsm/functions/fix_dst.sh @@ -2,10 +2,11 @@ # LGSM fix_dst.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Resolves various issues with Dont Starve together. +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. if [ -f "/etc/redhat-release" ] && [ ! -f "${filesdir}/bin/lib32/libcurl-gnutls.so.4" ]; then diff --git a/lgsm/functions/fix_glibc.sh b/lgsm/functions/fix_glibc.sh index 59a0983b1..82a689b8d 100644 --- a/lgsm/functions/fix_glibc.sh +++ b/lgsm/functions/fix_glibc.sh @@ -2,10 +2,11 @@ # LGSM fix_glibc.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Downloads required glibc files and applys teh glibc fix if required +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" ) for libstdc_server in "${libstdc_servers_array[@]}" do diff --git a/lgsm/functions/fix_ins.sh b/lgsm/functions/fix_ins.sh index 81a206d84..7afc46eeb 100644 --- a/lgsm/functions/fix_ins.sh +++ b/lgsm/functions/fix_ins.sh @@ -2,15 +2,16 @@ # LGSM fix_ins.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Resolves various issues with Insurgency. -# Resolves ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + +# Fixes: ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory. export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH} -# fix for issue #529 - gamemode not passed to debug or start +# Fixes: issue #529 - gamemode not passed to debug or start. if [ "${function_selfname}" == "command_debug.sh" ]; then defaultmap="\"${defaultmap}\"" diff --git a/lgsm/functions/fix_kf.sh b/lgsm/functions/fix_kf.sh index 7b5547851..5d87e3f48 100644 --- a/lgsm/functions/fix_kf.sh +++ b/lgsm/functions/fix_kf.sh @@ -2,7 +2,10 @@ # LGSM fix_kf.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Resolves various issues with Killing Floor. + +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ro.sh b/lgsm/functions/fix_ro.sh index 7e3115f8b..a8b062a22 100644 --- a/lgsm/functions/fix_ro.sh +++ b/lgsm/functions/fix_ro.sh @@ -2,9 +2,10 @@ # LGSM fix_ro.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Resolves various issues with Red Orchestra. -# Description: Resolves various issues with red orchestra. +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_steamcmd.sh b/lgsm/functions/fix_steamcmd.sh index 9b85cc47a..a95e888fc 100644 --- a/lgsm/functions/fix_steamcmd.sh +++ b/lgsm/functions/fix_steamcmd.sh @@ -2,9 +2,10 @@ # LGSM fix_steamcmd.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Resolves various issues related to steamCMD. -# Description: fixes various issues related to steamCMD. +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then diff --git a/lgsm/functions/fix_ut2k4.sh b/lgsm/functions/fix_ut2k4.sh index a0f07ac26..1f6243989 100644 --- a/lgsm/functions/fix_ut2k4.sh +++ b/lgsm/functions/fix_ut2k4.sh @@ -2,9 +2,10 @@ # LGSM fix_ut2k4.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Resolves various issues with Unreal Tournament 2004. -# Description: Resolves various issues with unreal tournament 2004. +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "applying WebAdmin ut2003.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ut99.sh b/lgsm/functions/fix_ut99.sh index 58644c03d..76213aaae 100644 --- a/lgsm/functions/fix_ut99.sh +++ b/lgsm/functions/fix_ut99.sh @@ -2,7 +2,11 @@ # LGSM fix_ut99.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" +# Description: Resolves various issues with Unreal Tournament 99. + +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + echo "${servercfgfullpath}" echo "enabling UdpServerUplink." { diff --git a/lgsm/functions/gsquery.py b/lgsm/functions/gsquery.py index 8f7b8208c..3bd9246b8 100644 --- a/lgsm/functions/gsquery.py +++ b/lgsm/functions/gsquery.py @@ -2,8 +2,11 @@ # -*- coding: utf-8 -*- # Game Server Query # Author: Anonymous & Daniel Gibbs -# # Website: https://gameservermanagers.com -# Version: 190216 +# Website: https://gameservermanagers.com +# Description: Handles querying of . + +local modulename="Fix" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" import optparse import socket diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index b48176cdb..fd3cdbdc2 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -2,10 +2,10 @@ # LGSM info_config.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Gets specific details from config files. +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo # tr -cd '[:digit:]' leave only digits diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 17aff8d92..fdcd01b29 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -2,11 +2,10 @@ # LGSM info_distro.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="190616" - # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for command_details.sh, command_debug.sh and alert.sh. +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### Distro infomation diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index fa69c010a..2a1adc058 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -2,10 +2,10 @@ # LGSM info_glibc.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: stores details on servers Glibc requirements. +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + if [ "${gamename}" == "Blade Symphony" ]; then glibcrequired="2.15" glibcfix="yes" diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index 1e59ca162..efdab1c7e 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -2,10 +2,10 @@ # LGSM info_parms.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Gets specific details from server parameters. +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo # tr -cd '[:digit:]' leave only digits diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index 6f9c9c8fa..962c12ff6 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -2,9 +2,9 @@ # LGSM install_complete.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Don't Starve Together" ]; then echo "" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index d19eaeddd..f7e39434e 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -2,9 +2,9 @@ # LGSM install_config.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_defaultconfig(){ echo "creating ${servercfg} config file." diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index 86ab78d06..823deee11 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -2,11 +2,10 @@ # LGSM install_gslt.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Configures GSLT. local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Game Server Login Token" diff --git a/lgsm/functions/install_gsquery.sh b/lgsm/functions/install_gsquery.sh index 86025c0a0..710a6080a 100644 --- a/lgsm/functions/install_gsquery.sh +++ b/lgsm/functions/install_gsquery.sh @@ -2,7 +2,9 @@ # LGSM install_gsquery.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" + +local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dlgsquery(){ cd "${functionsdir}" diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index 96c56a209..b5a817e95 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -2,9 +2,9 @@ # LGSM install_header.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" clear echo "=================================" diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index 4110e6c04..14ecf4c31 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -2,9 +2,9 @@ # LGSM install_logs.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${checklogs}" != "1" ]; then echo "" diff --git a/lgsm/functions/install_retry.sh b/lgsm/functions/install_retry.sh index 80df1a6ba..c56898898 100644 --- a/lgsm/functions/install_retry.sh +++ b/lgsm/functions/install_retry.sh @@ -2,9 +2,9 @@ # LGSM install_retry.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" while true; do read -e -i "y" -p "Retry install? [Y/n]" yn diff --git a/lgsm/functions/install_server_dir.sh b/lgsm/functions/install_server_dir.sh index c9aabc829..c2c6b36eb 100644 --- a/lgsm/functions/install_server_dir.sh +++ b/lgsm/functions/install_server_dir.sh @@ -2,9 +2,9 @@ # LGSM install_serverdir.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Server Directory" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index aa7da151b..f37390277 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -2,9 +2,9 @@ # LGSM install_server_files.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="270516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index 7c733d289..a5951c046 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -2,11 +2,10 @@ # LGSM install_steamcmd.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Downloads SteamCMD on install. local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Installing SteamCMD" diff --git a/lgsm/functions/install_ts3.sh b/lgsm/functions/install_ts3.sh index 44d2b4231..3a6eab039 100644 --- a/lgsm/functions/install_ts3.sh +++ b/lgsm/functions/install_ts3.sh @@ -2,9 +2,9 @@ # LGSM install_ts3.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" info_distro.sh # Gets the teamspeak server architecture diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index e2027a42b..cc7f0da9d 100644 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Contributor: PhilPhonic # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_ts3db_mariadb(){ echo "" diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 32e80728a..2fe62b3c6 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -2,9 +2,9 @@ # LGSM install_ut2k4_key.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" local modulename="Install" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Enter ${gamename} CD Key" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index de29bf8f0..cfbd28beb 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -3,11 +3,10 @@ # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Acts as a log rotater, removing old logs. local modulename="Log Manager" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Check if logfile variable and file exist, create logfile if it doesn't exist if [ -n "${consolelog}" ]; then diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 607f3ac96..80070bf35 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -2,12 +2,11 @@ # LGSM monitor_gsquery.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. local modulename="Monitor" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Forces legecy servers to use gsquery if [ -z "${gsquery}" ]; then diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index ac05d7ae4..6a6efb77e 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -2,8 +2,6 @@ # LGSM update_check.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Checks if a server update is available. local modulename="Update" diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index 047d80aec..29b67a8ff 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -2,8 +2,6 @@ # LGSM update_dl.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description: Runs a server update. local modulename="Update" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 9bfabc050..6dfd0ddc1 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -2,10 +2,11 @@ # LGSM commanf_update.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description:Handles updating using steamCMD. +local modulename="Update" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + fn_update_steamcmd_dl(){ check.sh diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 92665bd99..8f6fee29e 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -2,8 +2,6 @@ # LGSM commanf_update.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -lgsm_version="210516" - # Description:Handles updating of teamspeak 3 servers. local modulename="Update" From 462e54542f6cfbf4ff23e8d56d7fa48ae35e93c8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 7 Jul 2016 23:27:57 +0100 Subject: [PATCH 095/195] command_update.sh --- lgsm/functions/core_getopt.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 2a2abbc9f..15686b35c 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -82,7 +82,7 @@ case "${getopt}" in r|restart) command_restart.sh;; u|update) - update_check.sh;; + command_update.sh;; uf|update-functions) command_update_functions.sh;; m|monitor) @@ -187,7 +187,7 @@ case "${getopt}" in r|restart) command_restart.sh;; u|update) - update_check.sh;; + command_update.sh;; fu|force-update|update-restart) forceupdate=1; update_check.sh;; @@ -318,7 +318,7 @@ case "${getopt}" in r|restart) command_restart.sh;; u|update) - update_check.sh;; + command_update.sh;; fu|force-update|update-restart) forceupdate=1; update_check.sh;; From 737f5fe3db5096bb3361ca28913cbfe43f185852 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 00:29:09 +0100 Subject: [PATCH 096/195] moved tmp file to tmp dir --- lgsm/functions/update_ts3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 8f6fee29e..dd14be694 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -65,7 +65,7 @@ fn_update_ts3_availablebuild(){ # Gets availablebuild info. # Grabs all version numbers but not in correct order. -wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp +wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" # Sort version numbers cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" From 9f08f682ccf487a8fce3e73c5ec85695b7fffa72 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 00:35:41 +0100 Subject: [PATCH 097/195] created tmp dir if missing --- lgsm/functions/update_ts3.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index dd14be694..3f42103ae 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -64,6 +64,11 @@ fi fn_update_ts3_availablebuild(){ # Gets availablebuild info. +# Creates tmp dir if missing +if [ ! -d "${lgsmdir}/tmp" ]; then + mkdir -p "${lgsmdir}/tmp" +fi + # Grabs all version numbers but not in correct order. wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" From 94be9940e0bac8deb3ec79fbd2053d52565b3eb6 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 00:46:38 +0100 Subject: [PATCH 098/195] bug --- lgsm/functions/update_ts3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 3f42103ae..88911ad8c 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -73,7 +73,7 @@ fi wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" # Sort version numbers -cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" +cat "${lgsmdir}/tmp/.ts3_version_numbers_unsorted.tmp" | sort -r --version-sort -o "${lgsmdir}/tmp/.ts3_version_numbers_sorted.tmp" # Finds directory with most recent server version. while read ts3_version_number; do From 505d0c544bfa5050ecae698814253c566ba39dc2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 00:50:23 +0100 Subject: [PATCH 099/195] stop exitmsg on same line --- lgsm/functions/core_exit.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index d7994ca2e..3211b095f 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -6,6 +6,7 @@ fn_exit_dev_debug(){ if [ -f "${rootdir}/.dev-debug" ]; then + echo "" echo "${function_selfname} exiting with code: ${exitcode}" fi } From 6e2d050e64b470aba25ca0f037b955cf3b50bbc2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:05:40 +0100 Subject: [PATCH 100/195] added fn_update_ts3_arch to correct location --- lgsm/functions/update_ts3.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 88911ad8c..72856a481 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -159,6 +159,7 @@ fn_update_ts3_compare(){ fi } +fn_update_ts3_arch if [ "${installer}" == "1" ]; then fn_update_ts3_availablebuild fn_update_ts3_dl From c7492eb7f0220206e2906a20406070fb6f703cea Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:11:46 +0100 Subject: [PATCH 101/195] removed function_selfname as breaks check.sh --- lgsm/functions/check.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index bffa22a13..7c8da154c 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -7,7 +7,6 @@ # Runs checks that will either halt on or fix an issue. local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Every command that requires checks just references check.sh # check.sh selects which checks to run by using arrays From 89375352955e611454b715ac776df960c0b34102 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:23:17 +0100 Subject: [PATCH 102/195] fixing extract and copy --- lgsm/functions/update_ts3.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 72856a481..dcc1364e6 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -9,7 +9,16 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_ts3_dl(){ fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${filesdir}" + fn_dl_extract "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" + echo -e "copying to ${filesdir}...\c" + fn_script_log "Copying to ${filesdir}" + cp -R "${lgsmdir}/tmp/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" + local exitcode=$? + if [ ${exitcode} -eq 0 ]; then + fn_print_ok_eol_nl + else + fn_print_fail_eol_nl + fi } @@ -97,7 +106,7 @@ if [ -z "${availablebuild}" ]; then fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" core_exit.sh else - fn_print_ok "Checking for update: teamspeak.com" + fn_print_ok_nl "Checking for update: teamspeak.com" fn_script_log_pass "Checking for update: teamspeak.com" sleep 1 fi From 21a9b95c626064a3fc308e78fd2c63a45099a8ee Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:25:43 +0100 Subject: [PATCH 103/195] hides checking for update in installer --- lgsm/functions/update_ts3.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index dcc1364e6..3fca4194f 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -22,10 +22,7 @@ fn_update_ts3_dl(){ } -# Checks for server update from teamspeak.com using a mirror dl.4players.de. -fn_print_dots "Checking for update: teamspeak.com" -fn_script_log_info "Checking for update: teamspeak.com" -sleep 1 + fn_update_ts3_currentbuild(){ # Gets currentbuild info @@ -168,11 +165,16 @@ fn_update_ts3_compare(){ fi } + fn_update_ts3_arch if [ "${installer}" == "1" ]; then fn_update_ts3_availablebuild fn_update_ts3_dl else + # Checks for server update from teamspeak.com using a mirror dl.4players.de. + fn_print_dots "Checking for update: teamspeak.com" + fn_script_log_info "Checking for update: teamspeak.com" + sleep 1 fn_update_ts3_currentbuild fn_update_ts3_availablebuild fn_update_ts3_compare From b0628fa30c158c3fa4a2f1b004c2ea7915bf7b32 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:32:05 +0100 Subject: [PATCH 104/195] & != teamspeak3 --- lgsm/functions/check_logs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index 14c8e7c47..2e7a1b6bd 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -8,7 +8,7 @@ local modulename="Checking" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Create dir's for the script and console logs -if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]; then +if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then fn_print_dots "Checking for log files" sleep 1 fn_print_info_nl "Checking for log files: Creating log files" From fd4a4e57c648c3a27a9db0503f0d6960d014b36e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:32:13 +0100 Subject: [PATCH 105/195] message --- lgsm/functions/command_update_functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index d599c807c..c6136446e 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. -local modulename="Updating LGSM" +local modulename="Update LGSM" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" From 846754fa28687b25b17386f05de31c5bf065b913 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 01:42:37 +0100 Subject: [PATCH 106/195] added log messages --- lgsm/functions/install_config.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index f7e39434e..f5b207e8f 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -8,6 +8,7 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_defaultconfig(){ echo "creating ${servercfg} config file." + fn_script_log_info "creating ${servercfg} config file." cp -v "${servercfgdefault}" "${servercfgfullpath}" sleep 1 } @@ -26,9 +27,11 @@ fn_userinputconfig(){ rconpass="rconpassword" fi echo "changing hostname." + fn_script_log_info "changing hostname." sed -i "s/\"\"/\"${servername}\"/g" "${servercfgfullpath}" sleep 1 echo "changing rconpassword." + fn_script_log_info "changing rconpassword." sed -i "s/\"\"/\"${rconpass}\"/g" "${servercfgfullpath}" sleep 1 } @@ -36,6 +39,7 @@ fn_userinputconfig(){ fn_arma3config(){ fn_defaultconfig echo "creating ${networkcfg} config file." + fn_script_log_info "creating ${networkcfg} config file." cp -v "${networkcfgdefault}" "${networkcfgfullpath}" sleep 1 echo "" @@ -46,18 +50,22 @@ fn_goldsourceconfig(){ # server.cfg redirects to ${servercfg} for added security echo "creating server.cfg." + fn_script_log_info "creating server.cfg." touch "server.cfg" sleep 1 echo "creating redirect." + fn_script_log_info "creating redirect." echo "server.cfg > ${servercfg}." echo "exec ${servercfg}" > "server.cfg" sleep 1 # creating other files required echo "creating listip.cfg." + fn_script_log_info "creating listip.cfg." touch "${systemdir}/listip.cfg" sleep 1 echo "creating banned.cfg." + fn_script_log_info "creating banned.cfg." touch "${systemdir}/banned.cfg" sleep 1 @@ -70,6 +78,8 @@ fn_serious3config(){ echo "" echo "To edit ${gamename} server config use SS3 Server GUI 3 tool" echo "http://mrag.nl/sgui3/" + fn_script_log_info "To edit ${gamename} server config use SS3 Server GUI 3 tool" + fn_script_log_info "http://mrag.nl/sgui3/" sleep 1 echo "" } @@ -79,9 +89,11 @@ fn_sourceconfig(){ # server.cfg redirects to ${servercfg} for added security echo "creating server.cfg." + fn_script_log_info "creating server.cfg." touch "server.cfg" sleep 1 echo "creating redirect." + fn_script_log_info "creating redirect." echo "server.cfg > ${servercfg}." echo "exec ${servercfg}" > "server.cfg" sleep 1 @@ -94,9 +106,11 @@ fn_teeworldsconfig(){ fn_defaultconfig echo "adding logfile location to config." + fn_script_log_info "adding logfile location to config." sed -i "s@\"\"@\"${gamelog}\"@g" "${servercfgfullpath}" sleep 1 echo "removing password holder." + fn_script_log_info "removing password holder." sed -i "s///" "${servercfgfullpath}" sleep 1 @@ -105,6 +119,8 @@ fn_teeworldsconfig(){ } fn_ut99config(){ + echo "creating ${servercfg} config file." + fn_script_log_info "creating ${servercfg} config file." echo "${servercfgdefault} > ${servercfgfullpath}" tr -d '\r' < "${servercfgdefault}" > "${servercfgfullpath}" sleep 1 @@ -113,9 +129,11 @@ fn_ut99config(){ echo "=================================" sleep 1 echo "enabling WebAdmin." + fn_script_log_info "enabling WebAdmin." sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}" sleep 1 echo "setting WebAdmin port to 8076." + fn_script_log_info "setting WebAdmin port to 8076." sed -i '467i\ListenPort=8076' "${servercfgfullpath}" sleep 1 echo "" @@ -128,14 +146,17 @@ fn_unreal2config(){ echo "=================================" sleep 1 echo "setting WebAdmin username and password." + fn_script_log_info "setting WebAdmin username and password." sed -i 's/AdminName=/AdminName=admin/g' "${servercfgfullpath}" sed -i 's/AdminPassword=/AdminPassword=admin/g' "${servercfgfullpath}" sleep 1 echo "enabling WebAdmin." + fn_script_log_info "enabling WebAdmin." sed -i 's/bEnabled=False/bEnabled=True/g' "${servercfgfullpath}" if [ "${gamename}" == "Unreal Tournament 2004" ]; then sleep 1 echo "setting WebAdmin port to 8075." + fn_script_log_info "setting WebAdmin port to 8075." sed -i 's/ListenPort=80/ListenPort=8075/g' "${servercfgfullpath}" fi sleep 1 From 852a2140ba11a32dcdeb925eee2d077b42f17068 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 18:20:00 +0100 Subject: [PATCH 107/195] bug: removed bash code --- lgsm/functions/gsquery.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lgsm/functions/gsquery.py b/lgsm/functions/gsquery.py index 3bd9246b8..8102e28a7 100644 --- a/lgsm/functions/gsquery.py +++ b/lgsm/functions/gsquery.py @@ -5,9 +5,6 @@ # Website: https://gameservermanagers.com # Description: Handles querying of . -local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" - import optparse import socket import sys From b32bb17ae49a55b2b7210795274733c9f0fa963c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 19:29:00 +0100 Subject: [PATCH 108/195] functions_selfname is now just selfname Also commented out any selfname that causes issues. --- lgsm/functions/core_dl.sh | 2 +- lgsm/functions/core_getopt.sh | 2 +- lgsm/functions/fix.sh | 7 ++++--- lgsm/functions/fix_arma3.sh | 2 +- lgsm/functions/fix_dst.sh | 2 +- lgsm/functions/fix_glibc.sh | 2 +- lgsm/functions/fix_ins.sh | 5 +++-- lgsm/functions/fix_kf.sh | 2 +- lgsm/functions/fix_ro.sh | 2 +- lgsm/functions/fix_steamcmd.sh | 2 +- lgsm/functions/fix_ut2k4.sh | 2 +- lgsm/functions/fix_ut99.sh | 2 +- lgsm/functions/info_config.sh | 2 +- lgsm/functions/info_distro.sh | 2 +- lgsm/functions/info_glibc.sh | 2 +- lgsm/functions/info_parms.sh | 2 +- lgsm/functions/install_complete.sh | 2 +- lgsm/functions/update_ts3.sh | 2 +- 18 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index d505cc1a4..71321fad2 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -17,7 +17,7 @@ # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" local modulename="Download" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dl_md5(){ # Runs MD5 Check if available diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 15686b35c..6cbb77b8e 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: getopt arguments. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_getopt_generic(){ case "${getopt}" in diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index d1d436432..c70087065 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -6,7 +6,8 @@ # Runs functions that will fix an issue. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +# Cannot have selfname as breaks if statements. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Messages that are displayed for some fixes fn_fix_msg_start(){ @@ -30,7 +31,7 @@ fn_fix_msg_end(){ # Fixes that are run on start -if [ "${function_selfname}" != "command_install.sh" ]; then +if [ "${selfname}" != "command_install.sh" ]; then if [ -n "${appid}" ]; then fix_steamcmd.sh fi @@ -51,7 +52,7 @@ if [ "${function_selfname}" != "command_install.sh" ]; then fi # Fixes that are run on install only. -if [ "${function_selfname}" == "command_install.sh" ]; then +if [ "${selfname}" == "command_install.sh" ]; then if [ "${gamename}" == "Killing Floor" ]; then echo "" echo "Applying ${gamename} Server Fixes" diff --git a/lgsm/functions/fix_arma3.sh b/lgsm/functions/fix_arma3.sh index f788b85b9..5c66d2fd0 100644 --- a/lgsm/functions/fix_arma3.sh +++ b/lgsm/functions/fix_arma3.sh @@ -5,7 +5,7 @@ # Description: Resolves an issue with ARMA3. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: 20150 Segmentation fault (core dumped) error. if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then diff --git a/lgsm/functions/fix_dst.sh b/lgsm/functions/fix_dst.sh index 25fb8175b..31f77e416 100644 --- a/lgsm/functions/fix_dst.sh +++ b/lgsm/functions/fix_dst.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues with Dont Starve together. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. diff --git a/lgsm/functions/fix_glibc.sh b/lgsm/functions/fix_glibc.sh index 82a689b8d..d1e0ab89f 100644 --- a/lgsm/functions/fix_glibc.sh +++ b/lgsm/functions/fix_glibc.sh @@ -5,7 +5,7 @@ # Description: Downloads required glibc files and applys teh glibc fix if required local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" ) for libstdc_server in "${libstdc_servers_array[@]}" diff --git a/lgsm/functions/fix_ins.sh b/lgsm/functions/fix_ins.sh index 7afc46eeb..5b6061fef 100644 --- a/lgsm/functions/fix_ins.sh +++ b/lgsm/functions/fix_ins.sh @@ -5,7 +5,8 @@ # Description: Resolves various issues with Insurgency. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +# Cannot have selfname as breaks if statement. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory. @@ -13,7 +14,7 @@ export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH} # Fixes: issue #529 - gamemode not passed to debug or start. -if [ "${function_selfname}" == "command_debug.sh" ]; then +if [ "${selfname}" == "command_debug.sh" ]; then defaultmap="\"${defaultmap}\"" else defaultmap="\\\"${defaultmap}\\\"" diff --git a/lgsm/functions/fix_kf.sh b/lgsm/functions/fix_kf.sh index 5d87e3f48..048fa839d 100644 --- a/lgsm/functions/fix_kf.sh +++ b/lgsm/functions/fix_kf.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues with Killing Floor. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ro.sh b/lgsm/functions/fix_ro.sh index a8b062a22..8e3f6ccbd 100644 --- a/lgsm/functions/fix_ro.sh +++ b/lgsm/functions/fix_ro.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues with Red Orchestra. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_steamcmd.sh b/lgsm/functions/fix_steamcmd.sh index a95e888fc..00d871d10 100644 --- a/lgsm/functions/fix_steamcmd.sh +++ b/lgsm/functions/fix_steamcmd.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues related to steamCMD. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then diff --git a/lgsm/functions/fix_ut2k4.sh b/lgsm/functions/fix_ut2k4.sh index 1f6243989..3f82407ba 100644 --- a/lgsm/functions/fix_ut2k4.sh +++ b/lgsm/functions/fix_ut2k4.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues with Unreal Tournament 2004. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "applying WebAdmin ut2003.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ut99.sh b/lgsm/functions/fix_ut99.sh index 76213aaae..b956e6536 100644 --- a/lgsm/functions/fix_ut99.sh +++ b/lgsm/functions/fix_ut99.sh @@ -5,7 +5,7 @@ # Description: Resolves various issues with Unreal Tournament 99. local modulename="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "${servercfgfullpath}" echo "enabling UdpServerUplink." diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index fd3cdbdc2..ffed74203 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: Gets specific details from config files. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index fdcd01b29..7e476e987 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -5,7 +5,7 @@ # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for command_details.sh, command_debug.sh and alert.sh. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### Distro infomation diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index 2a1adc058..8a02ec78e 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: stores details on servers Glibc requirements. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Blade Symphony" ]; then glibcrequired="2.15" diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index efdab1c7e..a640ac938 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: Gets specific details from server parameters. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index 962c12ff6..92c9e5082 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Don't Starve Together" ]; then echo "" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 3fca4194f..752269217 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -5,7 +5,7 @@ # Description:Handles updating of teamspeak 3 servers. local modulename="Update" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_ts3_dl(){ fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" From 21512494fa7b8b84a97c185c73634c485ef256a9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 19:53:47 +0100 Subject: [PATCH 109/195] module name has been split now named commandname and command action command name is used in logs command action is used on-screen. Also alterations to function_selfname now called just selfname --- functions/command_update_functions.sh | 2 +- lgsm/functions/alert.sh | 14 +++++++------ lgsm/functions/alert_email.sh | 5 +++-- lgsm/functions/alert_pushbullet.sh | 5 +++-- lgsm/functions/check.sh | 23 ++++++++++++---------- lgsm/functions/check_config.sh | 5 +++-- lgsm/functions/check_deps.sh | 14 +++++++------ lgsm/functions/check_glibc.sh | 8 +++++--- lgsm/functions/check_ip.sh | 5 +++-- lgsm/functions/check_logs.sh | 5 +++-- lgsm/functions/check_permissions.sh | 5 +++-- lgsm/functions/check_root.sh | 5 +++-- lgsm/functions/check_status.sh | 5 +++-- lgsm/functions/check_steamcmd.sh | 12 ++++++----- lgsm/functions/check_system_dir.sh | 5 +++-- lgsm/functions/check_tmux.sh | 5 +++-- lgsm/functions/command_backup.sh | 5 +++-- lgsm/functions/command_console.sh | 5 +++-- lgsm/functions/command_debug.sh | 5 +++-- lgsm/functions/command_details.sh | 5 +++-- lgsm/functions/command_dev_debug.sh | 5 +++-- lgsm/functions/command_dev_detect_deps.sh | 5 +++-- lgsm/functions/command_fastdl.sh | 5 +++-- lgsm/functions/command_install.sh | 5 +++-- lgsm/functions/command_monitor.sh | 5 +++-- lgsm/functions/command_restart.sh | 5 +++-- lgsm/functions/command_start.sh | 5 +++-- lgsm/functions/command_stop.sh | 5 +++-- lgsm/functions/command_test_alert.sh | 5 +++-- lgsm/functions/command_ts3_server_pass.sh | 5 +++-- lgsm/functions/command_update.sh | 5 +++-- lgsm/functions/command_update_functions.sh | 4 ++-- lgsm/functions/command_validate.sh | 5 +++-- lgsm/functions/compress_unreal2_maps.sh | 4 ++-- lgsm/functions/compress_ut99_maps.sh | 4 ++-- lgsm/functions/core_dl.sh | 3 ++- lgsm/functions/core_exit.sh | 12 +++++------ lgsm/functions/fix.sh | 3 ++- lgsm/functions/fix_arma3.sh | 3 ++- lgsm/functions/fix_csgo.sh | 4 ++++ lgsm/functions/fix_dst.sh | 3 ++- lgsm/functions/fix_glibc.sh | 3 ++- lgsm/functions/fix_ins.sh | 3 ++- lgsm/functions/fix_kf.sh | 3 ++- lgsm/functions/fix_ro.sh | 3 ++- lgsm/functions/fix_steamcmd.sh | 3 ++- lgsm/functions/fix_ut2k4.sh | 3 ++- lgsm/functions/fix_ut99.sh | 3 ++- lgsm/functions/install_complete.sh | 3 ++- lgsm/functions/install_config.sh | 5 +++-- lgsm/functions/install_gslt.sh | 5 +++-- lgsm/functions/install_gsquery.sh | 5 +++-- lgsm/functions/install_header.sh | 5 +++-- lgsm/functions/install_logs.sh | 5 +++-- lgsm/functions/install_retry.sh | 5 +++-- lgsm/functions/install_server_dir.sh | 5 +++-- lgsm/functions/install_server_files.sh | 5 +++-- lgsm/functions/install_steamcmd.sh | 5 +++-- lgsm/functions/install_ts3.sh | 5 +++-- lgsm/functions/install_ts3db.sh | 5 +++-- lgsm/functions/install_ut2k4_key.sh | 5 +++-- lgsm/functions/logs.sh | 8 +++++--- lgsm/functions/monitor_gsquery.sh | 5 +++-- lgsm/functions/update_check.sh | 5 +++-- lgsm/functions/update_dl.sh | 5 +++-- lgsm/functions/update_steamcmd.sh | 5 +++-- lgsm/functions/update_ts3.sh | 3 ++- 67 files changed, 215 insertions(+), 143 deletions(-) diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index 0c35eb1f0..31b9672b7 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" fn_script_log "Updating functions" diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 6b12cd5fc..6c84a883d 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -4,8 +4,10 @@ # Website: https://gameservermanagers.com # Description: Overall function for managing alerts. -local modulename="Alert" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="ALERT" +local commandaction="Alert" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_alert_test(){ fn_script_log_info "Sending test alert" @@ -43,20 +45,20 @@ fi if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then alert_email.sh -elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then +elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Email alerts not enabled" fn_script_log_info "Email alerts not enabled" -elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then +elif [ -z "${email}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Email not set" fn_script_log "Email not set" fi if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh -elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then +elif [ "${pushbulletalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then fn_print_info_nl "Pushbullet alerts not enabled" fn_script_log_info "Pushbullet alerts not enabled" -elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then +elif [ -z "${pushbullettoken}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then fn_print_fail_nl "Pushbullet token not set" fn_script_log_warn "Pushbullet token not set" fi \ No newline at end of file diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 98003ec3c..7f7bf63f6 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Sends email alert if monitor picks up a failure. -local modulename="Alert" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="ALERT" +local commandaction="Alert" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_details_email(){ # diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 5aa342601..2b2bca093 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: alerts using pushbullet. -local modulename="Alert" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="ALERT" +local commandaction="Alert" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 7c8da154c..a674bcd49 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -6,7 +6,10 @@ # Description: Overall function for managing checks. # Runs checks that will either halt on or fix an issue. -local modulename="Checking" +local commandnane="CHECK" +local commandaction="Checking" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Every command that requires checks just references check.sh # check.sh selects which checks to run by using arrays @@ -14,14 +17,14 @@ local modulename="Checking" check_root.sh check_permissions.sh -if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "command_update_functions.sh" ]; then +if [ "${selfname}" != "command_install.sh" ] && [ "${selfname}" != "command_update_functions.sh" ]; then check_system_dir.sh fi local allowed_commands_array=( command_debug.sh command_start.sh command_install.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_glibc.sh fi done @@ -29,7 +32,7 @@ done local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh command_update_functions.sh command_email_test.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_logs.sh fi done @@ -37,7 +40,7 @@ done local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_deps.sh fi done @@ -45,7 +48,7 @@ done local allowed_commands_array=( command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_ip.sh fi done @@ -53,7 +56,7 @@ done local allowed_commands_array=( update_check.sh command_debug.sh command_start.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then if [ -n "${appid}" ]; then check_steamcmd.sh fi @@ -63,7 +66,7 @@ done local allowed_commands_array=( command_console.sh command_start.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_tmux.sh fi done @@ -71,7 +74,7 @@ done local allowed_commands_array=( command_console.sh command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_config.sh fi done @@ -79,7 +82,7 @@ done local allowed_commands_array=( command_details.sh command_monitor.sh command_start.sh command_stop.sh command_ts3_server_pass.sh update_check.sh command_details.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${function_selfname}" ]; then + if [ "${allowed_command}" == "${selfname}" ]; then check_status.sh fi done diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index 2324210a5..7efa1c46c 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: If server config missing warn user. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 4fb5a0822..eae0df5b5 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -4,8 +4,10 @@ # Website: https://gameservermanagers.com # Description: Checks that the requires dependencies are installed for LGSM. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_deps_detector(){ # Checks if dependency is missing @@ -18,14 +20,14 @@ fn_deps_detector(){ fi if [ "${depstatus}" == "0" ]; then missingdep=0 - if [ "${function_selfname}" == "command_install.sh" ]; then + if [ "${selfname}" == "command_install.sh" ]; then echo -e "\e[0;32m${deptocheck}\e[0m" sleep 0.5 fi else # if missing dependency is found missingdep=1 - if [ "${function_selfname}" == "command_install.sh" ]; then + if [ "${selfname}" == "command_install.sh" ]; then echo -e "\e[0;31m${deptocheck}\e[0m" sleep 0.5 fi @@ -97,7 +99,7 @@ fn_found_missing_deps(){ fi echo "" fi - if [ "${function_selfname}" == "command_install.sh" ]; then + if [ "${selfname}" == "command_install.sh" ]; then sleep 5 fi fi @@ -116,7 +118,7 @@ fn_check_loop(){ info_distro.sh -if [ "${function_selfname}" == "command_install.sh" ]; then +if [ "${selfname}" == "command_install.sh" ]; then echo "" echo "Checking Dependecies" echo "=================================" diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index e1239d281..6d7f3a307 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -4,8 +4,10 @@ # Website: https://gameservermanagers.com # Description: Checks if server has correct glibc or has a fix available. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" info_glibc.sh info_distro.sh @@ -18,7 +20,7 @@ elif [ "${glibcrequired}" == "UNKNOWN" ]; then echo -e " * glibc installed: ${glibcversion}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then if [ "${glibcfix}" == "yes" ]; then - if [ "${function_selfname}" != "command_install.sh" ]; then + if [ "${selfname}" != "command_install.sh" ]; then fn_print_info_nl "Glibc fix: \e[0;32mUsing Glibc fix\e[0m" echo -e " * glibc required: \e[0;31m${glibcrequired}\e[0m" echo -e " * glibc installed: ${glibcversion}" diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index 438bb880c..12c94758f 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -5,8 +5,9 @@ # Description: Automatically identifies the server interface IP. # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0". -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" != "Teamspeak 3" ]; then if [ ! -f "/bin/ip" ]; then diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index 2e7a1b6bd..d4bea2b5a 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Checks that log files exist on server start -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Create dir's for the script and console logs if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 013846515..bb440615f 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -5,8 +5,9 @@ # Website: https://gameservermanagers.com # Description: Checks script, files and folders ownership and permissions. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Useful variables currentuser="$(whoami)" diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index 37d3a6710..eb64ddb1f 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" diff --git a/lgsm/functions/check_status.sh b/lgsm/functions/check_status.sh index 355ce9dd6..41072261d 100644 --- a/lgsm/functions/check_status.sh +++ b/lgsm/functions/check_status.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Checks the proccess status of the server. Either online or offline. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Teamspeak 3" ]; then # 1: Server is running diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 57f1f5343..01049a5aa 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -4,8 +4,10 @@ # Website: https://gameservermanagers.com # Description: Checks SteamCMD is installed and correct. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_steamcmd(){ if [ ! -d "${steamcmddir}" ]; then @@ -44,7 +46,7 @@ fn_check_steamcmd_sh(){ # Installs if missing. steamcmddir="${rootdir}/steamcmd" if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then - if [ "${function_selfname}" == "command_install.sh" ]; then + if [ "${selfname}" == "command_install.sh" ]; then fn_install_steamcmd else fn_print_warn_nl "SteamCMD is missing" @@ -52,14 +54,14 @@ fn_check_steamcmd_sh(){ sleep 1 fn_install_steamcmd fi - elif [ "${function_selfname}" == "command_install.sh" ]; then + elif [ "${selfname}" == "command_install.sh" ]; then fn_print_infomation "SteamCMD is already installed..." fn_print_ok_eol_nl fi } fn_check_steamcmd_guard(){ - if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then + if [ "${selfname}" == "command_update.sh" ]||[ "${selfname}" == "command_validate.sh" ]; then # Checks that steamcmd is working correctly and will prompt Steam Guard if required. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit if [ $? -ne 0 ]; then diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index b4eb92559..be737d05a 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -d "${systemdir}" ]; then fn_print_fail_nl "Cannot access ${systemdir}: No such directory" diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index 63ddf80c4..5b2fa51d9 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google. -local modulename="Checking" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CHECK" +local commandaction="Checking" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then : diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index a71ee8339..cc651c920 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Creates a .tar.gz file in the backup directory. -local modulename="Backup" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="BACKUP" +local commandaction="Backup" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_distro.sh diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index b7d9a10d6..301bb4c07 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Gives access to the server tmux console. -local modulename="Console" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="CONSOLE" +local commandaction="Console" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh echo "" diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index d81166245..4bd35c56c 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Runs the server without tmux. Runs direct from the terminal. -local modulename="Debug" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="DEBUG" +local commandaction="Debug" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Trap to remove lockfile on quit. fn_lockfile_trap(){ diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 4cdad4d4a..3a740b68a 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Displays server infomation. -local modulename="Details" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="DETAILS" +local commandaction="Details" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Standard Details # This applies to all engines diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index abfd9795f..81548309c 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Dev only: enables debuging log to be saved to dev-debug.log. -local modulename="Dev Debug" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="DEV-DEBUG" +local commandaction="Dev-Debug" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index 2dca148ef..ab8e4a43d 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Detects dependencies the server binary requires. -local modulename="Deps Detect" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="DEPS-DETECT" +local commandaction="Deps-Detect" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh cd "${executabledir}" diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index de00c8902..5c5eed3dc 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -5,8 +5,9 @@ # Website: https://gameservermanagers.com # Description: Creates a FastDL folder -local modulename="FastDL" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="FASTDL" +local commandaction="FastDL" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 87ddac2c3..b57a22a42 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Overall function for the installer. -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 354ba8a64..5860c08b6 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -5,8 +5,9 @@ # Description: Monitors server by checking for running proccesses # then passes to monitor_gsquery.sh. -local modulename="Monitor" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="MONITOR" +local commandaction="Monitor" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 528737f7d..67a35c449 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Starts the server. -local modulename="Restarting" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="RESTART" +local commandaction="Restarting" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" exitbypass=1 info_config.sh diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index c7882ae44..991aa435c 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Starts the server. -local modulename="Starting" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="START" +local commandaction="Starting" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ if [ ! -e "${servercfgfullpath}" ]; then diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 8ff3c2859..5cb3cb5f1 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Stops the server. -local modulename="Stopping" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="STOP" +local commandaction="Stopping" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index 2fe73ee31..98e4d1cf6 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Sends a test email alert. -local modulename="Alert" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="ALERT" +local commandaction="Alert" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_config.sh diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 6386b8f08..0419bf181 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -5,8 +5,9 @@ # Website: https://gameservermanagers.com # Description: Changes TS3 serveradmin password -local modulename="TS3 Change Password" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="TS3-CHANGE-PASS" +local commandaction="TS3 Change Password" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_serveradmin_password_prompt(){ diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 6bc1c75c4..b9ecb82dc 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Handles updating of servers. -local modulename="Update" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="UPDATE" +local commandaction="Update" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index c6136446e..329bab64d 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. -local modulename="Update LGSM" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandaction="Update LGSM" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" fn_script_log_info "Updating functions" diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index ca9bbcfee..09bfb6e8a 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Runs a server validation. -local modulename="Validate" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="VALIDATE" +local commandaction="Validate" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ fn_print_warn_nl "Validating may overwrite some customised files." diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 3fa752867..415e82c24 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: compresses unreal maps -local modulename="Unreal Map Compressor" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandaction="Unreal Map Compressor" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index f5414125d..a6ce63495 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: compresses unreal maps -local modulename="Unreal Map Compressor" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandaction="Unreal Map Compressor" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 71321fad2..569bb5f9d 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -16,7 +16,8 @@ # fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" -local modulename="Download" +local commandnane="DOWNLOAD" +local commandaction="Download" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dl_md5(){ diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 3211b095f..7e0a704aa 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -7,19 +7,19 @@ fn_exit_dev_debug(){ if [ -f "${rootdir}/.dev-debug" ]; then echo "" - echo "${function_selfname} exiting with code: ${exitcode}" + echo "${selfname} exiting with code: ${exitcode}" fi } if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then - fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}" + fn_script_log_fatal "${selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then - fn_script_log_error "${function_selfname} exiting with code: ${exitcode}" + fn_script_log_error "${selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "3" ]; then - fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" + fn_script_log_warn "${selfname} exiting with code: ${exitcode}" else - fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" + fn_script_log_warn "${selfname} exiting with code: ${exitcode}" fi fn_exit_dev_debug # remove trap. @@ -29,7 +29,7 @@ elif [ -n "${exitbypass}" ]; then unset exitbypass else exitcode=0 - fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" + fn_script_log_pass "${selfname} exiting with code: ${exitcode}" fn_exit_dev_debug # remove trap. trap - INT diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index c70087065..7ab5ba4c7 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -5,7 +5,8 @@ # Description: Overall function for managing fixes. # Runs functions that will fix an issue. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" # Cannot have selfname as breaks if statements. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/fix_arma3.sh b/lgsm/functions/fix_arma3.sh index 5c66d2fd0..adf3fcfc6 100644 --- a/lgsm/functions/fix_arma3.sh +++ b/lgsm/functions/fix_arma3.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves an issue with ARMA3. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: 20150 Segmentation fault (core dumped) error. diff --git a/lgsm/functions/fix_csgo.sh b/lgsm/functions/fix_csgo.sh index a2a75bed6..acca65918 100644 --- a/lgsm/functions/fix_csgo.sh +++ b/lgsm/functions/fix_csgo.sh @@ -4,6 +4,10 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with csgo. +local commandnane="FIX" +local commandaction="Fix" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" + # Fixes: server not always creating steam_appid.txt file. if [ ! -f "${filesdir}/steam_appid.txt" ]; then fixname="730 steam_appid.txt" diff --git a/lgsm/functions/fix_dst.sh b/lgsm/functions/fix_dst.sh index 31f77e416..99d4a65f0 100644 --- a/lgsm/functions/fix_dst.sh +++ b/lgsm/functions/fix_dst.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Dont Starve together. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) diff --git a/lgsm/functions/fix_glibc.sh b/lgsm/functions/fix_glibc.sh index d1e0ab89f..34811136f 100644 --- a/lgsm/functions/fix_glibc.sh +++ b/lgsm/functions/fix_glibc.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Downloads required glibc files and applys teh glibc fix if required -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" ) diff --git a/lgsm/functions/fix_ins.sh b/lgsm/functions/fix_ins.sh index 5b6061fef..210662964 100644 --- a/lgsm/functions/fix_ins.sh +++ b/lgsm/functions/fix_ins.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Insurgency. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" # Cannot have selfname as breaks if statement. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/fix_kf.sh b/lgsm/functions/fix_kf.sh index 048fa839d..3730c0ef8 100644 --- a/lgsm/functions/fix_kf.sh +++ b/lgsm/functions/fix_kf.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Killing Floor. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." diff --git a/lgsm/functions/fix_ro.sh b/lgsm/functions/fix_ro.sh index 8e3f6ccbd..c17f7e06e 100644 --- a/lgsm/functions/fix_ro.sh +++ b/lgsm/functions/fix_ro.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Red Orchestra. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." diff --git a/lgsm/functions/fix_steamcmd.sh b/lgsm/functions/fix_steamcmd.sh index 00d871d10..62f048a73 100644 --- a/lgsm/functions/fix_steamcmd.sh +++ b/lgsm/functions/fix_steamcmd.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues related to steamCMD. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. diff --git a/lgsm/functions/fix_ut2k4.sh b/lgsm/functions/fix_ut2k4.sh index 3f82407ba..1cec482e0 100644 --- a/lgsm/functions/fix_ut2k4.sh +++ b/lgsm/functions/fix_ut2k4.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Unreal Tournament 2004. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "applying WebAdmin ut2003.css fix." diff --git a/lgsm/functions/fix_ut99.sh b/lgsm/functions/fix_ut99.sh index b956e6536..2bca9c8ba 100644 --- a/lgsm/functions/fix_ut99.sh +++ b/lgsm/functions/fix_ut99.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Unreal Tournament 99. -local modulename="Fix" +local commandnane="FIX" +local commandaction="Fix" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "${servercfgfullpath}" diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index 92c9e5082..ae492f826 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -3,7 +3,8 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" +local commandnane="INSTALL" +local commandaction="Install" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Don't Starve Together" ]; then diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index f5b207e8f..908e5bf7d 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_defaultconfig(){ echo "creating ${servercfg} config file." diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index 823deee11..5637f6990 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Configures GSLT. -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Game Server Login Token" diff --git a/lgsm/functions/install_gsquery.sh b/lgsm/functions/install_gsquery.sh index 710a6080a..19344c6d3 100644 --- a/lgsm/functions/install_gsquery.sh +++ b/lgsm/functions/install_gsquery.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dlgsquery(){ cd "${functionsdir}" diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index b5a817e95..55a9e6481 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" clear echo "=================================" diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index 14ecf4c31..e486f1619 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${checklogs}" != "1" ]; then echo "" diff --git a/lgsm/functions/install_retry.sh b/lgsm/functions/install_retry.sh index c56898898..3f1bdf26c 100644 --- a/lgsm/functions/install_retry.sh +++ b/lgsm/functions/install_retry.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" while true; do read -e -i "y" -p "Retry install? [Y/n]" yn diff --git a/lgsm/functions/install_server_dir.sh b/lgsm/functions/install_server_dir.sh index c2c6b36eb..a6b37d7e2 100644 --- a/lgsm/functions/install_server_dir.sh +++ b/lgsm/functions/install_server_dir.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Server Directory" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index f37390277..5ccac8390 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index a5951c046..5956d1beb 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Downloads SteamCMD on install. -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Installing SteamCMD" diff --git a/lgsm/functions/install_ts3.sh b/lgsm/functions/install_ts3.sh index 3a6eab039..3f136f802 100644 --- a/lgsm/functions/install_ts3.sh +++ b/lgsm/functions/install_ts3.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" info_distro.sh # Gets the teamspeak server architecture diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index cc7f0da9d..9ce622504 100644 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -4,8 +4,9 @@ # Contributor: PhilPhonic # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_ts3db_mariadb(){ echo "" diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index 2fe62b3c6..a41c2b688 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -3,8 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local modulename="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="INSTALL" +local commandaction="Install" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Enter ${gamename} CD Key" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index cfbd28beb..23306525e 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -5,8 +5,10 @@ # Website: https://gameservermanagers.com # Description: Acts as a log rotater, removing old logs. -local modulename="Log Manager" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="LOGS" +local commandaction="Log-Manager" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Check if logfile variable and file exist, create logfile if it doesn't exist if [ -n "${consolelog}" ]; then @@ -16,7 +18,7 @@ if [ -n "${consolelog}" ]; then fi # For games not displaying a console, and having logs into their game folder -if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then +if [ "${selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then fn_print_info "Moving game logs to ${gamelogdir}" fn_script_log_info "Moving game logs to ${gamelogdir}" diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 80070bf35..d770397a3 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -5,8 +5,9 @@ # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. -local modulename="Monitor" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="MONITOR" +local commandaction="Monitor" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Forces legecy servers to use gsquery if [ -z "${gsquery}" ]; then diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 6a6efb77e..584a3901f 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Checks if a server update is available. -local modulename="Update" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="UPDATE" +local commandaction="Update" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### SteamCMD Update Checker ### diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh index 29b67a8ff..c8e5ac967 100644 --- a/lgsm/functions/update_dl.sh +++ b/lgsm/functions/update_dl.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description: Runs a server update. -local modulename="Update" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="UPDATE" +local commandaction="Update" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_steamcmd_dl(){ cd "${rootdir}" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 6dfd0ddc1..61981e7c9 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -4,8 +4,9 @@ # Website: https://gameservermanagers.com # Description:Handles updating using steamCMD. -local modulename="Update" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandnane="UPDATE" +local commandaction="Update" +local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_steamcmd_dl(){ diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 752269217..ac2d4805c 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -4,7 +4,8 @@ # Website: https://gameservermanagers.com # Description:Handles updating of teamspeak 3 servers. -local modulename="Update" +local commandnane="UPDATE" +local commandaction="Update" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_ts3_dl(){ From ea17d3bd96ab5284786fa7001974963b3b762c21 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 20:04:24 +0100 Subject: [PATCH 110/195] Made messages consistent with new exitcode format --- lgsm/functions/core_messages.sh | 195 +++++++++++++++++++++----------- 1 file changed, 127 insertions(+), 68 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 34ca1f8ee..e6552e422 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -7,112 +7,139 @@ # nl: new line: message is following by a new line # eol: end of line: message is placed at the end of the current line -# Date, servicename & module details displayed in log files. -# e.g Feb 28 14:56:58 ut99-server: Monitor: + +# Log display +########## +## Feb 28 14:56:58 ut99-server: Monitor: fn_script_log(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}" fi } +## Feb 28 14:56:58 ut99-server: Monitor: PASS: fn_script_log_pass(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: PASS: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: PASS: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: PASS: ${1}" >> "${scriptlog}" fi exitcode=0 } +## Feb 28 14:56:58 ut99-server: Monitor: FATAL: fn_script_log_fatal(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: FATAL: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: FATAL: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: FATAL: ${1}" >> "${scriptlog}" fi exitcode=1 } +## Feb 28 14:56:58 ut99-server: Monitor: ERROR: fn_script_log_error(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: ERROR: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: ERROR: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ERROR: ${1}" >> "${scriptlog}" fi exitcode=2 } +## Feb 28 14:56:58 ut99-server: Monitor: WARN: fn_script_log_warn(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: WARN: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: WARN: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: WARN: ${1}" >> "${scriptlog}" fi exitcode=3 } +## Feb 28 14:56:58 ut99-server: Monitor: INFO: fn_script_log_info(){ - if [ -n "${modulename}" ]; then - echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${modulename}: INFO: ${1}" >> "${scriptlog}" + if [ -n "${commandaction}" ]; then + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${commandaction}: INFO: ${1}" >> "${scriptlog}" else echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: INFO: ${1}" >> "${scriptlog}" fi } -# [ FAIL ] -fn_print_fail(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" +# On-Screen +########## + +# [ .... ] +fn_print_dots(){ + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[ .... ] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" + echo -en "\r\033[K[ .... ] $@" fi } -fn_print_fail_nl(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${modulename} ${servicename}: $@" +fn_print_dots_nl(){ + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[ .... ] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" + echo -e "\r\033[K[ .... ] $@" fi - sleep 1 - echo -en "\n" } # [ OK ] fn_print_ok(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" else echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" fi } fn_print_ok_nl(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;32m OK \e[0m] ${modulename} ${servicename}: $@" + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" + echo -e "\r\033[K[\e[0;32m OK \e[0m] $@" fi sleep 1 echo -en "\n" } -# [ INFO ] -fn_print_info(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" +# [ FAIL ] +fn_print_fail(){ + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" fi } -fn_print_info_nl(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${modulename} ${servicename}: $@" +fn_print_fail_nl(){ + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" + fi + sleep 1 + echo -en "\n" +} + +# [ ERROR ] +fn_print_error(){ + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" + else + echo -en "\r\033[K[\e[0;31m ERROR \e[0m] $@" + fi +} + +fn_print_error_nl(){ + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" + else + echo -e "\r\033[K[\e[0;31m ERROR \e[0m] $@" fi sleep 1 echo -en "\n" @@ -120,32 +147,45 @@ fn_print_info_nl(){ # [ WARN ] fn_print_warn(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" else echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" fi } fn_print_warn_nl(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${modulename} ${servicename}: $@" + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" + echo -e "\r\033[K[\e[1;33m WARN \e[0m] $@" fi sleep 1 echo -en "\n" } -# [ .... ] -fn_print_dots(){ - if [ -n "${modulename}" ]; then - echo -en "\r\033[K[ .... ] ${modulename} ${servicename}: $@" +# [ INFO ] +fn_print_info(){ + if [ -n "${commandaction}" ]; then + echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[ .... ] $@" + echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" fi } +fn_print_info_nl(){ + if [ -n "${commandaction}" ]; then + echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" + else + echo -e "\r\033[K[\e[0;36m INFO \e[0m] $@" + fi + sleep 1 + echo -en "\n" +} + +# On-Screen full word +########## + # Complete! fn_print_complete(){ echo -en "\e[0;32mComplete!\e[0m $@" @@ -155,15 +195,6 @@ fn_print_complete_nl(){ echo -e "\e[0;32mComplete!\e[0m $@" } -# Warning! -fn_print_warning(){ - echo -en "\e[0;33mWarning!\e[0m $@" -} - -fn_print_warning_nl(){ - echo -e "\e[0;33mWarning!\e[0m $@" -} - # Failure! fn_print_failure(){ echo -en "\e[0;31mFailure!\e[0m $@" @@ -182,6 +213,15 @@ fn_print_error_nl(){ echo -e "\e[0;31mError!\e[0m $@" } +# Warning! +fn_print_warning(){ + echo -en "\e[0;33mWarning!\e[0m $@" +} + +fn_print_warning_nl(){ + echo -e "\e[0;33mWarning!\e[0m $@" +} + # Infomation! fn_print_infomation(){ echo -en "\e[0;36mInfomation!\e[0m $@" @@ -191,7 +231,10 @@ fn_print_infomation_nl(){ echo -e "\e[0;36mInfomation!\e[0m $@" } -# FAIL for end of line +# On-Screen End of Line +########## + +# OK fn_print_ok_eol(){ echo -en "\e[0;32mOK\e[0m" } @@ -200,7 +243,7 @@ fn_print_ok_eol_nl(){ echo -e "\e[0;32mOK\e[0m" } -# FAIL for end of line +# FAIL fn_print_fail_eol(){ echo -en "\e[0;31mFAIL\e[0m" } @@ -209,7 +252,25 @@ fn_print_fail_eol_nl(){ echo -e "\e[0;31mFAIL\e[0m" } -# QUERYING for end of line +# WARN +fn_print_warn_eol(){ + echo -en "\e[0;31mFAIL\e[0m" +} + +fn_print_warn_eol_nl(){ + echo -e "\e[0;31mFAIL\e[0m" +} + +# INFO +fn_print_info_eol(){ + echo -en "\e[0;31mFAIL\e[0m" +} + +fn_print_info_eol_nl(){ + echo -e "\e[0;31mFAIL\e[0m" +} + +# QUERYING fn_print_querying_eol(){ echo -en "\e[0;36mQUERYING\e[0m" } @@ -218,7 +279,7 @@ fn_print_querying_eol_nl(){ echo -e "\e[0;36mQUERYING\e[0m" } -# CHECKING for end of line +# CHECKING fn_print_checking_eol(){ echo -en "\e[0;36mCHECKING\e[0m" } @@ -227,7 +288,7 @@ fn_print_checking_eol_nl(){ echo -e "\e[0;36mCHECKING\e[0m" } -# CANCELED for end of line +# CANCELED fn_print_canceled_eol(){ echo -en "\e[0;33mCANCELED\e[0m" } @@ -236,7 +297,7 @@ fn_print_canceled_eol_nl(){ echo -e "\e[0;33mCANCELED\e[0m" } -# REMOVED for end of line +# REMOVED fn_print_removed_eol(){ echo -en "\e[0;31mREMOVED\e[0m" } @@ -245,13 +306,11 @@ fn_print_removed_eol_nl(){ echo -e "\e[0;31mREMOVED\e[0m" } -# UPDATE for end of line - +# UPDATE fn_print_update_eol(){ echo -en "\e[0;36mUPDATE\e[0m" } fn_print_update_eol_nl(){ echo -e "\e[0;36mUPDATE\e[0m" -} - +} \ No newline at end of file From dc63005b83487092abc546fdec2a173d44500492 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 20:51:32 +0100 Subject: [PATCH 111/195] removed nl --- lgsm/functions/alert.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 6c84a883d..e0b6b4a0e 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -46,19 +46,19 @@ fi if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then alert_email.sh elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_info_nl "Email alerts not enabled" - fn_script_log_info "Email alerts not enabled" + fn_print_warn "Email alerts not enabled" + fn_script_log_warn "Email alerts not enabled" elif [ -z "${email}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_fail_nl "Email not set" - fn_script_log "Email not set" + fn_print_error "Email not set" + fn_script_log_error "Email not set" fi if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh elif [ "${pushbulletalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_info_nl "Pushbullet alerts not enabled" - fn_script_log_info "Pushbullet alerts not enabled" + fn_print_warn "Pushbullet alerts not enabled" + fn_script_log_warn "Pushbullet alerts not enabled" elif [ -z "${pushbullettoken}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_fail_nl "Pushbullet token not set" - fn_script_log_warn "Pushbullet token not set" + fn_print_error "Pushbullet token not set" + fn_script_error_warn "Pushbullet token not set" fi \ No newline at end of file From 6928a324767e1ff71f593f9402942082f9eebe5f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 20:54:57 +0100 Subject: [PATCH 112/195] removed nl --- lgsm/functions/alert_email.sh | 11 ++++++----- lgsm/functions/alert_pushbullet.sh | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 7f7bf63f6..6e4fa15c3 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -213,7 +213,8 @@ fn_alert_email_template_logs(){ } | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee -a "${emaillog}" > /dev/null 2>&1 } -fn_print_dots "Sending alert to ${email}" +fn_print_dots "Sending alert: ${email}" +fn_script_log_info "Sending alert: ${email}" info_distro.sh info_config.sh info_glibc.sh @@ -232,9 +233,9 @@ fn_alert_email_template_logs mail -s "${alertsubject}" "${email}" < "${emaillog}" exitcode=$? if [ "${exitcode}" == "0" ]; then - fn_print_ok_nl "Sending alert to ${email}" - fn_script_log_pass "Sending alert to ${email}" + fn_print_ok "Sending alert: ${email}" + fn_script_log_pass "Sending alert: ${email}" else - fn_print_fail_nl "Sending alert to ${email}" - fn_script_log_fatal "Sending alert to ${email}" + fn_print_fail "Sending alert: ${email}" + fn_script_log_fatal "Sending alert: ${email}" fi \ No newline at end of file diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 2b2bca093..aae7cef80 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -14,9 +14,9 @@ sleep 1 pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes'|grep -o invalid_access_token|uniq) if [ "${pushbulletsend}" == "invalid_access_token" ]; then - fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token" + fn_print_fail "Sending Pushbullet alert: invalid_access_token" fn_script_log_fatal "Sending Pushbullet alert: invalid_access_token" else - fn_print_ok_nl "Sending Pushbullet alert" + fn_print_ok "Sending Pushbullet alert" fn_script_log_pass "Sent Pushbullet alert" fi \ No newline at end of file From e3590ead0fc830444c300ad653d693413abac847 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 20:58:25 +0100 Subject: [PATCH 113/195] commended out selfname --- lgsm/functions/check_permissions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index bb440615f..2afa434ce 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -7,7 +7,8 @@ local commandnane="CHECK" local commandaction="Checking" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +# Cannot have selfname as breaks the function. +#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Useful variables currentuser="$(whoami)" From 7b2e09c205af8483441e6071330d509d1ab6ccc3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 21:00:30 +0100 Subject: [PATCH 114/195] commented out for now --- lgsm/functions/check_permissions.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 2afa434ce..a88a742e9 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -18,12 +18,12 @@ conclusionpermissionerror="0" fn_check_ownership(){ # Check script ownership - if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then - fn_print_fail_nl "Oops ! Ownership issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" - echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" - exit 1 - fi + #if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then + # fn_print_fail_nl "Oops ! Ownership issue..." + # echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" + # echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" + # exit 1 + #fi # Check rootdir ownership if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then From edee6c46534d3cccd77a1d3467c97f616ec8c953 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 21:08:31 +0100 Subject: [PATCH 115/195] corrected nl bugs --- lgsm/functions/core_messages.sh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index e6552e422..532adfef6 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -86,6 +86,8 @@ fn_print_dots_nl(){ else echo -e "\r\033[K[ .... ] $@" fi + sleep 0.5 + echo -en "\n" } # [ OK ] @@ -99,11 +101,11 @@ fn_print_ok(){ fn_print_ok_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;32m OK \e[0m] $@" + echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" fi - sleep 1 + sleep 0.5 echo -en "\n" } @@ -118,11 +120,11 @@ fn_print_fail(){ fn_print_fail_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" else echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" fi - sleep 1 + sleep 0.5 echo -en "\n" } @@ -137,11 +139,11 @@ fn_print_error(){ fn_print_error_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;31m ERROR \e[0m] $@" + echo -en "\r\033[K[\e[0;31m ERROR \e[0m] $@" fi - sleep 1 + sleep 0.5 echo -en "\n" } @@ -156,11 +158,11 @@ fn_print_warn(){ fn_print_warn_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" else - echo -e "\r\033[K[\e[1;33m WARN \e[0m] $@" + echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" fi - sleep 1 + sleep 0.5 echo -en "\n" } @@ -175,11 +177,11 @@ fn_print_info(){ fn_print_info_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" else - echo -e "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" fi - sleep 1 + sleep 0.5 echo -en "\n" } From 82686dc6160e9a8622f037aaf5b514f12f268d60 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 21:09:22 +0100 Subject: [PATCH 116/195] nl --- lgsm/functions/alert.sh | 8 ++++---- lgsm/functions/alert_email.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index e0b6b4a0e..4242d6e8c 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -46,19 +46,19 @@ fi if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then alert_email.sh elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_warn "Email alerts not enabled" + fn_print_warn_nl "Email alerts not enabled" fn_script_log_warn "Email alerts not enabled" elif [ -z "${email}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Email not set" + fn_print_error_nl "Email not set" fn_script_log_error "Email not set" fi if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh elif [ "${pushbulletalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_warn "Pushbullet alerts not enabled" + fn_print_warn_nl "Pushbullet alerts not enabled" fn_script_log_warn "Pushbullet alerts not enabled" elif [ -z "${pushbullettoken}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then - fn_print_error "Pushbullet token not set" + fn_print_error_nl "Pushbullet token not set" fn_script_error_warn "Pushbullet token not set" fi \ No newline at end of file diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 6e4fa15c3..273861670 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -233,9 +233,9 @@ fn_alert_email_template_logs mail -s "${alertsubject}" "${email}" < "${emaillog}" exitcode=$? if [ "${exitcode}" == "0" ]; then - fn_print_ok "Sending alert: ${email}" + fn_print_ok_nl "Sending alert: ${email}" fn_script_log_pass "Sending alert: ${email}" else - fn_print_fail "Sending alert: ${email}" + fn_print_fail_nl "Sending alert: ${email}" fn_script_log_fatal "Sending alert: ${email}" fi \ No newline at end of file From 54eae918bf6ca12f346bf360d0e2ce2a35459d15 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 21:17:30 +0100 Subject: [PATCH 117/195] fn_restart command_restart.sh --- lgsm/functions/command_monitor.sh | 2 +- lgsm/functions/monitor_gsquery.sh | 2 +- tests/tests_jc2server.sh | 4 ++-- tests/tests_ts3server.sh | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 5860c08b6..d2a93a499 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -50,7 +50,7 @@ fn_monitor_teamspeak3(){ alert.sh fn_script_log_info "Monitor is starting ${servername}" sleep 1 - fn_restart + command_restart.sh fi } diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index d770397a3..1a4002c13 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -73,7 +73,7 @@ if [ "${gsquery}" == "yes" ]; then # Send alert if enabled alert="restartquery" alert.sh - fn_restart + command_restart.sh break fi diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index f2c84cd6c..3e62e78d1 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -289,7 +289,7 @@ echo "Description:" echo "restart ${gamename}." requiredstatus="ONLINE" fn_setstatus -fn_restart +command_restart.sh echo "" echo "Test complete!" sleep 1 @@ -300,7 +300,7 @@ echo "Description:" echo "restart ${gamename} while already stopped." requiredstatus="OFFLINE" fn_setstatus -fn_restart +command_restart.sh echo "" echo "Test complete!" sleep 1 diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index 7ea98bac7..f4a1d2769 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -273,7 +273,7 @@ echo "Description:" echo "restart ${gamename}." requiredstatus="ONLINE" fn_setstatus -fn_restart +command_restart.sh echo "" echo "Test complete!" sleep 1 @@ -284,7 +284,7 @@ echo "Description:" echo "restart ${gamename} while already stopped." requiredstatus="OFFLINE" fn_setstatus -fn_restart +command_restart.sh echo "" echo "Test complete!" sleep 1 From 4ca81c284d6db48aa55db88b9c20f6ee668cc5fd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 21:24:12 +0100 Subject: [PATCH 118/195] nl --- lgsm/functions/alert_pushbullet.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index aae7cef80..2b2bca093 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -14,9 +14,9 @@ sleep 1 pushbulletsend=$(curl --silent -u """${pushbullettoken}"":" -d type="note" -d body="${alertbody}" -d title="${alertsubject}" 'https://api.pushbullet.com/v2/pushes'|grep -o invalid_access_token|uniq) if [ "${pushbulletsend}" == "invalid_access_token" ]; then - fn_print_fail "Sending Pushbullet alert: invalid_access_token" + fn_print_fail_nl "Sending Pushbullet alert: invalid_access_token" fn_script_log_fatal "Sending Pushbullet alert: invalid_access_token" else - fn_print_ok "Sending Pushbullet alert" + fn_print_ok_nl "Sending Pushbullet alert" fn_script_log_pass "Sent Pushbullet alert" fi \ No newline at end of file From 60110fdc8c1eadfcfc4b013ab3edbb82ea339f19 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 23:38:23 +0100 Subject: [PATCH 119/195] colours are now variables --- functions/core_functions.sh | 6 +- lgsm/functions/check_config.sh | 2 +- lgsm/functions/check_deps.sh | 8 +- lgsm/functions/check_glibc.sh | 12 +- lgsm/functions/command_details.sh | 160 +++++++++++----------- lgsm/functions/core_functions.sh | 6 +- lgsm/functions/core_getopt.sh | 218 +++++++++++++++--------------- lgsm/functions/core_messages.sh | 115 +++++++++------- lgsm/functions/info_config.sh | 4 +- lgsm/functions/info_distro.sh | 2 +- lgsm/functions/info_parms.sh | 4 +- lgsm/functions/monitor_gsquery.sh | 2 +- lgsm/functions/update_check.sh | 16 +-- lgsm/functions/update_steamcmd.sh | 8 +- lgsm/functions/update_ts3.sh | 8 +- 15 files changed, 291 insertions(+), 280 deletions(-) diff --git a/functions/core_functions.sh b/functions/core_functions.sh index 536b461de..3e6d2fb1c 100644 --- a/functions/core_functions.sh +++ b/functions/core_functions.sh @@ -46,15 +46,15 @@ if [ ! -f "${filedir}/${filename}" ]; then if [ "$(basename ${curlcmd})" == "curl" ]; then curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "${red}FAIL${default}\n" echo "${curlfetch}" echo -e "${githuburl}\n" exit 1 else - echo -e "\e[0;32mOK\e[0m" + echo -e "${green}OK${default}" fi else - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "${red}FAIL${default}\n" echo "Curl is not installed!" echo -e "" exit 1 diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index 7efa1c46c..1775e1f49 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -10,7 +10,7 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then - fn_print_warn_nl "Config file missing!" + fn_print_warn_nl "Configuration file missing!" echo "${servercfgfullpath}" fn_script_log_warn "Configuration file missing!" fn_script_log_warn "${servercfgfullpath}" diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index eae0df5b5..cfdac39f5 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -21,14 +21,14 @@ fn_deps_detector(){ if [ "${depstatus}" == "0" ]; then missingdep=0 if [ "${selfname}" == "command_install.sh" ]; then - echo -e "\e[0;32m${deptocheck}\e[0m" + echo -e "${green}${deptocheck}${default}" sleep 0.5 fi else # if missing dependency is found missingdep=1 if [ "${selfname}" == "command_install.sh" ]; then - echo -e "\e[0;31m${deptocheck}\e[0m" + echo -e "${red}${deptocheck}${default}" sleep 0.5 fi fi @@ -66,8 +66,8 @@ fn_found_missing_deps(){ if [ "${#array_deps_missing[@]}" != "0" ]; then fn_print_dots "Checking dependencies" sleep 2 - fn_print_warn "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" - fn_script_log_info "Checking dependencies: missing: \e[0;31m${array_deps_missing[@]}\e[0m" + fn_print_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" + fn_script_log_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" sleep 1 echo -e "" sudo -n true > /dev/null 2>&1 diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 6d7f3a307..41d4d6ebf 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -15,22 +15,22 @@ info_distro.sh if [ "${glibcrequired}" == "NOT REQUIRED" ]; then : elif [ "${glibcrequired}" == "UNKNOWN" ]; then - fn_print_info_nl "Glibc fix: \e[0;31m${glibcrequired}\e[0m" - echo -e " * glibc required: \e[0;31m${glibcrequired}\e[0m" + fn_print_info_nl "Glibc fix: ${red}${glibcrequired}${default}" + echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc installed: ${glibcversion}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then if [ "${glibcfix}" == "yes" ]; then if [ "${selfname}" != "command_install.sh" ]; then - fn_print_info_nl "Glibc fix: \e[0;32mUsing Glibc fix\e[0m" - echo -e " * glibc required: \e[0;31m${glibcrequired}\e[0m" + fn_print_info_nl "Glibc fix: ${green}Using Glibc fix${default}" + echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc installed: ${glibcversion}" fix_glibc.sh fi else - fn_print_warn_nl "Glibc fix: \e[0;31mNo Glibc fix available!\e[0m" + fn_print_warn_nl "Glibc fix: ${red}No Glibc fix available!${default}" echo -en "\n" echo -e " * glibc required: ${glibcrequired}" - echo -e " * glibc installed: \e[0;31m${glibcversion}\e[0m" + echo -e " * glibc installed: ${red}${glibcversion}${default}" echo -en "\n" fn_print_infomation "The game server will probably not work. A distro upgrade is required!" sleep 5 diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 3a740b68a..89d29d5ec 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -23,15 +23,15 @@ fn_details_os(){ # GLIBC: 2.19 echo -e "" - echo -e "\e[93mDistro Details\e[0m" + echo -e "${lightyellow}Distro Details${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mDistro:\t\e[0m${os}" - echo -e "\e[34mArch:\t\e[0m${arch}" - echo -e "\e[34mKernel:\t\e[0m${kernel}" - echo -e "\e[34mHostname:\t\e[0m$HOSTNAME" - echo -e "\e[34mtmux:\t\e[0m${tmuxv}" - echo -e "\e[34mGLIBC:\t\e[0m${glibcversion}" + echo -e "${blue}Distro:\t${default}${os}" + echo -e "${blue}Arch:\t${default}${arch}" + echo -e "${blue}Kernel:\t${default}${kernel}" + echo -e "${blue}Hostname:\t${default}$HOSTNAME" + echo -e "${blue}tmux:\t${default}${tmuxv}" + echo -e "${blue}GLIBC:\t${default}${glibcversion}" } | column -s $'\t' -t } @@ -47,17 +47,17 @@ fn_details_performance(){ # Swap: 0B 0B 0B echo -e "" - echo -e "\e[93mPerformance\e[0m" + echo -e "${lightyellow}Performance${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mUptime:\t\e[0m${days}d, ${hours}h, ${minutes}m" - echo -e "\e[34mAvg Load:\t\e[0m${load}" + echo -e "${blue}Uptime:\t${default}${days}d, ${hours}h, ${minutes}m" + echo -e "${blue}Avg Load:\t${default}${load}" } | column -s $'\t' -t echo -e "" { - echo -e "\e[34mMem:\t\e[34mtotal\t used\t free\e[0m" - echo -e "\e[34mPhysical:\t\e[0m${physmemtotal}\t${physmemused}\t${physmemfree}\e[0m" - echo -e "\e[34mSwap:\t\e[0m${swaptotal}\t${swapused}\t${swapfree}\e[0m" + echo -e "${blue}Mem:\t${blue}total\t used\t free${default}" + echo -e "${blue}Physical:\t${default}${physmemtotal}\t${physmemused}\t${physmemfree}${default}" + echo -e "${blue}Swap:\t${default}${swaptotal}\t${swapused}\t${swapfree}${default}" } | column -s $'\t' -t } @@ -74,17 +74,17 @@ fn_details_disk(){ # Backups: 2G echo -e "" - echo -e "\e[93mStorage\e[0m" + echo -e "${lightyellow}Storage${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mFilesystem:\t\e[0m${filesystem}" - echo -e "\e[34mTotal:\t\e[0m${totalspace}" - echo -e "\e[34mUsed:\t\e[0m${usedspace}" - echo -e "\e[34mAvailable:\t\e[0m${availspace}" - echo -e "\e[34mLGSM Total:\t\e[0m${rootdirdu}" - echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}" + echo -e "${blue}Filesystem:\t${default}${filesystem}" + echo -e "${blue}Total:\t${default}${totalspace}" + echo -e "${blue}Used:\t${default}${usedspace}" + echo -e "${blue}Available:\t${default}${availspace}" + echo -e "${blue}LGSM Total:\t${default}${rootdirdu}" + echo -e "${blue}Serverfiles:\t${default}${filesdirdu}" if [ -d "${backupdir}" ]; then - echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" + echo -e "${blue}Backups:\t${default}${backupdirdu}" fi } | column -s $'\t' -t } @@ -101,65 +101,65 @@ fn_details_gameserver(){ # Status: OFFLINE echo -e "" - echo -e "\e[92m${gamename} Server Details\e[0m" + echo -e "\e[92m${gamename} Server Details${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { # Server name - echo -e "\e[34mServer name:\t\e[0m${servername}" + echo -e "${blue}Server name:\t${default}${servername}" # Server ip - echo -e "\e[34mServer IP:\t\e[0m${ip}:${port}" + echo -e "${blue}Server IP:\t${default}${ip}:${port}" # Server password if [ -n "${serverpassword}" ]; then - echo -e "\e[34mServer password:\t\e[0m${serverpassword}" + echo -e "${blue}Server password:\t${default}${serverpassword}" fi # RCON password if [ -n "${rconpassword}" ]; then - echo -e "\e[34mRCON password:\t\e[0m${rconpassword}" + echo -e "${blue}RCON password:\t${default}${rconpassword}" fi # Admin password if [ -n "${adminpassword}" ]; then - echo -e "\e[34mAdmin password:\t\e[0m${adminpassword}" + echo -e "${blue}Admin password:\t${default}${adminpassword}" fi # Stats password (Quake Live) if [ -n "${statspassword}" ]; then - echo -e "\e[34mStats password:\t\e[0m${statspassword}" + echo -e "${blue}Stats password:\t${default}${statspassword}" fi # Slots if [ -n "${slots}" ]; then - echo -e "\e[34mSlots:\t\e[0m${slots}" + echo -e "${blue}Slots:\t${default}${slots}" fi # Game mode if [ -n "${gamemode}" ]; then - echo -e "\e[34mGame mode:\t\e[0m${gamemode}" + echo -e "${blue}Game mode:\t${default}${gamemode}" fi # Game world if [ -n "${gameworld}" ]; then - echo -e "\e[34mGame world:\t\e[0m${gameworld}" + echo -e "${blue}Game world:\t${default}${gameworld}" fi # Tick rate if [ -n "${tickrate}" ]; then - echo -e "\e[34mTick rate:\t\e[0m${tickrate}" + echo -e "${blue}Tick rate:\t${default}${tickrate}" fi # Teamspeak dbplugin if [ -n "${dbplugin}" ]; then - echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}" + echo -e "${blue}dbplugin:\t${default}${dbplugin}" fi # Online status if [ "${status}" == "0" ]; then - echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m" + echo -e "${blue}Status:\t${red}OFFLINE${default}" else - echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m" + echo -e "${blue}Status:\t${green}ONLINE${default}" fi } | column -s $'\t' -t echo -e "" @@ -177,61 +177,61 @@ fn_details_script(){ # Location: /home/lgsm/qlserver # Config file: /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg - echo -e "\e[92m${selfname} Script Details\e[0m" + echo -e "\e[92m${selfname} Script Details${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { # Service name - echo -e "\e[34mService name:\t\e[0m${servicename}" + echo -e "${blue}Service name:\t${default}${servicename}" # Script version if [ -n "${version}" ]; then - echo -e "\e[34m${selfname} version:\t\e[0m${version}" + echo -e "${blue}${selfname} version:\t${default}${version}" fi # User - echo -e "\e[34mUser:\t\e[0m$(whoami)" + echo -e "${blue}User:\t${default}$(whoami)" # GLIBC required if [ -n "${glibcrequired}" ]; then if [ "${glibcrequired}" == "NOT REQUIRED" ]; then : elif [ "${glibcrequired}" == "UNKNOWN" ]; then - echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired}" + echo -e "${blue}GLIBC required:\t${red}${glibcrequired}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then if [ "${glibcfix}" == "yes" ]; then - echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)" + echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${green}Using GLIBC fix${default})" else - echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;31mGLIBC version too old\e[0m)" + echo -e "${blue}GLIBC required:\t${red}${glibcrequired} ${default}(${red}GLIBC version too old${default})" fi else - echo -e "\e[34mGLIBC required:\t\e[0;32m${glibcrequired}\e[0m" + echo -e "${blue}GLIBC required:\t${green}${glibcrequired}${default}" fi fi # Email alert - echo -e "\e[34mEmail alert:\t\e[0m${emailalert}" + echo -e "${blue}Email alert:\t${default}${emailalert}" # Pushbullet alert - echo -e "\e[34mPushbullet alert:\t\e[0m${pushbulletalert}" + echo -e "${blue}Pushbullet alert:\t${default}${pushbulletalert}" # Update on start - echo -e "\e[34mUpdate on start:\t\e[0m${updateonstart}" + echo -e "${blue}Update on start:\t${default}${updateonstart}" # Script location - echo -e "\e[34mLocation:\t\e[0m${rootdir}" + echo -e "${blue}Location:\t${default}${rootdir}" # Config file location if [ -n "${servercfgfullpath}" ]; then if [ -f "${servercfgfullpath}" ]; then - echo -e "\e[34mConfig file:\t\e[0m${servercfgfullpath}" + echo -e "${blue}Config file:\t${default}${servercfgfullpath}" else - echo -e "\e[34mConfig file:\t\e[0m\e[0;31m${servercfgfullpath}\e[0m (\e[0;31mFILE MISSING\e[0m)" + echo -e "${blue}Config file:\t${default}${red}${servercfgfullpath}${default} (${red}FILE MISSING${default})" fi fi # Network config file location (ARMA 3) if [ -n "${networkcfgfullpath}" ]; then - echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}" + echo -e "${blue}Network config file:\t${default}${networkcfgfullpath}" fi } | column -s $'\t' -t } @@ -247,17 +247,17 @@ fn_details_backup(){ # size: 945M echo -e "" - echo -e "\e[92mBackups\e[0m" + echo -e "\e[92mBackups${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then echo -e "No Backups created" else { - echo -e "\e[34mNo. of backups:\t\e[0m${backupcount}" - echo -e "\e[34mLatest backup:\e[0m" - echo -e "\e[34m date:\t\e[0m${lastbackupdate}" - echo -e "\e[34m file:\t\e[0m${lastbackup}" - echo -e "\e[34m size:\t\e[0m${lastbackupsize}" + echo -e "${blue}No. of backups:\t${default}${backupcount}" + echo -e "${blue}Latest backup:${default}" + echo -e "${blue} date:\t${default}${lastbackupdate}" + echo -e "${blue} file:\t${default}${lastbackup}" + echo -e "${blue} size:\t${default}${lastbackupsize}" } | column -s $'\t' -t fi } @@ -269,7 +269,7 @@ fn_details_commandlineparms(){ # ./run_server_x86.sh +set net_strict 1 echo -e "" - echo -e "\e[92mCommand-line Parameters\e[0m" + echo -e "\e[92mCommand-line Parameters${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "${executable} ${parms}" } @@ -281,11 +281,11 @@ fn_details_ports(){ # /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg echo -e "" - echo -e "\e[92mPorts\e[0m" + echo -e "\e[92mPorts${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "Change ports by editing the parameters in:" - parmslocation="\e[0;31mUNKNOWN\e[0m" + parmslocation="${red}UNKNOWN${default}" local ports_edit_array=( "avalanche" "dontstarve" "projectzomboid" "idtech3" "realvirtuality" "seriousengine35" "teeworlds" "terraria" "unreal" "unreal2" "Teamspeak 3" "7 Days To Die" ) for port_edit in "${ports_edit_array[@]}" do @@ -309,9 +309,9 @@ fn_details_ports(){ fn_details_statusbottom(){ echo -e "" if [ "${status}" == "0" ]; then - echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m" + echo -e "${blue}Status:\t${red}OFFLINE${default}" else - echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m" + echo -e "${blue}Status:\t${green}ONLINE${default}" fi echo -e "" } @@ -350,7 +350,7 @@ fn_details_realvirtuality(){ echo -e "netstat -atunp | grep arma3server" echo -e "" if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then - echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}." + echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}." echo -e "" fi { @@ -365,7 +365,7 @@ fn_details_idtech3(){ echo -e "netstat -atunp | grep qzeroded" echo -e "" if [ -z "${port}" ]||[ -z "${rconport}" ]||[ -z "${statsport}" ]; then - echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}." + echo -e "${red}ERROR!${default} Missing/commented ports in ${servercfg}." echo -e "" fi { @@ -410,12 +410,12 @@ fn_details_spark(){ echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin\e[0m" + echo -e "\e[92m${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}/index.html" - echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}" - echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" + echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}/index.html" + echo -e "${blue}WebAdmin username:\t${default}${webadminuser}" + echo -e "${blue}WebAdmin password:\t${default}${webadminpass}" } | column -s $'\t' -t } @@ -470,20 +470,20 @@ fn_details_sdtd(){ echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin\e[0m" + echo -e "\e[92m${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}" - echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}" - echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" + echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}" + echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}" + echo -e "${blue}WebAdmin password:\t${default}${webadminpass}" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} Telnet\e[0m" + echo -e "\e[92m${servername} Telnet${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mTelnet enabled:\t\e[0m${telnetenabled}" - echo -e "\e[34mTelnet address:\t\e[0m${ip} ${telnetport}" - echo -e "\e[34mTelnet password:\t\e[0m${telnetpass}" + echo -e "${blue}Telnet enabled:\t${default}${telnetenabled}" + echo -e "${blue}Telnet address:\t${default}${ip} ${telnetport}" + echo -e "${blue}Telnet password:\t${default}${telnetpass}" } | column -s $'\t' -t } @@ -535,13 +535,13 @@ fn_details_unreal(){ echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin\e[0m" + echo -e "\e[92m${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { - echo -e "\e[34mWebAdmin enabled:\t\e[0m${webadminenabled}" - echo -e "\e[34mWebAdmin url:\t\e[0mhttp://${ip}:${webadminport}" - echo -e "\e[34mWebAdmin username:\t\e[0m${webadminuser}" - echo -e "\e[34mWebAdmin password:\t\e[0m${webadminpass}" + echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}" + echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}" + echo -e "${blue}WebAdmin username:\t${default}${webadminuser}" + echo -e "${blue}WebAdmin password:\t${default}${webadminpass}" } | column -s $'\t' -t } diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 9a5706344..e89b18fe7 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -49,15 +49,15 @@ if [ ! -f "${filedir}/${filename}" ]; then if [ "$(basename ${curlcmd})" == "curl" ]; then curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "${red}FAIL${default}\n" echo "${curlfetch}" echo -e "${githuburl}\n" exit 1 else - echo -e "\e[0;32mOK\e[0m" + echo -e "${green}OK${default}" fi else - echo -e "\e[0;31mFAIL\e[0m\n" + echo -e "${red}FAIL${default}\n" echo "Curl is not installed!" echo -e "" exit 1 diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 6cbb77b8e..c9dcddf05 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -45,30 +45,30 @@ case "${getopt}" in command_dev_detect_deps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD." - echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." } | column -s $'\t' -t esac } @@ -105,27 +105,27 @@ case "${getopt}" in command_dev_detect_deps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate\t\e[0mu |Checks and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mchange-password\t\e[0mpw |Changes TS3 serveradmin password." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}change-password\t${default}pw |Changes TS3 serveradmin password." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." } | column -s $'\t' -t esac } @@ -156,24 +156,24 @@ case "${getopt}" in command_dev_detect_deps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." } | column -s $'\t' -t esac } @@ -219,31 +219,31 @@ case "${getopt}" in command_fastdl.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." - echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." - echo -e "\e[34mfastdl\t\e[0mfd |Generates or update a FastDL folder for your server." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server." } | column -s $'\t' -t esac } @@ -282,28 +282,28 @@ case "${getopt}" in command_dev_detect_deps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." - echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac } @@ -350,31 +350,31 @@ case "${getopt}" in compress_unreal2_maps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." - echo -e "\e[34mforce-update\t\e[0mfu |Bypasses the check and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mvalidate\t\e[0mv |Validate server files with SteamCMD." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." - echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update\t${default}Checks and applies updates from SteamCMD." + echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac } @@ -416,29 +416,29 @@ case "${getopt}" in command_dev_detect_deps.sh;; *) if [ -n "${getopt}" ]; then - echo -e "\e[0;31mUnknown command\e[0m: $0 ${getopt}" + echo -e "${red}Unknown command${default}: $0 ${getopt}" exitcode=2 fi echo "Usage: $0 [option]" echo "${gamename} - Linux Game Server Manager - Version ${version}" echo "https://gameservermanagers.com/${selfname}" echo -e "" - echo -e "\e[93mCommands\e[0m" + echo -e "${lightyellow}Commands${default}" { - echo -e "\e[34mstart\t\e[0mst |Start the server." - echo -e "\e[34mstop\t\e[0msp |Stop the server." - echo -e "\e[34mrestart\t\e[0mr |Restart the server." - echo -e "\e[34mupdate-functions\t\e[0muf |Removes all functions so latest can be downloaded." - echo -e "\e[34mmonitor\t\e[0mm |Checks that the server is running." - echo -e "\e[34mtest-alert\t\e[0mta |Sends test alert." - echo -e "\e[34mdetails\t\e[0mdt |Displays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mb |Create archive of the server." - echo -e "\e[34mconsole\t\e[0mc |Console allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0md |See the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mi |Install the server." - echo -e "\e[34mauto-install\t\e[0mai |Install the server, without prompts." - echo -e "\e[34mserver-cd-key\t\e[0mcd |Add your server cd key" - echo -e "\e[34mmap-compressor\t\e[0mmc |Compresses all ${gamename} server maps." + echo -e "${blue}start\t${default}st |Start the server." + echo -e "${blue}stop\t${default}sp |Stop the server." + echo -e "${blue}restart\t${default}r |Restart the server." + echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded." + echo -e "${blue}monitor\t${default}m |Checks that the server is running." + echo -e "${blue}test-alert\t${default}ta |Sends test alert." + echo -e "${blue}details\t${default}dt |Displays useful infomation about the server." + echo -e "${blue}backup\t${default}b |Create archive of the server." + echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server." + echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal." + echo -e "${blue}install\t${default}i |Install the server." + echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts." + echo -e "${blue}server-cd-key\t${default}cd |Add your server cd key" + echo -e "${blue}map-compressor\t${default}mc |Compresses all ${gamename} server maps." } | column -s $'\t' -t esac } diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 532adfef6..57c3f6ebc 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -7,6 +7,17 @@ # nl: new line: message is following by a new line # eol: end of line: message is placed at the end of the current line +if [ "${ansi}" != "off" ]; then + # echo colors + default="\e[0m" + red="\e[31m" + green="\e[32m" + yellow="\e[33m" + blue="\e[34m" + magenta="\e[35m" + cyan="\e[36m" + lightyellow="\e[93m" +fi # Log display ########## @@ -74,17 +85,17 @@ fn_script_log_info(){ # [ .... ] fn_print_dots(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[ .... ] ${commandaction} ${servicename}: $@" + echo -en "\r[ .... ] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[ .... ] $@" + echo -en "\r[ .... ] $@" fi } fn_print_dots_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r\033[K[ .... ] ${commandaction} ${servicename}: $@" + echo -e "\r[ .... ] ${commandaction} ${servicename}: $@" else - echo -e "\r\033[K[ .... ] $@" + echo -e "\r[ .... ] $@" fi sleep 0.5 echo -en "\n" @@ -93,17 +104,17 @@ fn_print_dots_nl(){ # [ OK ] fn_print_ok(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${green} OK ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" + echo -en "\r[${green} OK ${default}] $@" fi } fn_print_ok_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;32m OK \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${green} OK ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;32m OK \e[0m] $@" + echo -en "\r[${green} OK ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -112,17 +123,17 @@ fn_print_ok_nl(){ # [ FAIL ] fn_print_fail(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" + echo -en "\r[${red} FAIL ${default}] $@" fi } fn_print_fail_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m FAIL \e[0m] $@" + echo -en "\r[${red} FAIL ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -131,17 +142,17 @@ fn_print_fail_nl(){ # [ ERROR ] fn_print_error(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m ERROR \e[0m] $@" + echo -en "\r[${red} ERROR ${default}] $@" fi } fn_print_error_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;31m ERROR \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;31m ERROR \e[0m] $@" + echo -en "\r[${red} ERROR ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -150,17 +161,17 @@ fn_print_error_nl(){ # [ WARN ] fn_print_warn(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" + echo -en "\r[${yellow} WARN ${default}] $@" fi } fn_print_warn_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[1;33m WARN \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[1;33m WARN \e[0m] $@" + echo -en "\r[${yellow} WARN ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -169,17 +180,17 @@ fn_print_warn_nl(){ # [ INFO ] fn_print_info(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r[${cyan} INFO ${default}] $@" fi } fn_print_info_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r\033[K[\e[0;36m INFO \e[0m] ${commandaction} ${servicename}: $@" + echo -en "\r[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r\033[K[\e[0;36m INFO \e[0m] $@" + echo -en "\r[${cyan} INFO ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -190,47 +201,47 @@ fn_print_info_nl(){ # Complete! fn_print_complete(){ - echo -en "\e[0;32mComplete!\e[0m $@" + echo -en "${green}Complete!${default} $@" } fn_print_complete_nl(){ - echo -e "\e[0;32mComplete!\e[0m $@" + echo -e "${green}Complete!${default} $@" } # Failure! fn_print_failure(){ - echo -en "\e[0;31mFailure!\e[0m $@" + echo -en "${red}Failure!${default} $@" } fn_print_failure_nl(){ - echo -e "\e[0;31mFailure!\e[0m $@" + echo -e "${red}Failure!${default} $@" } # Error! fn_print_error(){ - echo -en "\e[0;31mError!\e[0m $@" + echo -en "${red}Error!${default} $@" } fn_print_error_nl(){ - echo -e "\e[0;31mError!\e[0m $@" + echo -e "${red}Error!${default} $@" } # Warning! fn_print_warning(){ - echo -en "\e[0;33mWarning!\e[0m $@" + echo -en "${yellow}Warning!${default} $@" } fn_print_warning_nl(){ - echo -e "\e[0;33mWarning!\e[0m $@" + echo -e "${yellow}Warning!${default} $@" } # Infomation! fn_print_infomation(){ - echo -en "\e[0;36mInfomation!\e[0m $@" + echo -en "${cyan}Infomation!${default} $@" } fn_print_infomation_nl(){ - echo -e "\e[0;36mInfomation!\e[0m $@" + echo -e "${cyan}Infomation!${default} $@" } # On-Screen End of Line @@ -238,81 +249,81 @@ fn_print_infomation_nl(){ # OK fn_print_ok_eol(){ - echo -en "\e[0;32mOK\e[0m" + echo -en "${green}OK${default}" } fn_print_ok_eol_nl(){ - echo -e "\e[0;32mOK\e[0m" + echo -e "${green}OK${default}" } # FAIL fn_print_fail_eol(){ - echo -en "\e[0;31mFAIL\e[0m" + echo -en "${red}FAIL${default}" } fn_print_fail_eol_nl(){ - echo -e "\e[0;31mFAIL\e[0m" + echo -e "${red}FAIL${default}" } # WARN fn_print_warn_eol(){ - echo -en "\e[0;31mFAIL\e[0m" + echo -en "${red}FAIL${default}" } fn_print_warn_eol_nl(){ - echo -e "\e[0;31mFAIL\e[0m" + echo -e "${red}FAIL${default}" } # INFO fn_print_info_eol(){ - echo -en "\e[0;31mFAIL\e[0m" + echo -en "${red}FAIL${default}" } fn_print_info_eol_nl(){ - echo -e "\e[0;31mFAIL\e[0m" + echo -e "${red}FAIL${default}" } # QUERYING fn_print_querying_eol(){ - echo -en "\e[0;36mQUERYING\e[0m" + echo -en "${cyan}QUERYING${default}" } fn_print_querying_eol_nl(){ - echo -e "\e[0;36mQUERYING\e[0m" + echo -e "${cyan}QUERYING${default}" } # CHECKING fn_print_checking_eol(){ - echo -en "\e[0;36mCHECKING\e[0m" + echo -en "${cyan}CHECKING${default}" } fn_print_checking_eol_nl(){ - echo -e "\e[0;36mCHECKING\e[0m" + echo -e "${cyan}CHECKING${default}" } # CANCELED fn_print_canceled_eol(){ - echo -en "\e[0;33mCANCELED\e[0m" + echo -en "${yellow}CANCELED${default}" } fn_print_canceled_eol_nl(){ - echo -e "\e[0;33mCANCELED\e[0m" + echo -e "${yellow}CANCELED${default}" } # REMOVED fn_print_removed_eol(){ - echo -en "\e[0;31mREMOVED\e[0m" + echo -en "${red}REMOVED${default}" } fn_print_removed_eol_nl(){ - echo -e "\e[0;31mREMOVED\e[0m" + echo -e "${red}REMOVED${default}" } # UPDATE fn_print_update_eol(){ - echo -en "\e[0;36mUPDATE\e[0m" + echo -en "${cyan}UPDATE${default}" } fn_print_update_eol_nl(){ - echo -e "\e[0;36mUPDATE\e[0m" + echo -e "${cyan}UPDATE${default}" } \ No newline at end of file diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index ffed74203..2ed6f0131 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -12,8 +12,8 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # tr -d '=\"; ' remove selected charectors =\"; # grep -v "foo" filter out lines that contain foo -unavailable="\e[0;31mUNAVAILABLE\e[0m" -zero="\e[0;31m0\e[0m" +unavailable="${red}UNAVAILABLE${default}" +zero="${red}0${default}" fn_info_config_avalanche(){ if [ ! -f "${servercfgfullpath}" ]; then diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 7e476e987..5cca70c33 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -30,7 +30,7 @@ glibcversion="$(ldd --version | sed -n '1s/.* //p')" ## tmux version # e.g: tmux 1.6 if [ -z "$(command -v tmux)" ]; then - tmuxv="\e[0;31mNOT INSTALLED!\e[0m" + tmuxv="${red}NOT INSTALLED!${default}" elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ]; then tmuxv="$(tmux -V) (>= 1.6 required for console log)" else diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index a640ac938..3fc2cc92d 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -12,8 +12,8 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # tr -d '=\"; ' remove selected charectors =\"; # grep -v "foo" filter out lines that contain foo -unavailable="\e[0;31mUNAVAILABLE\e[0m" -zero="\e[0;31m0\e[0m" +unavailable="${red}UNAVAILABLE${default}" +zero="${red}0${default}" fn_info_config_idtech3(){ diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 1a4002c13..9643d9d56 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -79,7 +79,7 @@ if [ "${gsquery}" == "yes" ]; then # Seconds counter for seconds in {1..15}; do - fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : \e[0;31m${gsquerycmd}\e[0m" + fn_print_fail "Querying port: ${ip}:${port} : ${totalseconds}/${queryattempt} : ${red}${gsquerycmd}${default}" totalseconds=$((totalseconds + 1)) sleep 1 if [ "${seconds}" == "15" ]; then diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh index 584a3901f..44e668c00 100644 --- a/lgsm/functions/update_check.sh +++ b/lgsm/functions/update_check.sh @@ -149,8 +149,8 @@ fn_steamcmdcheck(){ echo -e "\n" echo -e "Update available:" sleep 1 - echo -e " Current build: \e[0;31m${currentbuild}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current build: ${red}${currentbuild}${default}" + echo -e " Available build: ${green}${availablebuild}${default}" echo -e "" echo -e " https://steamdb.info/app/${appid}/" sleep 1 @@ -181,8 +181,8 @@ fn_steamcmdcheck(){ else echo -e "\n" echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current version: ${green}${currentbuild}${default}" + echo -e " Available version: ${green}${availablebuild}${default}" echo -e " https://steamdb.info/app/${appid}/" echo -e "" fn_print_ok_nl "No update available" @@ -279,8 +279,8 @@ fn_teamspeak3_check(){ echo -e "\n" echo -e "Update available:" sleep 1 - echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e " Current build: ${red}${currentbuild} ${architecture}${default}" + echo -e " Available build: ${green}${availablebuild} ${architecture}${default}" echo -e "" sleep 1 echo "" @@ -313,8 +313,8 @@ fn_teamspeak3_check(){ else echo -e "\n" echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current version: ${green}${currentbuild}${default}" + echo -e " Available version: ${green}${availablebuild}${default}" echo -e "" fn_print_ok_nl "No update available" fn_script_log "Current build: ${currentbuild}" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 61981e7c9..3bd47025f 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -171,8 +171,8 @@ fn_update_steamcmd_check(){ echo -e "\n" echo -e "Update available:" sleep 1 - echo -e " Current build: \e[0;31m${currentbuild}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current build: ${red}${currentbuild}${default}" + echo -e " Available build: ${green}${availablebuild}${default}" echo -e "" echo -e " https://steamdb.info/app/${appid}/" sleep 1 @@ -205,8 +205,8 @@ fn_update_steamcmd_check(){ else echo -e "\n" echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current version: ${green}${currentbuild}${default}" + echo -e " Available version: ${green}${availablebuild}${default}" echo -e " https://steamdb.info/app/${appid}/" echo -e "" fn_print_ok_nl "No update available" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index ac2d4805c..e10b1cbac 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -119,8 +119,8 @@ fn_update_ts3_compare(){ echo -e "\n" echo -e "Update available:" sleep 1 - echo -e " Current build: \e[0;31m${currentbuild} ${architecture}\e[0;39m" - echo -e " Available build: \e[0;32m${availablebuild} ${architecture}\e[0;39m" + echo -e " Current build: ${red}${currentbuild} ${architecture}${default}" + echo -e " Available build: ${green}${availablebuild} ${architecture}${default}" echo -e "" sleep 1 echo "" @@ -157,8 +157,8 @@ fn_update_ts3_compare(){ else echo -e "\n" echo -e "No update available:" - echo -e " Current version: \e[0;32m${currentbuild}\e[0;39m" - echo -e " Available version: \e[0;32m${availablebuild}\e[0;39m" + echo -e " Current version: ${green}${currentbuild}${default}" + echo -e " Available version: ${green}${availablebuild}${default}" echo -e "" fn_print_ok_nl "No update available" fn_script_log_info "Current build: ${currentbuild}" From eed7bad25a5cfb6d497e26959465fdbc9e8c58af Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 23:54:03 +0100 Subject: [PATCH 120/195] re arraigned exitbypass --- lgsm/functions/command_restart.sh | 3 ++- lgsm/functions/core_exit.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 67a35c449..1753e6ed7 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -8,7 +8,8 @@ local commandnane="RESTART" local commandaction="Restarting" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -exitbypass=1 info_config.sh +exitbypass=1 command_stop.sh +exitbypass=1 command_start.sh \ No newline at end of file diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index 7e0a704aa..ae5e7a62e 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -11,7 +11,9 @@ fn_exit_dev_debug(){ fi } -if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then +if [ -n "${exitbypass}" ]; then + unset exitbypass +elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then fn_script_log_fatal "${selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then @@ -25,8 +27,6 @@ if [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then # remove trap. trap - INT exit ${exitcode} -elif [ -n "${exitbypass}" ]; then - unset exitbypass else exitcode=0 fn_script_log_pass "${selfname} exiting with code: ${exitcode}" From 8f9565cb36ecd8aace136c9295817fe2b185fa21 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 8 Jul 2016 23:58:38 +0100 Subject: [PATCH 121/195] lightgreen color --- lgsm/functions/command_details.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 89d29d5ec..9374ec869 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -101,7 +101,7 @@ fn_details_gameserver(){ # Status: OFFLINE echo -e "" - echo -e "\e[92m${gamename} Server Details${default}" + echo -e "${lightgreen}${gamename} Server Details${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { # Server name @@ -177,7 +177,7 @@ fn_details_script(){ # Location: /home/lgsm/qlserver # Config file: /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg - echo -e "\e[92m${selfname} Script Details${default}" + echo -e "${lightgreen}${selfname} Script Details${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { # Service name @@ -247,7 +247,7 @@ fn_details_backup(){ # size: 945M echo -e "" - echo -e "\e[92mBackups${default}" + echo -e "${lightgreen}Backups${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then echo -e "No Backups created" @@ -269,7 +269,7 @@ fn_details_commandlineparms(){ # ./run_server_x86.sh +set net_strict 1 echo -e "" - echo -e "\e[92mCommand-line Parameters${default}" + echo -e "${lightgreen}Command-line Parameters${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "${executable} ${parms}" } @@ -281,7 +281,7 @@ fn_details_ports(){ # /home/lgsm/qlserver/serverfiles/baseq3/ql-server.cfg echo -e "" - echo -e "\e[92mPorts${default}" + echo -e "${lightgreen}Ports${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "Change ports by editing the parameters in:" @@ -410,7 +410,7 @@ fn_details_spark(){ echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin${default}" + echo -e "${lightgreen}${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { echo -e "${blue}WebAdmin url:\t${default}http://${ip}:${webadminport}/index.html" @@ -470,7 +470,7 @@ fn_details_sdtd(){ echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin${default}" + echo -e "${lightgreen}${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}" @@ -478,7 +478,7 @@ fn_details_sdtd(){ echo -e "${blue}WebAdmin password:\t${default}${webadminpass}" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} Telnet${default}" + echo -e "${lightgreen}${servername} Telnet${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { echo -e "${blue}Telnet enabled:\t${default}${telnetenabled}" @@ -535,7 +535,7 @@ fn_details_unreal(){ echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" } | column -s $'\t' -t echo -e "" - echo -e "\e[92m${servername} WebAdmin${default}" + echo -e "${lightgreen}${servername} WebAdmin${default}" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = { echo -e "${blue}WebAdmin enabled:\t${default}${webadminenabled}" From edaa4e2bc265f2455a35cdee5cf17676b191e980 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 00:43:46 +0100 Subject: [PATCH 122/195] moved print_dots --- lgsm/functions/check_deps.sh | 18 +++++++++++++----- lgsm/functions/check_glibc.sh | 4 ++-- lgsm/functions/command_start.sh | 6 ++---- lgsm/functions/command_stop.sh | 4 ++-- lgsm/functions/command_test_alert.sh | 1 + lgsm/functions/command_update.sh | 4 +++- lgsm/functions/command_update_functions.sh | 5 +++-- lgsm/functions/command_validate.sh | 5 +++-- lgsm/functions/core_messages.sh | 4 ++-- 9 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index cfdac39f5..3c5849d45 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -72,7 +72,8 @@ fn_found_missing_deps(){ echo -e "" sudo -n true > /dev/null 2>&1 if [ $? -eq 0 ]; then - fn_print_info_nl "Attempting to install missing dependencies automatically" + fn_print_infomation_nl "Attempting to install missing dependencies automatically" + fn_script_log_info "Attempting to install missing dependencies automatically" echo -en ".\r" sleep 1 echo -en "..\r" @@ -82,15 +83,22 @@ fn_found_missing_deps(){ echo -en " \r" if [ -n "$(command -v dpkg-query)" ]; then cmd="sudo dpkg --add-architecture i386; sudo apt-get -y install ${array_deps_missing[@]}" - eval $cmd + eval ${cmd} elif [ -n "$(command -v yum)" ]; then cmd="sudo yum -y install ${array_deps_missing[@]}" - eval $cmd + eval ${cmd} + fi + if [ $? != 0 ]; then + fn_print_failure_nl "Unable to install dependencies" + fn_script_log_fail "Unable to install dependencies" + else + fn_print_success_nl "install dependencies completed" + fn_script_log_pass "install dependencies completed" fi else echo "" - fn_print_infomation_nl "$(whoami) does not have sudo access. Please manually install dependencies" - fn_script_log_info "$(whoami) does not have sudo access. Please manually install dependencies" + fn_print_warning_nl "$(whoami) does not have sudo access. Please manually install dependencies" + fn_script_log_warn "$(whoami) does not have sudo access. Please manually install dependencies" echo "" if [ -n "$(command -v dpkg-query)" ]; then echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 41d4d6ebf..5918bac44 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -15,7 +15,7 @@ info_distro.sh if [ "${glibcrequired}" == "NOT REQUIRED" ]; then : elif [ "${glibcrequired}" == "UNKNOWN" ]; then - fn_print_info_nl "Glibc fix: ${red}${glibcrequired}${default}" + fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}" echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc installed: ${glibcversion}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then @@ -27,7 +27,7 @@ elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n fix_glibc.sh fi else - fn_print_warn_nl "Glibc fix: ${red}No Glibc fix available!${default}" + fn_print_error_nl "Glibc fix: ${red}No Glibc fix available!${default}" echo -en "\n" echo -e " * glibc required: ${glibcrequired}" echo -e " * glibc installed: ${red}${glibcversion}${default}" diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 991aa435c..4a4757590 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -23,8 +23,6 @@ fn_start_teamspeak3(){ sleep 5 touch "${servercfgfullpath}" fi - - fn_print_dots "${servername}" sleep 1 check_status.sh if [ "${status}" != "0" ]; then @@ -57,8 +55,6 @@ fn_start_teamspeak3(){ fn_start_tmux(){ fn_parms - fn_print_dots "${servername}" - sleep 1 # Log rotation check_status.sh @@ -166,6 +162,8 @@ fn_start_tmux(){ echo -en "\n" } +fn_print_dots "${servername}" +sleep 1 check.sh fix.sh info_config.sh diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 5cb3cb5f1..b1a39129a 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -256,9 +256,9 @@ fn_stop_pre_check(){ fi } -check.sh -info_config.sh fn_print_dots "${servername}" sleep 1 +check.sh +info_config.sh fn_stop_pre_check core_exit.sh \ No newline at end of file diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index 98e4d1cf6..ee8f8ddf3 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -8,6 +8,7 @@ local commandnane="ALERT" local commandaction="Alert" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +fn_print_dots "${servername}" check.sh info_config.sh alert="test" diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index b9ecb82dc..a72f84e65 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -8,9 +8,11 @@ local commandnane="UPDATE" local commandaction="Update" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +fn_print_dots "Checking for update" +sleep 1 check.sh -fn_print_dots "Checking for update" + if [ "${gamename}" == "Teamspeak 3" ]; then update_ts3.sh elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 329bab64d..756185aba 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -6,10 +6,11 @@ local commandaction="Update LGSM" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -check.sh + fn_print_dots "Updating functions" -fn_script_log_info "Updating functions" sleep 1 +check.sh +fn_script_log_info "Updating functions" echo -ne "\n" # Removed legecy functions dir diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 09bfb6e8a..2f99f9b27 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -13,8 +13,6 @@ fn_validation(){ echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" sleep 5 echo -en "\n" - fn_print_dots "Checking server files" - sleep 1 fn_print_ok "Checking server files" fn_script_log_info "Checking server files" sleep 1 @@ -35,6 +33,9 @@ fn_validation(){ fn_script_log_info "Checking complete" } +fn_print_dots "Checking server files" +sleep 1 +check.sh check_status.sh if [ "${status}" != "0" ]; then exitbypass=1 diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 57c3f6ebc..99e3c0e75 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -218,11 +218,11 @@ fn_print_failure_nl(){ } # Error! -fn_print_error(){ +fn_print_error2(){ echo -en "${red}Error!${default} $@" } -fn_print_error_nl(){ +fn_print_error2_nl(){ echo -e "${red}Error!${default} $@" } From 6a3193194dab7a95f34a528277017cce74194f1e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 00:48:20 +0100 Subject: [PATCH 123/195] removed local commandaction="Checking" --- lgsm/functions/check.sh | 1 - lgsm/functions/check_config.sh | 1 - lgsm/functions/check_deps.sh | 1 - lgsm/functions/check_glibc.sh | 1 - lgsm/functions/check_ip.sh | 1 - lgsm/functions/check_logs.sh | 1 - lgsm/functions/check_permissions.sh | 1 - lgsm/functions/check_root.sh | 1 - lgsm/functions/check_status.sh | 1 - lgsm/functions/check_steamcmd.sh | 1 - lgsm/functions/check_system_dir.sh | 1 - lgsm/functions/check_tmux.sh | 1 - lgsm/functions/command_monitor.sh | 6 ++++-- lgsm/functions/command_test_alert.sh | 1 + 14 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index a674bcd49..4b82e1cc4 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -7,7 +7,6 @@ # Runs checks that will either halt on or fix an issue. local commandnane="CHECK" -local commandaction="Checking" # Cannot have selfname as breaks the function. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index 1775e1f49..e1ca42706 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -5,7 +5,6 @@ # Description: If server config missing warn user. local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -e "${servercfgfullpath}" ]; then diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 3c5849d45..55686446b 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -5,7 +5,6 @@ # Description: Checks that the requires dependencies are installed for LGSM. local commandnane="CHECK" -local commandaction="Checking" # Cannot have selfname as breaks the function. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 5918bac44..70fda1f94 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -5,7 +5,6 @@ # Description: Checks if server has correct glibc or has a fix available. local commandnane="CHECK" -local commandaction="Checking" # Cannot have selfname as breaks the function. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index 12c94758f..e10dd793d 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -6,7 +6,6 @@ # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0". local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" != "Teamspeak 3" ]; then diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index d4bea2b5a..3d8e5cd40 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -5,7 +5,6 @@ # Description: Checks that log files exist on server start local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Create dir's for the script and console logs diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index a88a742e9..de912b403 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -6,7 +6,6 @@ # Description: Checks script, files and folders ownership and permissions. local commandnane="CHECK" -local commandaction="Checking" # Cannot have selfname as breaks the function. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index eb64ddb1f..b89672cfa 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -4,7 +4,6 @@ # Website: https://gameservermanagers.com local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ $(whoami) = "root" ]; then diff --git a/lgsm/functions/check_status.sh b/lgsm/functions/check_status.sh index 41072261d..3399d07b4 100644 --- a/lgsm/functions/check_status.sh +++ b/lgsm/functions/check_status.sh @@ -5,7 +5,6 @@ # Description: Checks the proccess status of the server. Either online or offline. local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Teamspeak 3" ]; then diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 01049a5aa..3b80312ab 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -5,7 +5,6 @@ # Description: Checks SteamCMD is installed and correct. local commandnane="CHECK" -local commandaction="Checking" # Cannot have selfname as breaks the function. #local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index be737d05a..26a4506b5 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -4,7 +4,6 @@ # Website: https://gameservermanagers.com local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -d "${systemdir}" ]; then diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index 5b2fa51d9..c3680d5fa 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -5,7 +5,6 @@ # Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google. local commandnane="CHECK" -local commandaction="Checking" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index d2a93a499..d1a155d69 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -80,11 +80,13 @@ fn_monitor_tmux(){ fi } +fn_print_dots "${servername}" +sleep 1 check.sh logs.sh info_config.sh -fn_print_dots "${servername}" -sleep 1 + + fn_monitor_check_lockfile fn_monitor_check_update fn_monitor_msg_checking diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index ee8f8ddf3..c9e17785c 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -9,6 +9,7 @@ local commandaction="Alert" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "${servername}" +sleep 1 check.sh info_config.sh alert="test" From 2ae02cd187ab602cb7b850d0e96c087b14bbad13 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 00:51:36 +0100 Subject: [PATCH 124/195] removed space in error --- lgsm/functions/core_messages.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 99e3c0e75..cadfc9975 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -142,17 +142,17 @@ fn_print_fail_nl(){ # [ ERROR ] fn_print_error(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} ERROR ${default}] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} ERROR${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} ERROR ${default}] $@" + echo -en "\r[${red} ERROR${default}] $@" fi } fn_print_error_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} ERROR ${default}] ${commandaction} ${servicename}: $@" + echo -en "\r[${red} ERROR${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} ERROR ${default}] $@" + echo -en "\r[${red} ERROR${default}] $@" fi sleep 0.5 echo -en "\n" From a0d2122361f4eef8edb171838ec8733cfe461bae Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 00:57:08 +0100 Subject: [PATCH 125/195] messages --- lgsm/functions/check_deps.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 55686446b..c40ab0e62 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -68,11 +68,10 @@ fn_found_missing_deps(){ fn_print_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" fn_script_log_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" sleep 1 - echo -e "" sudo -n true > /dev/null 2>&1 if [ $? -eq 0 ]; then - fn_print_infomation_nl "Attempting to install missing dependencies automatically" - fn_script_log_info "Attempting to install missing dependencies automatically" + fn_print_infomation_nl "Automatically installing missing dependencies." + fn_script_log_info "Automatically installing missing dependencies." echo -en ".\r" sleep 1 echo -en "..\r" @@ -91,18 +90,17 @@ fn_found_missing_deps(){ fn_print_failure_nl "Unable to install dependencies" fn_script_log_fail "Unable to install dependencies" else - fn_print_success_nl "install dependencies completed" - fn_script_log_pass "install dependencies completed" + fn_print_success_nl "Install dependencies completed" + fn_script_log_pass "Install dependencies completed" fi else echo "" - fn_print_warning_nl "$(whoami) does not have sudo access. Please manually install dependencies" - fn_script_log_warn "$(whoami) does not have sudo access. Please manually install dependencies" - echo "" + fn_print_warning_nl "$(whoami) does not have sudo access. Manually install dependencies." + fn_script_log_warn "$(whoami) does not have sudo access. Manually install dependencies." if [ -n "$(command -v dpkg-query)" ]; then - echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" + echo " sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}" elif [ -n "$(command -v yum)" ]; then - echo "sudo yum install ${array_deps_missing[@]}" + echo " sudo yum install ${array_deps_missing[@]}" fi echo "" fi From 6fba694b97b94820c29179861fccb79df606a836 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:03:11 +0100 Subject: [PATCH 126/195] messages --- lgsm/functions/check_ip.sh | 2 +- lgsm/functions/core_messages.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index e10dd793d..b9083911e 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -20,7 +20,7 @@ if [ "${gamename}" != "Teamspeak 3" ]; then if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_print_fail "Multiple active network interfaces found.\n\n" - echo -en "Manually specify the IP you want to use within the ${selfname} script.\n" + fn_print_infomation "Specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "${getip}\n" echo -en "" diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index cadfc9975..933a7bded 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -142,17 +142,17 @@ fn_print_fail_nl(){ # [ ERROR ] fn_print_error(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} ERROR${default}] ${commandaction} ${servicename}: $@" + echo -en "\r[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} ERROR${default}] $@" + echo -en "\r[${red}ERROR ${default}] $@" fi } fn_print_error_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} ERROR${default}] ${commandaction} ${servicename}: $@" + echo -en "\r[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} ERROR${default}] $@" + echo -en "\r[${red}ERROR ${default}] $@" fi sleep 0.5 echo -en "\n" From 44453353dfdbcfe056af061a64b6afd978a356f5 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:11:27 +0100 Subject: [PATCH 127/195] messages --- lgsm/functions/check_deps.sh | 2 +- lgsm/functions/check_glibc.sh | 6 ++++++ lgsm/functions/check_ip.sh | 2 ++ lgsm/functions/check_logs.sh | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index c40ab0e62..6a5ad2623 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -64,7 +64,7 @@ fn_deps_email(){ fn_found_missing_deps(){ if [ "${#array_deps_missing[@]}" != "0" ]; then fn_print_dots "Checking dependencies" - sleep 2 + sleep 0.5 fn_print_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" fn_script_log_error "Checking dependencies: missing: ${red}${array_deps_missing[@]}${default}" sleep 1 diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 70fda1f94..259ac9561 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -14,18 +14,24 @@ info_distro.sh if [ "${glibcrequired}" == "NOT REQUIRED" ]; then : elif [ "${glibcrequired}" == "UNKNOWN" ]; then + fn_print_dots "Glibc fix" + sleep 0.5 fn_print_error_nl "Glibc fix: ${red}${glibcrequired}${default}" echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc installed: ${glibcversion}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then if [ "${glibcfix}" == "yes" ]; then if [ "${selfname}" != "command_install.sh" ]; then + fn_print_dots "Glibc fix" + sleep 0.5 fn_print_info_nl "Glibc fix: ${green}Using Glibc fix${default}" echo -e " * glibc required: ${red}${glibcrequired}${default}" echo -e " * glibc installed: ${glibcversion}" fix_glibc.sh fi else + fn_print_dots "Glibc fix" + sleep 0.5 fn_print_error_nl "Glibc fix: ${red}No Glibc fix available!${default}" echo -en "\n" echo -e " * glibc required: ${glibcrequired}" diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index b9083911e..ab2fa3768 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -19,6 +19,8 @@ if [ "${gamename}" != "Teamspeak 3" ]; then if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then + fn_print_dots "" + sleep 0.5 fn_print_fail "Multiple active network interfaces found.\n\n" fn_print_infomation "Specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index 3d8e5cd40..b8474ca6b 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -10,7 +10,7 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Create dir's for the script and console logs if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then fn_print_dots "Checking for log files" - sleep 1 + sleep 0.5 fn_print_info_nl "Checking for log files: Creating log files" checklogs=1 install_logs.sh From aeefbe964eeb83e9e777205e4115b9a497713efb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:14:01 +0100 Subject: [PATCH 128/195] message --- lgsm/functions/check_root.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index b89672cfa..31c55a63a 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -9,7 +9,7 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" if [ -d "${scriptlogdir}" ]; then - fn_scriptlog_fatal "${selfname} attempted to run as root." + fn_script_log_fatal "${selfname} attempted to run as root." fi core_exit.sh fi From 362d1b83005feb4dd54d8808c8349d3149f6fc2b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:19:47 +0100 Subject: [PATCH 129/195] message --- lgsm/functions/command_backup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index cc651c920..dfba86a66 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -11,7 +11,8 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_distro.sh backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" -echo "" +fn_print_dots "" +sleep 0.5 fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the following backup:" echo "${backupdir}/${backupname}.tar.gz" echo "" From f2db46aaacf0e0b50d2c600f7f710603b9093903 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:20:54 +0100 Subject: [PATCH 130/195] read y --- lgsm/functions/command_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index dfba86a66..a5c68caab 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -17,7 +17,7 @@ fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the fo echo "${backupdir}/${backupname}.tar.gz" echo "" while true; do - read -p "Continue? [Y/N]" yn + read -e -i "y" -p "Continue? [Y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return;; From da4abb8975e662b77730836dc3de24da69573ba2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:38:15 +0100 Subject: [PATCH 131/195] added tar error checking --- lgsm/functions/command_backup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index a5c68caab..f9841bd83 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -17,7 +17,7 @@ fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the fo echo "${backupdir}/${backupname}.tar.gz" echo "" while true; do - read -e -i "y" -p "Continue? [Y/N]" yn + read -p "Continue? [Y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return;; @@ -47,9 +47,13 @@ if [ ! -d "${backupdir}" ]; then mkdir "${backupdir}" fi tar -czf "${backupdir}/${backupname}.tar.gz" -C "${rootdir}" --exclude "backups" ./* -# NOTE: Need to add error checking for tar. -fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" -fn_script_log_pass "Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" +if [ $? != 0 ]; then + fn_print_ok_nl "Backup created: ${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" + fn_script_log_pass "Backup created: ${backupdir}/${backupname}.tar.gz is $(du -sh "${backupdir}/${backupname}.tar.gz" | awk '{print $1}') size" +else + fn_print_error_nl "Backup failed: ${backupname}.tar.gz" + fn_script_log_error "Backup failed: ${backupname}.tar.gz" +fi sleep 1 echo "" core_exit.sh \ No newline at end of file From c10622cf92bf9984a47ac684bdcc5785bb581cf4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:39:49 +0100 Subject: [PATCH 132/195] read --- lgsm/functions/command_backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index f9841bd83..7ddeb8bc6 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -17,7 +17,7 @@ fn_print_info_nl "A total of ${rootdirduexbackup} will be compressed into the fo echo "${backupdir}/${backupname}.tar.gz" echo "" while true; do - read -p "Continue? [Y/N]" yn + read -e -i "y" -p "Continue? [Y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return;; From 9f1a86dde17dc720cc9881e9c0567aa7b5b96080 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:44:37 +0100 Subject: [PATCH 133/195] messages --- lgsm/functions/command_update.sh | 4 ++-- lgsm/functions/update_steamcmd.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index a72f84e65..4662d7133 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -8,8 +8,8 @@ local commandnane="UPDATE" local commandaction="Update" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -fn_print_dots "Checking for update" -sleep 1 +fn_print_dots "" +sleep 0.5 check.sh diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 3bd47025f..75d7df566 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -12,10 +12,10 @@ fn_update_steamcmd_dl(){ check.sh info_config.sh - fn_print_dots "Updating ${servername}" + fn_print_dots "Starting SteamCMD" sleep 1 - fn_print_ok_nl "Updating ${servername}" - fn_script_log_info "Updating ${servername}" + fn_print_ok_nl "Starting SteamCMD" + fn_script_log_info "Starting SteamCMD" cd "${rootdir}/steamcmd" From a01ed79d8530277e131f1b2e0a5b8d3e7d043435 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:55:16 +0100 Subject: [PATCH 134/195] fixed if --- lgsm/functions/command_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index 4662d7133..d06608a8f 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -15,7 +15,7 @@ check.sh if [ "${gamename}" == "Teamspeak 3" ]; then update_ts3.sh -elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then +else update_steamcmd.sh fi From d8d210812a1a0159af68c2b15a8f7212033c7502 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 9 Jul 2016 01:55:24 +0100 Subject: [PATCH 135/195] no longer required --- lgsm/functions/update_check.sh | 343 --------------------------------- lgsm/functions/update_dl.sh | 82 -------- 2 files changed, 425 deletions(-) delete mode 100644 lgsm/functions/update_check.sh delete mode 100644 lgsm/functions/update_dl.sh diff --git a/lgsm/functions/update_check.sh b/lgsm/functions/update_check.sh deleted file mode 100644 index 44e668c00..000000000 --- a/lgsm/functions/update_check.sh +++ /dev/null @@ -1,343 +0,0 @@ -#!/bin/bash -# LGSM update_check.sh function -# Author: Daniel Gibbs -# Website: https://gameservermanagers.com -# Description: Checks if a server update is available. - -local commandnane="UPDATE" -local commandaction="Update" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" - -### SteamCMD Update Checker ### - -fn_appmanifestinfo(){ - appmanifestfile=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf") - appmanifestfilewc=$(find "${filesdir}" -type f -name "appmanifest_${appid}.acf"|wc -l) -} - -fn_appmanifestcheck(){ - fn_appmanifestinfo - # Multiple or no matching appmanifest files may sometimes be available. - # This is an error is corrected below if required. - if [ "${appmanifestfilewc}" -ge "2" ]; then - sleep 1 - fn_print_warn "Multiple appmanifest_${appid}.acf files found" - fn_script_log_warn "Multiple appmanifest_${appid}.acf files found" - sleep 2 - fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" - sleep 1 - for appfile in ${appmanifestfile}; do - rm "${appfile}" - done - appmanifestfilewc1="${appmanifestfilewc}" - fn_appmanifestinfo - if [ "${appmanifestfilewc}" -ge "2" ]; then - fn_print_fail "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - fn_script_log_fatal "Unable to remove x${appmanifestfilewc} appmanifest_${appid}.acf files" - sleep 1 - echo "" - echo " Check user permissions" - for appfile in ${appmanifestfile}; do - echo " ${appfile}" - done - exit 1 - else - sleep 1 - fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" - fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" - sleep 1 - fn_print_info_nl "Forcing update to correct issue" - fn_script_log_info "Forcing update to correct issue" - sleep 1 - update_dl.sh - update_check.sh - fi - elif [ "${appmanifestfilewc}" -eq "0" ]; then - if [ "${forceupdate}" == "1" ]; then - fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" - fn_script_log_fatal "Still no appmanifest_${appid}.acf found: Unable to update" - core_exit.sh - fi - forceupdate=1 - fn_print_warn "No appmanifest_${appid}.acf found" - fn_script_log_warn "No appmanifest_${appid}.acf found" - sleep 2 - fn_print_info_nl "Forcing update to correct issue" - fn_script_log_warn "Forcing update to correct issue" - sleep 1 - update_dl.sh - update_check.sh - fi -} - -fn_logupdaterequest(){ - # Checks for server update requests from server logs. - fn_print_dots "Checking for update: Server logs" - fn_script_log_info "Checking for update: Server logs" - sleep 1 - requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") - if [ "${requestrestart}" -ge "1" ]; then - fn_print_ok_nl "Checking for update: Server logs: Update requested" - sleep 1 - echo "" - echo -ne "Applying update.\r" - sleep 1 - echo -ne "Applying update..\r" - sleep 1 - echo -ne "Applying update...\r" - sleep 1 - echo -ne "\n" - - unset updateonstart - check_status.sh - if [ "${status}" != "0" ]; then - command_stop.sh - update_dl.sh - command_start.sh - else - update_dl.sh - fi - alert="update" - alert.sh - else - fn_print_ok "Checking for update: Server logs: No update requested" - sleep 1 - fi -} - -fn_steamcmdcheck(){ - fn_appmanifestcheck - # Checks for server update from SteamCMD - fn_print_dots "Checking for update: SteamCMD" - fn_script_log_info "Checking for update: SteamCMD" - sleep 1 - - # Gets currentbuild - currentbuild=$(grep buildid "${appmanifestfile}" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) - - # Removes appinfo.vdf as a fix for not always getting up to date version info from SteamCMD - - # Gets availablebuild info - cd "${rootdir}/steamcmd" - if [ -f "${HOME}/Steam/appcache/appinfo.vdf" ]; then - rm -f "${HOME}/Steam/appcache/appinfo.vdf" - fi - - # set branch for updateinfo - IFS=' ' read -a branchsplits <<< "${branch}" - if [ "${#branchsplits[@]}" -gt 1 ]; then - branchname="${branchsplits[1]}" - else - branchname="public" - fi - - availablebuild=$(./steamcmd.sh +login "${steamuser}" "${steampass}" +app_info_update 1 +app_info_print "${appid}" +app_info_print "${appid}" +quit | grep -EA 1000 "^\s+\"branches\"$" | grep -EA 5 "^\s+\"${branchname}\"$" | grep -m 1 -EB 10 "^\s+}$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -d\ -f3) - if [ -z "${availablebuild}" ]; then - fn_print_fail "Checking for update: SteamCMD" - fn_script_log_fatal "Checking for update: SteamCMD" - sleep 1 - fn_print_fail_nl "Checking for update: SteamCMD: Not returning version info" - fn_script_log_fatal "Checking for update: SteamCMD: Not returning version info" - core_exit.sh - else - fn_print_ok "Checking for update: SteamCMD" - fn_script_log_pass "Checking for update: SteamCMD" - sleep 1 - fi - - if [ "${currentbuild}" != "${availablebuild}" ]; then - echo -e "\n" - echo -e "Update available:" - sleep 1 - echo -e " Current build: ${red}${currentbuild}${default}" - echo -e " Available build: ${green}${availablebuild}${default}" - echo -e "" - echo -e " https://steamdb.info/app/${appid}/" - sleep 1 - echo "" - echo -en "Applying update.\r" - sleep 1 - echo -en "Applying update..\r" - sleep 1 - echo -en "Applying update...\r" - sleep 1 - echo -en "\n" - fn_script_log "Update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fn_script_log "${currentbuild} > ${availablebuild}" - - unset updateonstart - check_status.sh - if [ "${status}" != "0" ]; then - command_stop.sh - update_dl.sh - command_start.sh - else - update_dl.sh - fi - alert="update" - alert.sh - else - echo -e "\n" - echo -e "No update available:" - echo -e " Current version: ${green}${currentbuild}${default}" - echo -e " Available version: ${green}${availablebuild}${default}" - echo -e " https://steamdb.info/app/${appid}/" - echo -e "" - fn_print_ok_nl "No update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fi -} - -### END SteamCMD Update Checker ### - -fn_teamspeak3_check(){ - # Checks for server update from teamspeak.com using a mirror dl.4players.de - fn_print_dots "Checking for update: teamspeak.com" - fn_script_log_info "Checking for update: teamspeak.com" - sleep 1 - - # Gets currentbuild info - # Checks currentbuild info is available, if fails a server restart will be forced to generate logs - if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found" - sleep 2 - fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart" - sleep 2 - command_stop.sh - command_start.sh - sleep 2 - # If still failing will exit - if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail_nl "Checking for update: teamspeak.com: Still No logs with server version found" - fn_script_log_fatal "Checking for update: teamspeak.com: Still No logs with server version found" - core_exit.sh - else - exitcode=0 - fi - fi - currentbuild=$(cat $(find ./* -name 'ts3server*_0.log' 2> /dev/null | sort | egrep -E -v '${rootdir}/.ts3version' | tail -1) | egrep -o 'TeamSpeak 3 Server ((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}' | egrep -o '((\.)?[0-9]{1,3}){1,3}\.[0-9]{1,3}') - - # Gets the teamspeak server architecture - info_distro.sh - if [ "${arch}" == "x86_64" ]; then - ts3arch="amd64" - elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then - ts3arch="x86" - else - echo "" - fn_print_failure "${arch} is an unsupported architecture" - exit 1 - fi - - # Gets availablebuild info - - # Grabs all version numbers but not in correct order - wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp - - # Sort version numbers - cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp - - # Finds directory with most recent server version. - while read ts3_version_number; do - wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - if [ $? -eq 0 ]; then - availablebuild="${ts3_version_number}" - # Break while-loop, if the latest release could be found - break - fi - done < .ts3_version_numbers_sorted.tmp - - # Tidy up - rm -f ".ts3_version_numbers_unsorted.tmp" - rm -f ".ts3_version_numbers_sorted.tmp" - - # Checks availablebuild info is available - if [ -z "${availablebuild}" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail "Checking for update: teamspeak.com: Not returning version info" - fn_script_log_fatal "Failure! Checking for update: teamspeak.com: Not returning version info" - sleep 1 - core_exit.sh - else - fn_print_ok "Checking for update: teamspeak.com" - fn_script_log_pass "Checking for update: teamspeak.com" - sleep 1 - fi - - # Removes dots so if can compare version numbers - currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') - availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') - if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then - echo -e "\n" - echo -e "Update available:" - sleep 1 - echo -e " Current build: ${red}${currentbuild} ${architecture}${default}" - echo -e " Available build: ${green}${availablebuild} ${architecture}${default}" - echo -e "" - sleep 1 - echo "" - echo -en "Applying update.\r" - sleep 1 - echo -en "Applying update..\r" - sleep 1 - echo -en "Applying update...\r" - sleep 1 - echo -en "\n" - fn_script_log "Update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fn_script_log "${currentbuild} > ${availablebuild}" - - unset updateonstart - check_status.sh - if [ "${status}" == "0" ]; then - update_dl.sh - command_start.sh - sleep 5 - command_stop.sh - else - command_stop.sh - update_dl.sh - command_start.sh - fi - alert="update" - alert.sh - else - echo -e "\n" - echo -e "No update available:" - echo -e " Current version: ${green}${currentbuild}${default}" - echo -e " Available version: ${green}${availablebuild}${default}" - echo -e "" - fn_print_ok_nl "No update available" - fn_script_log "Current build: ${currentbuild}" - fn_script_log "Available build: ${availablebuild}" - fi -} - -check.sh -fn_print_dots "Checking for update" -if [ "${gamename}" == "Teamspeak 3" ]; then - fn_teamspeak3_check -elif [ "${engine}" == "goldsource" ]||[ "${forceupdate}" == "1" ]; then - # Goldsource servers bypass checks as fn_steamcmdcheck does not work for appid 90 servers. - # forceupdate bypasses checks - if [ "${status}" != "0" ]; then - exitbypass=1 - command_stop.sh - update_dl.sh - command_start.sh - else - update_dl.sh - fi -else - fn_logupdaterequest - fn_steamcmdcheck -fi diff --git a/lgsm/functions/update_dl.sh b/lgsm/functions/update_dl.sh deleted file mode 100644 index c8e5ac967..000000000 --- a/lgsm/functions/update_dl.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# LGSM update_dl.sh function -# Author: Daniel Gibbs -# Website: https://gameservermanagers.com -# Description: Runs a server update. - -local commandnane="UPDATE" -local commandaction="Update" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" - -fn_steamcmd_dl(){ - cd "${rootdir}" - cd "steamcmd" - - # Detects if unbuffer command is available. - if [ $(command -v stdbuf) ]; then - unbuffer="stdbuf -i0 -o0 -e0" - fi - - if [ "${engine}" == "goldsource" ]; then - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_set_config 90 mod ${appidmod} +app_update "${appid}" +quit | tee -a "${scriptlog}" - else - ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit | tee -a "${scriptlog}" - fi - - fix.sh -} - -fn_teamspeak3_dl(){ - cd "${rootdir}" - echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" - fn_script_log "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq - sleep 1 - echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" - fn_script_log "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp" - local status=$? - if [ ${status} -eq 0 ]; then - echo "OK" - else - echo "FAIL - Exit status ${status}" - fn_script_log "Failed to extract - Exit status ${status}" - sleep 1 - cat "${scriptlogdir}/.${servicename}-tar-error.tmp" - cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}" - rm "${scriptlogdir}/.${servicename}-tar-error.tmp" - fn_script_log "Failure! Unable to update" - exit ${status} - fi - echo -e "copying to ${filesdir}...\c" - fn_script_log "Copying to ${filesdir}" - cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp" - local status=$? - if [ ${status} -eq 0 ]; then - echo "OK" - else - echo "FAIL - Exit status ${status}" - fn_script_log "Failed to copy - Exit status ${status}" - sleep 1 - cat "${scriptlogdir}/.${servicename}-cp-error.tmp" - cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}" - rm "${scriptlogdir}/.${servicename}-cp-error.tmp" - fn_script_log "Failure! Unable to update" - exit ${status} - fi - rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 - rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}" -} - -check.sh -info_config.sh -fn_print_dots "Updating ${servername}" -sleep 1 -fn_print_ok_nl "Updating ${servername}" -fn_script_log "Updating ${servername}" -sleep 1 -if [ "${gamename}" == "Teamspeak 3" ]; then - fn_teamspeak3_dl -else - fn_steamcmd_dl -fi From b1e9435413c561a8d479d3398572a104fa949f02 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 01:52:18 +0100 Subject: [PATCH 136/195] added creeol var carriage return & erase to end of line back in to the script. --- lgsm/functions/core_messages.sh | 50 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 933a7bded..81175530a 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -17,6 +17,8 @@ if [ "${ansi}" != "off" ]; then magenta="\e[35m" cyan="\e[36m" lightyellow="\e[93m" + # carriage return & Erase to end of line: + creeol="\r\033[K" fi # Log display @@ -85,17 +87,17 @@ fn_script_log_info(){ # [ .... ] fn_print_dots(){ if [ -n "${commandaction}" ]; then - echo -en "\r[ .... ] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[ .... ] ${commandaction} ${servicename}: $@" else - echo -en "\r[ .... ] $@" + echo -en "${creeol}[ .... ] $@" fi } fn_print_dots_nl(){ if [ -n "${commandaction}" ]; then - echo -e "\r[ .... ] ${commandaction} ${servicename}: $@" + echo -e "${creeol}[ .... ] ${commandaction} ${servicename}: $@" else - echo -e "\r[ .... ] $@" + echo -e "${creeol}[ .... ] $@" fi sleep 0.5 echo -en "\n" @@ -104,17 +106,17 @@ fn_print_dots_nl(){ # [ OK ] fn_print_ok(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${green} OK ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${green} OK ${default}] $@" + echo -en "${creeol}[${green} OK ${default}] $@" fi } fn_print_ok_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${green} OK ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${green} OK ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${green} OK ${default}] $@" + echo -en "${creeol}[${green} OK ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -123,17 +125,17 @@ fn_print_ok_nl(){ # [ FAIL ] fn_print_fail(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} FAIL ${default}] $@" + echo -en "${creeol}[${red} FAIL ${default}] $@" fi } fn_print_fail_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${red} FAIL ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red} FAIL ${default}] $@" + echo -en "${creeol}[${red} FAIL ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -142,17 +144,17 @@ fn_print_fail_nl(){ # [ ERROR ] fn_print_error(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red}ERROR ${default}] $@" + echo -en "${creeol}[${red}ERROR ${default}] $@" fi } fn_print_error_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${red}ERROR ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${red}ERROR ${default}] $@" + echo -en "${creeol}[${red}ERROR ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -161,17 +163,17 @@ fn_print_error_nl(){ # [ WARN ] fn_print_warn(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${yellow} WARN ${default}] $@" + echo -en "${creeol}[${yellow} WARN ${default}] $@" fi } fn_print_warn_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${yellow} WARN ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${yellow} WARN ${default}] $@" + echo -en "${creeol}[${yellow} WARN ${default}] $@" fi sleep 0.5 echo -en "\n" @@ -180,17 +182,17 @@ fn_print_warn_nl(){ # [ INFO ] fn_print_info(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${cyan} INFO ${default}] $@" + echo -en "${creeol}[${cyan} INFO ${default}] $@" fi } fn_print_info_nl(){ if [ -n "${commandaction}" ]; then - echo -en "\r[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" + echo -en "${creeol}[${cyan} INFO ${default}] ${commandaction} ${servicename}: $@" else - echo -en "\r[${cyan} INFO ${default}] $@" + echo -en "${creeol}[${cyan} INFO ${default}] $@" fi sleep 0.5 echo -en "\n" From f6c60ef37197efca7f8f3f1b06061c0bf83275f7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 01:52:27 +0100 Subject: [PATCH 137/195] messages --- lgsm/functions/check_config.sh | 2 ++ lgsm/functions/update_steamcmd.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index e1ca42706..a4061dd40 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -9,6 +9,8 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then + fn_print_dots "" + sleep 0.5 fn_print_warn_nl "Configuration file missing!" echo "${servercfgfullpath}" fn_script_log_warn "Configuration file missing!" diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 75d7df566..46ff1874f 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -209,7 +209,7 @@ fn_update_steamcmd_check(){ echo -e " Available version: ${green}${availablebuild}${default}" echo -e " https://steamdb.info/app/${appid}/" echo -e "" - fn_print_ok_nl "No update available" + fn_print_ok_nl ": Checking for update: No update available" fn_script_log_info "Current build: ${currentbuild}" fn_script_log_info "Available build: ${availablebuild}" fi From fe86ab76d6a03286dfdf6d4d79680a782ddced43 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 02:52:33 +0100 Subject: [PATCH 138/195] messages --- lgsm/functions/check_steamcmd.sh | 6 ++--- lgsm/functions/command_console.sh | 2 +- lgsm/functions/command_debug.sh | 2 +- lgsm/functions/command_monitor.sh | 12 +++++----- lgsm/functions/command_stop.sh | 38 ++++++++++++++++-------------- lgsm/functions/command_validate.sh | 22 ++++++++++------- lgsm/functions/core_dl.sh | 4 ++-- lgsm/functions/core_messages.sh | 2 +- lgsm/functions/fix.sh | 2 +- lgsm/functions/update_steamcmd.sh | 16 ++++++------- lgsm/functions/update_ts3.sh | 8 +++---- 11 files changed, 61 insertions(+), 53 deletions(-) diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 3b80312ab..695ba5592 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -30,7 +30,7 @@ fn_check_steamcmd_user(){ fi # Anonymous user is set if steamuser is missing if [ -z "${steamuser}" ]; then - fn_print_warn_nl "Steam login not set. Using anonymous login." + fn_print_error_nl "Steam login not set. Using anonymous login." if [ -d "${scriptlogdir}" ]; then fn_script_log_error "Steam login not set. Using anonymous login." fi @@ -48,8 +48,8 @@ fn_check_steamcmd_sh(){ if [ "${selfname}" == "command_install.sh" ]; then fn_install_steamcmd else - fn_print_warn_nl "SteamCMD is missing" - fn_script_log_warn "SteamCMD is missing" + fn_print_error_nl "SteamCMD is missing" + fn_script_log_error "SteamCMD is missing" sleep 1 fn_install_steamcmd fi diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 301bb4c07..b23a3a06b 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -35,7 +35,7 @@ if [ "${status}" != "0" ]; then fn_print_ok_nl "Closing console" fn_script_log_info "Console closed" else - fn_print_fail_nl "Server not running" + fn_print_error_nl "Server not running" fn_script_log_error "Failed to access: Server not running" sleep 1 while true; do diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 4bd35c56c..3be89db87 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -15,7 +15,7 @@ fn_lockfile_trap(){ # resets terminal. Servers can sometimes mess up the terminal on exit. reset fn_print_ok_nl "Closing debug" - fn_script_log_info "Debug closed" + fn_script_log_pass "Debug closed" core_exit.sh } diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index d1a155d69..3d2cbc965 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -12,8 +12,8 @@ local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found if [ ! -f "${rootdir}/${lockselfname}" ]; then - fn_print_info_nl "Disabled: No lock file found" - fn_script_log_info "Disabled: No lock file found" + fn_print_error_nl "Disabled: No lock file found" + fn_script_log_error "Disabled: No lock file found" echo " * To enable monitor run ./${selfname} start" core_exit.sh fi @@ -22,8 +22,8 @@ fn_monitor_check_lockfile(){ fn_monitor_check_update(){ # Monitor will not check if update is running. if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then - fn_print_info_nl "SteamCMD is currently checking for updates" - fn_script_log_info "SteamCMD is currently checking for updates" + fn_print_error_nl "SteamCMD is currently checking for updates" + fn_script_log_error "SteamCMD is currently checking for updates" sleep 1 core_exit.sh fi @@ -42,7 +42,7 @@ fn_monitor_teamspeak3(){ fn_print_ok_eol_nl fn_script_log_pass "Checking session: OK" else - fn_print_fail "Checking session: ${ts3error}: " + fn_print_error "Checking session: ${ts3error}: " fn_print_fail_eol_nl fn_script_log_error "Checking session: ${ts3error}: FAIL" failurereason="${ts3error}" @@ -69,7 +69,7 @@ fn_monitor_tmux(){ fi done else - fn_print_fail "Checking session: " + fn_print_error "Checking session: " fn_print_fail_eol_nl fn_script_log_error "Checking session: FAIL" alert="restart" diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index b1a39129a..666326c9b 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -28,9 +28,9 @@ fn_stop_graceful_source(){ done check_status.sh if [ "${status}" != "0" ]; then - fn_print_fail "Graceful: rcon quit: " + fn_print_error "Graceful: rcon quit: " fn_print_fail_eol_nl - fn_script_log_fail "Graceful: rcon quit: FAIL" + fn_script_log_error "Graceful: rcon quit: FAIL" fi sleep 1 fn_stop_tmux @@ -94,9 +94,9 @@ fn_stop_graceful_sdtd(){ completed=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Completed.") refused=$(echo -en "\n ${sdtd_telnet_shutdown}"|grep "Timeout or EOF") if [ -n "${refused}" ]; then - fn_print_warn "Graceful: telnet: ${telnetip}: " + fn_print_error "Graceful: telnet: ${telnetip}: " fn_print_fail_eol_nl - fn_script_log_warn "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL" sleep 1 elif [ -n "${completed}" ]; then break @@ -122,12 +122,12 @@ fn_stop_graceful_sdtd(){ # If cannot shutdown correctly world save may be lost else if [ -n "${refused}" ]; then - fn_print_fail "Graceful: telnet: " + fn_print_error "Graceful: telnet: " fn_print_fail_eol_nl - fn_script_log_fail "Graceful: telnet: ${telnetip}: FAIL" + fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL" else - fn_print_fail_nl "Graceful: telnet: Unknown error" - fn_script_log_fail "Graceful: telnet: Unknown error" + fn_print_error_nl "Graceful: telnet: Unknown error" + fn_script_log_error "Graceful: telnet: Unknown error" fi echo -en "\n" | tee -a "${scriptlog}" echo -en "Telnet output:" | tee -a "${scriptlog}" @@ -135,9 +135,9 @@ fn_stop_graceful_sdtd(){ echo -en "\n\n" | tee -a "${scriptlog}" fi else - fn_print_fail "Graceful: telnet: expect not installed: " + fn_print_warn "Graceful: telnet: expect not installed: " fn_print_fail_eol_nl - fn_script_log_fail "Graceful: telnet: expect not installed: FAIL" + fn_script_log_warn "Graceful: telnet: expect not installed: FAIL" fi sleep 1 fn_stop_tmux @@ -159,13 +159,15 @@ fn_stop_ark(){ maxpiditer=15 # The maximum number of times to check if the ark pid has closed gracefully. info_config.sh if [ -z "${queryport}" ]; then - fn_print_warn "no queryport found using info_config.sh" + fn_print_warn "No queryport found using info_config.sh" + fn_script_log_warn "No queryport found using info_config.sh" userconfigfile="${filesdir}" userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini" queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g") fi if [ -z "${queryport}" ]; then - fn_print_warn "no queryport found in the GameUsersettings.ini file" + fn_print_warn "No queryport found in the GameUsersettings.ini file" + fn_script_log_warn "No queryport found in the GameUsersettings.ini file" return fi @@ -178,8 +180,8 @@ fn_stop_ark(){ # check for a valid pid let pid+=0 # turns an empty string into a valid number, '0', # and a valid numeric pid remains unchanged. - if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then - fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck" + if [[ ${pid} -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then + fn_print_dots "Process still bound. Awaiting graceful exit: ${pidcheck}" sleep 1 else break # Our job is done here @@ -188,7 +190,7 @@ fn_stop_ark(){ if [[ ${pidcheck} -eq ${maxpiditer} ]] ; then # The process doesn't want to close after 20 seconds. # kill it hard. - fn_print_warn "Terminating reluctant Ark process: $pid" + fn_print_error "Terminating reluctant Ark process: ${pid}" kill -9 $pid fi fi # end if for port check @@ -205,8 +207,8 @@ fn_stop_teamspeak3(){ fn_print_ok_nl "${servername}" fn_script_log_pass "Stopped ${servername}" else - fn_print_fail_nl "Unable to stop${servername}" - fn_script_log_fail "Unable to stop${servername}" + fn_print_fail_nl "Unable to stop ${servername}" + fn_script_log_fail "Unable to stop ${servername}" fi } @@ -231,7 +233,7 @@ fn_stop_tmux(){ fn_script_log_pass "Stopped ${servername}" else fn_print_fail_nl "Unable to stop${servername}" - fn_script_log_error "Unable to stop${servername}" + fn_script_log_fatal "Unable to stop${servername}" fi } diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 2f99f9b27..4e6e7b18a 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -9,12 +9,12 @@ local commandaction="Validate" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ - fn_print_warn_nl "Validating may overwrite some customised files." - echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate" - sleep 5 + echp -e " * Validating may overwrite some customised files." + echo -en " * https://developer.valvesoftware.com/wiki/SteamCMD#Validate" + sleep 3 echo -en "\n" - fn_print_ok "Checking server files" - fn_script_log_info "Checking server files" + fn_print_dots "Validating files: SteamCMD" + fn_script_log_info "Validating files: SteamCMD" sleep 1 cd "${rootdir}/steamcmd" @@ -28,12 +28,18 @@ fn_validation(){ else ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" fi - + if [ $? =! 0 ]; then + fn_print_fail "Validating files: SteamCMD" + fn_script_log_fatal "Validating files: SteamCMD: FAIL" + else + fn_print_ok "Validating files: SteamCMD" + fn_script_log_pass "Validating files: SteamCMD: OK" + fi fix.sh - fn_script_log_info "Checking complete" + } -fn_print_dots "Checking server files" +fn_print_dots "Validating files" sleep 1 check.sh check_status.sh diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 569bb5f9d..26126d10a 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -33,7 +33,7 @@ fn_dl_md5(){ fn_script_log_fatal "Verifying ${filename} with MD5: FAIL" fn_script_log_info "${filename} returned MD5 checksum: ${md5sumcmd}" fn_script_log_info "Expected MD5 checksum: ${md5}" - exit 1 + core_exit.sh else fn_print_ok_eol_nl fn_script_log_pass "Verifying ${filename} with MD5: OK" @@ -147,7 +147,7 @@ fn_fetch_file(){ if [ -f "${scriptlog}" ]; then fn_script_log_fatal "Curl is not installed!" fi - exit 1 + core_exit.sh fi # make file executecmd if executecmd is set if [ "${executecmd}" == "executecmd" ]; then diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 81175530a..1adf36546 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -17,7 +17,7 @@ if [ "${ansi}" != "off" ]; then magenta="\e[35m" cyan="\e[36m" lightyellow="\e[93m" - # carriage return & Erase to end of line: + # carriage return & erase to end of line creeol="\r\033[K" fi diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 7ab5ba4c7..6560b4490 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -21,7 +21,7 @@ fn_fix_msg_start(){ fn_fix_msg_end(){ if [ $? -ne 0 ]; then - fn_print_fail_nl "Applying ${fixname} fix: ${gamename}" + fn_print_error_nl "Applying ${fixname} fix: ${gamename}" fn_script_log_error "Applying ${fixname} fix: ${gamename}" exitcode=2 else diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 46ff1874f..24a9c9135 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -12,9 +12,9 @@ fn_update_steamcmd_dl(){ check.sh info_config.sh - fn_print_dots "Starting SteamCMD" + fn_print_dots "SteamCMD" sleep 1 - fn_print_ok_nl "Starting SteamCMD" + fn_print_ok_nl "SteamCMD" fn_script_log_info "Starting SteamCMD" cd "${rootdir}/steamcmd" @@ -44,8 +44,8 @@ fn_appmanifest_check(){ # This error is corrected if required. if [ "${appmanifestfilewc}" -ge "2" ]; then sleep 1 - fn_print_warn "Multiple appmanifest_${appid}.acf files found" - fn_script_log_warn "Multiple appmanifest_${appid}.acf files found" + fn_print_error "Multiple appmanifest_${appid}.acf files found" + fn_script_log_error "Multiple appmanifest_${appid}.acf files found" sleep 2 fn_print_dots "Removing x${appmanifestfilewc} appmanifest_${appid}.acf files" sleep 1 @@ -68,8 +68,8 @@ fn_appmanifest_check(){ fn_print_ok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" fn_script_log_pass "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" sleep 1 - fn_print_warn_nl "Forcing update to correct issue" - fn_script_log_warn "Forcing update to correct issue" + fn_print_info_nl "Forcing update to correct issue" + fn_script_log_info "Forcing update to correct issue" sleep 1 update_dl.sh update_check.sh @@ -81,8 +81,8 @@ fn_appmanifest_check(){ core_exit.sh fi forceupdate=1 - fn_print_warn "No appmanifest_${appid}.acf found" - fn_script_log_warn "No appmanifest_${appid}.acf found" + fn_print_error "No appmanifest_${appid}.acf found" + fn_script_log_error "No appmanifest_${appid}.acf found" sleep 1 fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index e10b1cbac..86c29e6ef 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -29,13 +29,13 @@ fn_update_ts3_currentbuild(){ # Gets currentbuild info # Checks currentbuild info is available, if fails a server restart will be forced to generate logs. if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then - fn_print_fail "Checking for update: teamspeak.com" + fn_print_error "Checking for update: teamspeak.com" sleep 1 - fn_print_fail_nl "Checking for update: teamspeak.com: No logs with server version found" - fn_script_log_warn "Checking for update: teamspeak.com: No logs with server version found" + fn_print_error_nl "Checking for update: teamspeak.com: No logs with server version found" + fn_script_log_error "Checking for update: teamspeak.com: No logs with server version found" sleep 2 fn_print_info_nl "Checking for update: teamspeak.com: Forcing server restart" - fn_script_log_warn "Checking for update: teamspeak.com: Forcing server restart" + fn_script_log_info "Checking for update: teamspeak.com: Forcing server restart" sleep 2 exitbypass=1 command_stop.sh From bc48e9c43e375bedc4dc27cd468712677916ddd2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 02:52:40 +0100 Subject: [PATCH 139/195] no longer required --- lgsm/functions/install_ts3.sh | 82 ----------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 lgsm/functions/install_ts3.sh diff --git a/lgsm/functions/install_ts3.sh b/lgsm/functions/install_ts3.sh deleted file mode 100644 index 3f136f802..000000000 --- a/lgsm/functions/install_ts3.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# LGSM install_ts3.sh function -# Author: Daniel Gibbs -# Website: https://gameservermanagers.com - -local commandnane="INSTALL" -local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" - -info_distro.sh -# Gets the teamspeak server architecture -if [ "${arch}" == "x86_64" ]; then - ts3arch="amd64" -elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then - ts3arch="x86" -else - fn_print_failure "${arch} is an unsupported architecture" - exit 1 -fi - -# Grabs all version numbers but not in correct order -wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp - -# Sort version numbers -cat .ts3_version_numbers_unsorted.tmp | sort -r --version-sort -o .ts3_version_numbers_sorted.tmp - -# Finds directory with most recent server version. -while read ts3_version_number; do - wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" - if [ $? -eq 0 ]; then - availablebuild="${ts3_version_number}" - # Break while-loop, if the latest release could be found - break - fi -done < .ts3_version_numbers_sorted.tmp - -# Tidy up -rm -f ".ts3_version_numbers_unsorted.tmp" -rm -f ".ts3_version_numbers_sorted.tmp" - -# Checks availablebuild info is available -if [ -z "${availablebuild}" ]; then - fn_print_fail "Checking for update: teamspeak.com" - sleep 1 - fn_print_fail "Checking for update: teamspeak.com: Not returning version info" - sleep 2 - exit 1 -fi - -echo "" -echo "Installing ${gamename} Server" -echo "=================================" -cd "${rootdir}" -echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" -wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq -sleep 1 -echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c" -tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> ".${servicename}-tar-error.tmp" -local status=$? -if [ ${status} -eq 0 ]; then - echo "OK" -else - echo "FAIL - Exit status ${status}" - sleep 1 - cat ".${servicename}-tar-error.tmp" - rm ".${servicename}-tar-error.tmp" - exit $? -fi -echo -e "copying to ${filesdir}...\c" -cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp" -local status=$? -if [ ${status} -eq 0 ]; then - echo "OK" -else - echo "FAIL - Exit status ${status}" - sleep 1 - cat ".${servicename}-cp-error.tmp" - rm ".${servicename}-cp-error.tmp" - exit $? -fi -rm -f "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" -rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}" From 4697448b8b00aaef8fb4de5031cec75347221094 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 02:54:41 +0100 Subject: [PATCH 140/195] messages --- lgsm/functions/command_validate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 4e6e7b18a..b22cf77e1 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -13,7 +13,7 @@ fn_validation(){ echo -en " * https://developer.valvesoftware.com/wiki/SteamCMD#Validate" sleep 3 echo -en "\n" - fn_print_dots "Validating files: SteamCMD" + fn_print_dots_nl "Validating files: SteamCMD" fn_script_log_info "Validating files: SteamCMD" sleep 1 From f75db0d25682bd703173abc450e08a7604fa437c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 03:00:42 +0100 Subject: [PATCH 141/195] messages --- lgsm/functions/update_steamcmd.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 24a9c9135..353309500 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -100,15 +100,16 @@ fn_update_request_log(){ requestrestart=$(grep -Ec "MasterRequestRestart" "${consolelog}") if [ "${requestrestart}" -ge "1" ]; then fn_print_ok_nl "Checking for update: Server logs: Update requested" + fn_script_log_pass "Checking for update: Server logs: Update requested" sleep 1 echo "" - echo -ne "Applying update.\r" + echo -en "Applying update.\r" sleep 1 - echo -ne "Applying update..\r" + echo -en "Applying update..\r" sleep 1 - echo -ne "Applying update...\r" + echo -en "Applying update...\r" sleep 1 - echo -ne "\n" + echo -en "\n" unset updateonstart check_status.sh @@ -168,6 +169,8 @@ fn_update_steamcmd_check(){ fi if [ "${currentbuild}" != "${availablebuild}" ]; then + fn_print_ok "Checking for update: SteamCMD: Update available" + fn_script_log_pass "Checking for update: SteamCMD: Update available" echo -e "\n" echo -e "Update available:" sleep 1 @@ -203,13 +206,14 @@ fn_update_steamcmd_check(){ alert="update" alert.sh else + fn_print_ok "Checking for update: SteamCMD: No update available" + fn_script_log_pass "Checking for update: SteamCMD: No update available" echo -e "\n" echo -e "No update available:" echo -e " Current version: ${green}${currentbuild}${default}" echo -e " Available version: ${green}${availablebuild}${default}" echo -e " https://steamdb.info/app/${appid}/" echo -e "" - fn_print_ok_nl ": Checking for update: No update available" fn_script_log_info "Current build: ${currentbuild}" fn_script_log_info "Available build: ${availablebuild}" fi From 7b49a8dd39e8da36c3380c457e1360eb4670d0d8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 03:02:09 +0100 Subject: [PATCH 142/195] bugs --- lgsm/functions/command_validate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index b22cf77e1..2279e65a7 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -9,7 +9,7 @@ local commandaction="Validate" local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ - echp -e " * Validating may overwrite some customised files." + echo -e " * Validating may overwrite some customised files." echo -en " * https://developer.valvesoftware.com/wiki/SteamCMD#Validate" sleep 3 echo -en "\n" @@ -28,7 +28,7 @@ fn_validation(){ else ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" fi - if [ $? =! 0 ]; then + if [ $? != 0 ]; then fn_print_fail "Validating files: SteamCMD" fn_script_log_fatal "Validating files: SteamCMD: FAIL" else From 46941def99c57a8b6e850c9ab11c3ba09186409f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 18:43:37 +0100 Subject: [PATCH 143/195] function_selfname + fixes --- functions/command_update_functions.sh | 2 +- lgsm/functions/alert.sh | 12 +++++------ lgsm/functions/alert_email.sh | 6 +++--- lgsm/functions/alert_pushbullet.sh | 4 ++-- lgsm/functions/check.sh | 24 ++++++++++------------ lgsm/functions/check_config.sh | 4 ++-- lgsm/functions/check_deps.sh | 12 +++++------ lgsm/functions/check_glibc.sh | 6 ++---- lgsm/functions/check_ip.sh | 4 ++-- lgsm/functions/check_logs.sh | 4 ++-- lgsm/functions/check_permissions.sh | 18 ++++++++-------- lgsm/functions/check_root.sh | 4 ++-- lgsm/functions/check_status.sh | 6 +++--- lgsm/functions/check_steamcmd.sh | 10 ++++----- lgsm/functions/check_system_dir.sh | 4 ++-- lgsm/functions/check_tmux.sh | 4 ++-- lgsm/functions/command_backup.sh | 4 ++-- lgsm/functions/command_console.sh | 8 ++++---- lgsm/functions/command_debug.sh | 4 ++-- lgsm/functions/command_details.sh | 4 ++-- lgsm/functions/command_dev_debug.sh | 6 +++--- lgsm/functions/command_dev_detect_deps.sh | 6 +++--- lgsm/functions/command_fastdl.sh | 6 +++--- lgsm/functions/command_install.sh | 6 +++--- lgsm/functions/command_monitor.sh | 4 ++-- lgsm/functions/command_restart.sh | 4 ++-- lgsm/functions/command_start.sh | 4 ++-- lgsm/functions/command_stop.sh | 4 ++-- lgsm/functions/command_test_alert.sh | 4 ++-- lgsm/functions/command_ts3_server_pass.sh | 4 ++-- lgsm/functions/command_update.sh | 4 ++-- lgsm/functions/command_update_functions.sh | 2 +- lgsm/functions/command_validate.sh | 4 ++-- lgsm/functions/compress_unreal2_maps.sh | 2 +- lgsm/functions/compress_ut99_maps.sh | 2 +- lgsm/functions/core_dl.sh | 4 ++-- lgsm/functions/core_exit.sh | 12 +++++------ lgsm/functions/core_getopt.sh | 2 +- lgsm/functions/core_messages.sh | 2 +- lgsm/functions/fix.sh | 9 ++++---- lgsm/functions/fix_arma3.sh | 4 ++-- lgsm/functions/fix_csgo.sh | 4 ++-- lgsm/functions/fix_dst.sh | 4 ++-- lgsm/functions/fix_glibc.sh | 4 ++-- lgsm/functions/fix_ins.sh | 6 ++---- lgsm/functions/fix_kf.sh | 4 ++-- lgsm/functions/fix_ro.sh | 4 ++-- lgsm/functions/fix_steamcmd.sh | 4 ++-- lgsm/functions/fix_ut2k4.sh | 4 ++-- lgsm/functions/fix_ut99.sh | 4 ++-- lgsm/functions/fn_functions | 2 +- lgsm/functions/fn_getopt | 2 +- lgsm/functions/fn_update_functions | 2 +- lgsm/functions/info_config.sh | 2 +- lgsm/functions/info_distro.sh | 2 +- lgsm/functions/info_glibc.sh | 2 +- lgsm/functions/info_parms.sh | 2 +- lgsm/functions/install_complete.sh | 4 ++-- lgsm/functions/install_config.sh | 4 ++-- lgsm/functions/install_gslt.sh | 4 ++-- lgsm/functions/install_gsquery.sh | 4 ++-- lgsm/functions/install_header.sh | 4 ++-- lgsm/functions/install_logs.sh | 4 ++-- lgsm/functions/install_retry.sh | 4 ++-- lgsm/functions/install_server_dir.sh | 6 +++--- lgsm/functions/install_server_files.sh | 4 ++-- lgsm/functions/install_steamcmd.sh | 4 ++-- lgsm/functions/install_ts3db.sh | 6 +++--- lgsm/functions/install_ut2k4_key.sh | 4 ++-- lgsm/functions/logs.sh | 6 ++---- lgsm/functions/monitor_gsquery.sh | 4 ++-- lgsm/functions/update_steamcmd.sh | 6 +++--- lgsm/functions/update_ts3.sh | 6 +++--- 73 files changed, 174 insertions(+), 191 deletions(-) diff --git a/functions/command_update_functions.sh b/functions/command_update_functions.sh index 31b9672b7..0c35eb1f0 100644 --- a/functions/command_update_functions.sh +++ b/functions/command_update_functions.sh @@ -6,7 +6,7 @@ lgsm_version="210516" # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh fn_print_dots "Updating functions" fn_script_log "Updating functions" diff --git a/lgsm/functions/alert.sh b/lgsm/functions/alert.sh index 4242d6e8c..206abba22 100644 --- a/lgsm/functions/alert.sh +++ b/lgsm/functions/alert.sh @@ -4,10 +4,8 @@ # Website: https://gameservermanagers.com # Description: Overall function for managing alerts. -local commandnane="ALERT" +local commandname="ALERT" local commandaction="Alert" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_alert_test(){ fn_script_log_info "Sending test alert" @@ -45,20 +43,20 @@ fi if [ "${emailnotification}" == "on" ]||[ "${emailalert}" == "on" ]&&[ -n "${email}" ]; then alert_email.sh -elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then +elif [ "${emailnotification}" != "on" ]||[ "${emailalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_warn_nl "Email alerts not enabled" fn_script_log_warn "Email alerts not enabled" -elif [ -z "${email}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then +elif [ -z "${email}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_error_nl "Email not set" fn_script_log_error "Email not set" fi if [ "${pushbulletalert}" == "on" ]&&[ -n "${pushbullettoken}" ]; then alert_pushbullet.sh -elif [ "${pushbulletalert}" != "on" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then +elif [ "${pushbulletalert}" != "on" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_warn_nl "Pushbullet alerts not enabled" fn_script_log_warn "Pushbullet alerts not enabled" -elif [ -z "${pushbullettoken}" ]&&[ "${selfname}" == "command_test_alert.sh" ]; then +elif [ -z "${pushbullettoken}" ]&&[ "${function_selfname}" == "command_test_alert.sh" ]; then fn_print_error_nl "Pushbullet token not set" fn_script_error_warn "Pushbullet token not set" fi \ No newline at end of file diff --git a/lgsm/functions/alert_email.sh b/lgsm/functions/alert_email.sh index 273861670..e0d84b255 100644 --- a/lgsm/functions/alert_email.sh +++ b/lgsm/functions/alert_email.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM email.sh function +# LGSM alert_email.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Sends email alert if monitor picks up a failure. -local commandnane="ALERT" +local commandname="ALERT" local commandaction="Alert" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_details_email(){ # diff --git a/lgsm/functions/alert_pushbullet.sh b/lgsm/functions/alert_pushbullet.sh index 2b2bca093..e8e65c607 100644 --- a/lgsm/functions/alert_pushbullet.sh +++ b/lgsm/functions/alert_pushbullet.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: alerts using pushbullet. -local commandnane="ALERT" +local commandname="ALERT" local commandaction="Alert" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Sending Pushbullet alert" sleep 1 diff --git a/lgsm/functions/check.sh b/lgsm/functions/check.sh index 4b82e1cc4..cc5df5a42 100644 --- a/lgsm/functions/check.sh +++ b/lgsm/functions/check.sh @@ -1,14 +1,12 @@ #!/bin/bash -# LGSM fn_check function +# LGSM check.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Overall function for managing checks. # Runs checks that will either halt on or fix an issue. -local commandnane="CHECK" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" # Every command that requires checks just references check.sh # check.sh selects which checks to run by using arrays @@ -16,14 +14,14 @@ local commandnane="CHECK" check_root.sh check_permissions.sh -if [ "${selfname}" != "command_install.sh" ] && [ "${selfname}" != "command_update_functions.sh" ]; then +if [ "${function_selfname}" != "command_install.sh" ] && [ "${function_selfname}" != "command_update_functions.sh" ]; then check_system_dir.sh fi local allowed_commands_array=( command_debug.sh command_start.sh command_install.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_glibc.sh fi done @@ -31,7 +29,7 @@ done local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh command_update_functions.sh command_email_test.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_logs.sh fi done @@ -39,7 +37,7 @@ done local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_deps.sh fi done @@ -47,7 +45,7 @@ done local allowed_commands_array=( command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_ip.sh fi done @@ -55,7 +53,7 @@ done local allowed_commands_array=( update_check.sh command_debug.sh command_start.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then if [ -n "${appid}" ]; then check_steamcmd.sh fi @@ -65,7 +63,7 @@ done local allowed_commands_array=( command_console.sh command_start.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_tmux.sh fi done @@ -73,7 +71,7 @@ done local allowed_commands_array=( command_console.sh command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_config.sh fi done @@ -81,7 +79,7 @@ done local allowed_commands_array=( command_details.sh command_monitor.sh command_start.sh command_stop.sh command_ts3_server_pass.sh update_check.sh command_details.sh command_validate.sh ) for allowed_command in "${allowed_commands_array[@]}" do - if [ "${allowed_command}" == "${selfname}" ]; then + if [ "${allowed_command}" == "${function_selfname}" ]; then check_status.sh fi done diff --git a/lgsm/functions/check_config.sh b/lgsm/functions/check_config.sh index a4061dd40..b42c47d9d 100644 --- a/lgsm/functions/check_config.sh +++ b/lgsm/functions/check_config.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: If server config missing warn user. -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -e "${servercfgfullpath}" ]; then if [ "${gamename}" != "Hurtworld" ]; then diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 6a5ad2623..b0c7c6d7c 100644 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -4,9 +4,7 @@ # Website: https://gameservermanagers.com # Description: Checks that the requires dependencies are installed for LGSM. -local commandnane="CHECK" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" fn_deps_detector(){ # Checks if dependency is missing @@ -19,14 +17,14 @@ fn_deps_detector(){ fi if [ "${depstatus}" == "0" ]; then missingdep=0 - if [ "${selfname}" == "command_install.sh" ]; then + if [ "${function_selfname}" == "command_install.sh" ]; then echo -e "${green}${deptocheck}${default}" sleep 0.5 fi else # if missing dependency is found missingdep=1 - if [ "${selfname}" == "command_install.sh" ]; then + if [ "${function_selfname}" == "command_install.sh" ]; then echo -e "${red}${deptocheck}${default}" sleep 0.5 fi @@ -104,7 +102,7 @@ fn_found_missing_deps(){ fi echo "" fi - if [ "${selfname}" == "command_install.sh" ]; then + if [ "${function_selfname}" == "command_install.sh" ]; then sleep 5 fi fi @@ -123,7 +121,7 @@ fn_check_loop(){ info_distro.sh -if [ "${selfname}" == "command_install.sh" ]; then +if [ "${function_selfname}" == "command_install.sh" ]; then echo "" echo "Checking Dependecies" echo "=================================" diff --git a/lgsm/functions/check_glibc.sh b/lgsm/functions/check_glibc.sh index 259ac9561..8b0fe339c 100644 --- a/lgsm/functions/check_glibc.sh +++ b/lgsm/functions/check_glibc.sh @@ -4,9 +4,7 @@ # Website: https://gameservermanagers.com # Description: Checks if server has correct glibc or has a fix available. -local commandnane="CHECK" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" info_glibc.sh info_distro.sh @@ -21,7 +19,7 @@ elif [ "${glibcrequired}" == "UNKNOWN" ]; then echo -e " * glibc installed: ${glibcversion}" elif [ "$(printf '%s\n'${glibcrequired}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibcrequired}" ]; then if [ "${glibcfix}" == "yes" ]; then - if [ "${selfname}" != "command_install.sh" ]; then + if [ "${function_selfname}" != "command_install.sh" ]; then fn_print_dots "Glibc fix" sleep 0.5 fn_print_info_nl "Glibc fix: ${green}Using Glibc fix${default}" diff --git a/lgsm/functions/check_ip.sh b/lgsm/functions/check_ip.sh index ab2fa3768..5375bcac6 100644 --- a/lgsm/functions/check_ip.sh +++ b/lgsm/functions/check_ip.sh @@ -5,8 +5,8 @@ # Description: Automatically identifies the server interface IP. # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0". -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" != "Teamspeak 3" ]; then if [ ! -f "/bin/ip" ]; then diff --git a/lgsm/functions/check_logs.sh b/lgsm/functions/check_logs.sh index b8474ca6b..3012203fb 100644 --- a/lgsm/functions/check_logs.sh +++ b/lgsm/functions/check_logs.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: Checks that log files exist on server start -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Create dir's for the script and console logs if [ ! -d "${scriptlogdir}" ]||[ ! -d "${consolelogdir}" ]&&[ "${gamename}" != "Teamspeak 3" ]; then diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index de912b403..77622c690 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -5,9 +5,7 @@ # Website: https://gameservermanagers.com # Description: Checks script, files and folders ownership and permissions. -local commandnane="CHECK" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" # Useful variables currentuser="$(whoami)" @@ -17,12 +15,12 @@ conclusionpermissionerror="0" fn_check_ownership(){ # Check script ownership - #if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then - # fn_print_fail_nl "Oops ! Ownership issue..." - # echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" - # echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" - # exit 1 - #fi + if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then + fn_print_fail_nl "Oops ! Ownership issue..." + echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" + echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" + exit 1 + fi # Check rootdir ownership if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then @@ -98,4 +96,4 @@ fn_check_permissions_conclusion(){ fn_check_ownership fn_check_permissions -fn_check_permissions_conclusion +fn_check_permissions_conclusion \ No newline at end of file diff --git a/lgsm/functions/check_root.sh b/lgsm/functions/check_root.sh index 31c55a63a..903075c29 100644 --- a/lgsm/functions/check_root.sh +++ b/lgsm/functions/check_root.sh @@ -3,8 +3,8 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ $(whoami) = "root" ]; then fn_print_fail_nl "Do NOT run this script as root!" diff --git a/lgsm/functions/check_status.sh b/lgsm/functions/check_status.sh index 3399d07b4..f82d75b58 100644 --- a/lgsm/functions/check_status.sh +++ b/lgsm/functions/check_status.sh @@ -1,11 +1,11 @@ #!/bin/bash -# LGSM check_status function +# LGSM check_status.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Checks the proccess status of the server. Either online or offline. -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Teamspeak 3" ]; then # 1: Server is running diff --git a/lgsm/functions/check_steamcmd.sh b/lgsm/functions/check_steamcmd.sh index 695ba5592..99be7cdba 100644 --- a/lgsm/functions/check_steamcmd.sh +++ b/lgsm/functions/check_steamcmd.sh @@ -4,9 +4,7 @@ # Website: https://gameservermanagers.com # Description: Checks SteamCMD is installed and correct. -local commandnane="CHECK" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" fn_install_steamcmd(){ if [ ! -d "${steamcmddir}" ]; then @@ -45,7 +43,7 @@ fn_check_steamcmd_sh(){ # Installs if missing. steamcmddir="${rootdir}/steamcmd" if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then - if [ "${selfname}" == "command_install.sh" ]; then + if [ "${function_selfname}" == "command_install.sh" ]; then fn_install_steamcmd else fn_print_error_nl "SteamCMD is missing" @@ -53,14 +51,14 @@ fn_check_steamcmd_sh(){ sleep 1 fn_install_steamcmd fi - elif [ "${selfname}" == "command_install.sh" ]; then + elif [ "${function_selfname}" == "command_install.sh" ]; then fn_print_infomation "SteamCMD is already installed..." fn_print_ok_eol_nl fi } fn_check_steamcmd_guard(){ - if [ "${selfname}" == "command_update.sh" ]||[ "${selfname}" == "command_validate.sh" ]; then + if [ "${function_selfname}" == "command_update.sh" ]||[ "${function_selfname}" == "command_validate.sh" ]; then # Checks that steamcmd is working correctly and will prompt Steam Guard if required. "${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit if [ $? -ne 0 ]; then diff --git a/lgsm/functions/check_system_dir.sh b/lgsm/functions/check_system_dir.sh index 26a4506b5..9c6448ca1 100644 --- a/lgsm/functions/check_system_dir.sh +++ b/lgsm/functions/check_system_dir.sh @@ -3,8 +3,8 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ ! -d "${systemdir}" ]; then fn_print_fail_nl "Cannot access ${systemdir}: No such directory" diff --git a/lgsm/functions/check_tmux.sh b/lgsm/functions/check_tmux.sh index c3680d5fa..3af90a4b6 100644 --- a/lgsm/functions/check_tmux.sh +++ b/lgsm/functions/check_tmux.sh @@ -4,8 +4,8 @@ # Website: https://gameservermanagers.com # Description: Checks if tmux is installed as too many users do not RTFM or know how to use Google. -local commandnane="CHECK" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local commandname="CHECK" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "$(command -v tmux)" ]||[ "$(which tmux >/dev/null 2>&1)" ]||[ -f "/usr/bin/tmux" ]||[ -f "/bin/tmux" ]; then : diff --git a/lgsm/functions/command_backup.sh b/lgsm/functions/command_backup.sh index 7ddeb8bc6..4c9a1b39d 100644 --- a/lgsm/functions/command_backup.sh +++ b/lgsm/functions/command_backup.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Creates a .tar.gz file in the backup directory. -local commandnane="BACKUP" +local commandname="BACKUP" local commandaction="Backup" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh info_distro.sh diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index b23a3a06b..dbd8a58f9 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Gives access to the server tmux console. -local commandnane="CONSOLE" +local commandname="CONSOLE" local commandaction="Console" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh echo "" @@ -29,11 +29,11 @@ sleep 1 check_status.sh if [ "${status}" != "0" ]; then fn_print_ok_nl "Accessing console" - fn_script_log_info "Console accessed" + fn_script_log_pass "Console accessed" sleep 1 tmux attach-session -t ${servicename} fn_print_ok_nl "Closing console" - fn_script_log_info "Console closed" + fn_script_log_pass "Console closed" else fn_print_error_nl "Server not running" fn_script_log_error "Failed to access: Server not running" diff --git a/lgsm/functions/command_debug.sh b/lgsm/functions/command_debug.sh index 3be89db87..a83defc3d 100644 --- a/lgsm/functions/command_debug.sh +++ b/lgsm/functions/command_debug.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Runs the server without tmux. Runs direct from the terminal. -local commandnane="DEBUG" +local commandname="DEBUG" local commandaction="Debug" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Trap to remove lockfile on quit. fn_lockfile_trap(){ diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 9374ec869..2072835be 100644 --- a/lgsm/functions/command_details.sh +++ b/lgsm/functions/command_details.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Displays server infomation. -local commandnane="DETAILS" +local commandname="DETAILS" local commandaction="Details" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Standard Details # This applies to all engines diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 81548309c..08d31e976 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM dev_debug.sh function +# LGSM command_dev_debug.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Dev only: enables debuging log to be saved to dev-debug.log. -local commandnane="DEV-DEBUG" +local commandname="DEV-DEBUG" local commandaction="Dev-Debug" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ -f ".dev-debug" ]; then diff --git a/lgsm/functions/command_dev_detect_deps.sh b/lgsm/functions/command_dev_detect_deps.sh index ab8e4a43d..c29fdc33a 100644 --- a/lgsm/functions/command_dev_detect_deps.sh +++ b/lgsm/functions/command_dev_detect_deps.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM fn_dep_detect function +# LGSM command_dev_detect_deps.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Detects dependencies the server binary requires. -local commandnane="DEPS-DETECT" +local commandname="DEPS-DETECT" local commandaction="Deps-Detect" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh cd "${executabledir}" diff --git a/lgsm/functions/command_fastdl.sh b/lgsm/functions/command_fastdl.sh index 5c5eed3dc..ac0cd0fa6 100644 --- a/lgsm/functions/command_fastdl.sh +++ b/lgsm/functions/command_fastdl.sh @@ -1,13 +1,13 @@ #!/bin/bash -# LGSM command_fastdl function +# LGSM command_fastdl.sh function # Author: Daniel Gibbs # Contributor: UltimateByte # Website: https://gameservermanagers.com # Description: Creates a FastDL folder -local commandnane="FASTDL" +local commandname="FASTDL" local commandaction="FastDL" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index b57a22a42..1f1022f9f 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM fn_install function +# LGSM command_install.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Overall function for the installer. -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh install_header.sh diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index 3d2cbc965..b58340911 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -5,9 +5,9 @@ # Description: Monitors server by checking for running proccesses # then passes to monitor_gsquery.sh. -local commandnane="MONITOR" +local commandname="MONITOR" local commandaction="Monitor" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_monitor_check_lockfile(){ # Monitor does not run it lockfile is not found diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 1753e6ed7..06da6afb6 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Starts the server. -local commandnane="RESTART" +local commandname="RESTART" local commandaction="Restarting" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" info_config.sh exitbypass=1 diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 4a4757590..26689c29a 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Starts the server. -local commandnane="START" +local commandname="START" local commandaction="Starting" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_start_teamspeak3(){ if [ ! -e "${servercfgfullpath}" ]; then diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 666326c9b..f1c333dee 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Stops the server. -local commandnane="STOP" +local commandname="STOP" local commandaction="Stopping" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Attempts Graceful of source using rcon 'quit' command. fn_stop_graceful_source(){ diff --git a/lgsm/functions/command_test_alert.sh b/lgsm/functions/command_test_alert.sh index c9e17785c..3f66c6400 100644 --- a/lgsm/functions/command_test_alert.sh +++ b/lgsm/functions/command_test_alert.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Sends a test email alert. -local commandnane="ALERT" +local commandname="ALERT" local commandaction="Alert" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "${servername}" sleep 1 diff --git a/lgsm/functions/command_ts3_server_pass.sh b/lgsm/functions/command_ts3_server_pass.sh index 0419bf181..bc65de444 100644 --- a/lgsm/functions/command_ts3_server_pass.sh +++ b/lgsm/functions/command_ts3_server_pass.sh @@ -5,9 +5,9 @@ # Website: https://gameservermanagers.com # Description: Changes TS3 serveradmin password -local commandnane="TS3-CHANGE-PASS" +local commandname="TS3-CHANGE-PASS" local commandaction="TS3 Change Password" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_serveradmin_password_prompt(){ diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index d06608a8f..e0fde4a0b 100644 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Handles updating of servers. -local commandnane="UPDATE" +local commandname="UPDATE" local commandaction="Update" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "" sleep 0.5 diff --git a/lgsm/functions/command_update_functions.sh b/lgsm/functions/command_update_functions.sh index 756185aba..0c9c7b803 100644 --- a/lgsm/functions/command_update_functions.sh +++ b/lgsm/functions/command_update_functions.sh @@ -5,7 +5,7 @@ # Description: Deletes the functions dir to allow re-downloading of functions from GitHub. local commandaction="Update LGSM" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_print_dots "Updating functions" sleep 1 diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index 2279e65a7..de97c4a70 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Runs a server validation. -local commandnane="VALIDATE" +local commandname="VALIDATE" local commandaction="Validate" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_validation(){ echo -e " * Validating may overwrite some customised files." diff --git a/lgsm/functions/compress_unreal2_maps.sh b/lgsm/functions/compress_unreal2_maps.sh index 415e82c24..0b42b883e 100644 --- a/lgsm/functions/compress_unreal2_maps.sh +++ b/lgsm/functions/compress_unreal2_maps.sh @@ -5,7 +5,7 @@ # Description: compresses unreal maps local commandaction="Unreal Map Compressor" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/compress_ut99_maps.sh b/lgsm/functions/compress_ut99_maps.sh index a6ce63495..899b597d5 100644 --- a/lgsm/functions/compress_ut99_maps.sh +++ b/lgsm/functions/compress_ut99_maps.sh @@ -5,7 +5,7 @@ # Description: compresses unreal maps local commandaction="Unreal Map Compressor" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" check.sh clear diff --git a/lgsm/functions/core_dl.sh b/lgsm/functions/core_dl.sh index 26126d10a..2b1ff8053 100644 --- a/lgsm/functions/core_dl.sh +++ b/lgsm/functions/core_dl.sh @@ -16,9 +16,9 @@ # fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}" # fn_fetch_file "http://example.com/file.tar.bz2" "/some/dir" "file.tar.bz2" "executecmd" "run" "force" "10cd7353aa9d758a075c600a6dd193fd" -local commandnane="DOWNLOAD" +local commandname="DOWNLOAD" local commandaction="Download" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dl_md5(){ # Runs MD5 Check if available diff --git a/lgsm/functions/core_exit.sh b/lgsm/functions/core_exit.sh index ae5e7a62e..13f4a5cc5 100644 --- a/lgsm/functions/core_exit.sh +++ b/lgsm/functions/core_exit.sh @@ -7,7 +7,7 @@ fn_exit_dev_debug(){ if [ -f "${rootdir}/.dev-debug" ]; then echo "" - echo "${selfname} exiting with code: ${exitcode}" + echo "${function_selfname} exiting with code: ${exitcode}" fi } @@ -15,13 +15,13 @@ if [ -n "${exitbypass}" ]; then unset exitbypass elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then if [ "${exitcode}" == "1" ]; then - fn_script_log_fatal "${selfname} exiting with code: ${exitcode}" + fn_script_log_fatal "${function_selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "2" ]; then - fn_script_log_error "${selfname} exiting with code: ${exitcode}" + fn_script_log_error "${function_selfname} exiting with code: ${exitcode}" elif [ "${exitcode}" == "3" ]; then - fn_script_log_warn "${selfname} exiting with code: ${exitcode}" + fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" else - fn_script_log_warn "${selfname} exiting with code: ${exitcode}" + fn_script_log_warn "${function_selfname} exiting with code: ${exitcode}" fi fn_exit_dev_debug # remove trap. @@ -29,7 +29,7 @@ elif [ -n "${exitcode}" ]&&[ "${exitcode}" != "0" ]; then exit ${exitcode} else exitcode=0 - fn_script_log_pass "${selfname} exiting with code: ${exitcode}" + fn_script_log_pass "${function_selfname} exiting with code: ${exitcode}" fn_exit_dev_debug # remove trap. trap - INT diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index c9dcddf05..772a5a4b3 100644 --- a/lgsm/functions/core_getopt.sh +++ b/lgsm/functions/core_getopt.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: getopt arguments. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_getopt_generic(){ case "${getopt}" in diff --git a/lgsm/functions/core_messages.sh b/lgsm/functions/core_messages.sh index 1adf36546..3efc7a41f 100644 --- a/lgsm/functions/core_messages.sh +++ b/lgsm/functions/core_messages.sh @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM fn_messages function +# LGSM core_messages.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description: Defines on-screen messages such as [ OK ] and how script logs look. diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 6560b4490..706beac15 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -5,10 +5,9 @@ # Description: Overall function for managing fixes. # Runs functions that will fix an issue. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -# Cannot have selfname as breaks if statements. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Messages that are displayed for some fixes fn_fix_msg_start(){ @@ -32,7 +31,7 @@ fn_fix_msg_end(){ # Fixes that are run on start -if [ "${selfname}" != "command_install.sh" ]; then +if [ "${function_selfname}" != "command_install.sh" ]; then if [ -n "${appid}" ]; then fix_steamcmd.sh fi @@ -53,7 +52,7 @@ if [ "${selfname}" != "command_install.sh" ]; then fi # Fixes that are run on install only. -if [ "${selfname}" == "command_install.sh" ]; then +if [ "${function_selfname}" == "command_install.sh" ]; then if [ "${gamename}" == "Killing Floor" ]; then echo "" echo "Applying ${gamename} Server Fixes" diff --git a/lgsm/functions/fix_arma3.sh b/lgsm/functions/fix_arma3.sh index adf3fcfc6..e1bb4abcc 100644 --- a/lgsm/functions/fix_arma3.sh +++ b/lgsm/functions/fix_arma3.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves an issue with ARMA3. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: 20150 Segmentation fault (core dumped) error. if [ ! -d "${HOME}/.local/share/Arma 3" ]||[ ! -d "${HOME}/.local/share/Arma 3 - Other Profiles" ]; then diff --git a/lgsm/functions/fix_csgo.sh b/lgsm/functions/fix_csgo.sh index acca65918..a98d9e17e 100644 --- a/lgsm/functions/fix_csgo.sh +++ b/lgsm/functions/fix_csgo.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with csgo. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: server not always creating steam_appid.txt file. if [ ! -f "${filesdir}/steam_appid.txt" ]; then diff --git a/lgsm/functions/fix_dst.sh b/lgsm/functions/fix_dst.sh index 99d4a65f0..2ffb0a354 100644 --- a/lgsm/functions/fix_dst.sh +++ b/lgsm/functions/fix_dst.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Dont Starve together. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: ./dontstarve_dedicated_server_nullrenderer: ./lib32/libcurl-gnutls.so.4: no version information available (required by ./dontstarve_dedicated_server_nullrenderer) # Issue only occures on CentOS as libcurl-gnutls.so.4 is called libcurl.so.4 on CentOS. diff --git a/lgsm/functions/fix_glibc.sh b/lgsm/functions/fix_glibc.sh index 34811136f..f9606bdc9 100644 --- a/lgsm/functions/fix_glibc.sh +++ b/lgsm/functions/fix_glibc.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Downloads required glibc files and applys teh glibc fix if required -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" local libstdc_servers_array=( "ARMA 3" "Blade Symphony" "Garry's Mod" "Just Cause 2" ) for libstdc_server in "${libstdc_servers_array[@]}" diff --git a/lgsm/functions/fix_ins.sh b/lgsm/functions/fix_ins.sh index 210662964..2fab8f8ae 100644 --- a/lgsm/functions/fix_ins.sh +++ b/lgsm/functions/fix_ins.sh @@ -4,10 +4,8 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Insurgency. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -# Cannot have selfname as breaks if statement. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: ./srcds_linux: error while loading shared libraries: libtier0.so: cannot open shared object file: No such file or directory. @@ -15,7 +13,7 @@ export LD_LIBRARY_PATH=${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH} # Fixes: issue #529 - gamemode not passed to debug or start. -if [ "${selfname}" == "command_debug.sh" ]; then +if [ "${function_selfname}" == "command_debug.sh" ]; then defaultmap="\"${defaultmap}\"" else defaultmap="\\\"${defaultmap}\\\"" diff --git a/lgsm/functions/fix_kf.sh b/lgsm/functions/fix_kf.sh index 3730c0ef8..c08a34341 100644 --- a/lgsm/functions/fix_kf.sh +++ b/lgsm/functions/fix_kf.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Killing Floor. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ro.sh b/lgsm/functions/fix_ro.sh index c17f7e06e..ee28aaf4a 100644 --- a/lgsm/functions/fix_ro.sh +++ b/lgsm/functions/fix_ro.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Red Orchestra. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "Applying WebAdmin ROOst.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_steamcmd.sh b/lgsm/functions/fix_steamcmd.sh index 62f048a73..c4d023ee6 100644 --- a/lgsm/functions/fix_steamcmd.sh +++ b/lgsm/functions/fix_steamcmd.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues related to steamCMD. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Fixes: [S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam,or a local steamclient.so. if [ ! -f "${HOME}/.steam/sdk32/steamclient.so" ]; then diff --git a/lgsm/functions/fix_ut2k4.sh b/lgsm/functions/fix_ut2k4.sh index 1cec482e0..85b2334a7 100644 --- a/lgsm/functions/fix_ut2k4.sh +++ b/lgsm/functions/fix_ut2k4.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Unreal Tournament 2004. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "applying WebAdmin ut2003.css fix." echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13" diff --git a/lgsm/functions/fix_ut99.sh b/lgsm/functions/fix_ut99.sh index 2bca9c8ba..aaa16bbf0 100644 --- a/lgsm/functions/fix_ut99.sh +++ b/lgsm/functions/fix_ut99.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Resolves various issues with Unreal Tournament 99. -local commandnane="FIX" +local commandname="FIX" local commandaction="Fix" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "${servercfgfullpath}" echo "enabling UdpServerUplink." diff --git a/lgsm/functions/fn_functions b/lgsm/functions/fn_functions index 8e1e6c941..ee9891cb6 100644 --- a/lgsm/functions/fn_functions +++ b/lgsm/functions/fn_functions @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM core_functions.sh function +# LGSM fn_functions function # Author: Daniel Gibbs # Website: https://gameservermanagers.com lgsm_version="210516" diff --git a/lgsm/functions/fn_getopt b/lgsm/functions/fn_getopt index a9c766583..cec7b51b4 100644 --- a/lgsm/functions/fn_getopt +++ b/lgsm/functions/fn_getopt @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM core_getopt.sh function +# LGSM fn_getopt function # Author: Daniel Gibbs # Website: https://gameservermanagers.com lgsm_version="210516" diff --git a/lgsm/functions/fn_update_functions b/lgsm/functions/fn_update_functions index 6ebee6652..7c3be31e6 100644 --- a/lgsm/functions/fn_update_functions +++ b/lgsm/functions/fn_update_functions @@ -1,5 +1,5 @@ #!/bin/bash -# LGSM fn_update_functions.sh function +# LGSM fn_update_functions function # Author: Daniel Gibbs # Website: https://gameservermanagers.com lgsm_version="210516" diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 2ed6f0131..deb7367c7 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: Gets specific details from config files. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 5cca70c33..b75499f3d 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -5,7 +5,7 @@ # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for command_details.sh, command_debug.sh and alert.sh. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ### Distro infomation diff --git a/lgsm/functions/info_glibc.sh b/lgsm/functions/info_glibc.sh index 8a02ec78e..2a1adc058 100644 --- a/lgsm/functions/info_glibc.sh +++ b/lgsm/functions/info_glibc.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: stores details on servers Glibc requirements. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Blade Symphony" ]; then glibcrequired="2.15" diff --git a/lgsm/functions/info_parms.sh b/lgsm/functions/info_parms.sh index 3fc2cc92d..d4cba6548 100644 --- a/lgsm/functions/info_parms.sh +++ b/lgsm/functions/info_parms.sh @@ -4,7 +4,7 @@ # Website: https://gameservermanagers.com # Description: Gets specific details from server parameters. -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index ae492f826..a0680bcda 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${gamename}" == "Don't Starve Together" ]; then echo "" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 908e5bf7d..4b7d26cbf 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_defaultconfig(){ echo "creating ${servercfg} config file." diff --git a/lgsm/functions/install_gslt.sh b/lgsm/functions/install_gslt.sh index 5637f6990..f0a706830 100644 --- a/lgsm/functions/install_gslt.sh +++ b/lgsm/functions/install_gslt.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Configures GSLT. -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Game Server Login Token" diff --git a/lgsm/functions/install_gsquery.sh b/lgsm/functions/install_gsquery.sh index 19344c6d3..9878537e0 100644 --- a/lgsm/functions/install_gsquery.sh +++ b/lgsm/functions/install_gsquery.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_dlgsquery(){ cd "${functionsdir}" diff --git a/lgsm/functions/install_header.sh b/lgsm/functions/install_header.sh index 55a9e6481..3f2e5f0e1 100644 --- a/lgsm/functions/install_header.sh +++ b/lgsm/functions/install_header.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" clear echo "=================================" diff --git a/lgsm/functions/install_logs.sh b/lgsm/functions/install_logs.sh index e486f1619..59446681a 100644 --- a/lgsm/functions/install_logs.sh +++ b/lgsm/functions/install_logs.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" if [ "${checklogs}" != "1" ]; then echo "" diff --git a/lgsm/functions/install_retry.sh b/lgsm/functions/install_retry.sh index 3f1bdf26c..661b57f39 100644 --- a/lgsm/functions/install_retry.sh +++ b/lgsm/functions/install_retry.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" while true; do read -e -i "y" -p "Retry install? [Y/n]" yn diff --git a/lgsm/functions/install_server_dir.sh b/lgsm/functions/install_server_dir.sh index a6b37d7e2..2ac93d2fb 100644 --- a/lgsm/functions/install_server_dir.sh +++ b/lgsm/functions/install_server_dir.sh @@ -1,11 +1,11 @@ #!/bin/bash -# LGSM install_serverdir.sh function +# LGSM install_server_dir.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Server Directory" diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index 5ccac8390..d881a2717 100644 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_server_files(){ if [ "${gamename}" == "Unreal Tournament 99" ]; then diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index 5956d1beb..e4e7c7325 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -4,9 +4,9 @@ # Website: https://gameservermanagers.com # Description: Downloads SteamCMD on install. -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Installing SteamCMD" diff --git a/lgsm/functions/install_ts3db.sh b/lgsm/functions/install_ts3db.sh index 9ce622504..90006538f 100644 --- a/lgsm/functions/install_ts3db.sh +++ b/lgsm/functions/install_ts3db.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM fn_install_ts3_mariadb function +# LGSM install_ts3db.sh function # Author: Daniel Gibbs # Contributor: PhilPhonic # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_install_ts3db_mariadb(){ echo "" diff --git a/lgsm/functions/install_ut2k4_key.sh b/lgsm/functions/install_ut2k4_key.sh index a41c2b688..ba2a7634e 100644 --- a/lgsm/functions/install_ut2k4_key.sh +++ b/lgsm/functions/install_ut2k4_key.sh @@ -3,9 +3,9 @@ # Author: Daniel Gibbs # Website: https://gameservermanagers.com -local commandnane="INSTALL" +local commandname="INSTALL" local commandaction="Install" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Enter ${gamename} CD Key" diff --git a/lgsm/functions/logs.sh b/lgsm/functions/logs.sh index 23306525e..b31bdc102 100644 --- a/lgsm/functions/logs.sh +++ b/lgsm/functions/logs.sh @@ -5,10 +5,8 @@ # Website: https://gameservermanagers.com # Description: Acts as a log rotater, removing old logs. -local commandnane="LOGS" +local commandname="LOGS" local commandaction="Log-Manager" -# Cannot have selfname as breaks the function. -#local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Check if logfile variable and file exist, create logfile if it doesn't exist if [ -n "${consolelog}" ]; then @@ -18,7 +16,7 @@ if [ -n "${consolelog}" ]; then fi # For games not displaying a console, and having logs into their game folder -if [ "${selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then +if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then fn_print_info "Moving game logs to ${gamelogdir}" fn_script_log_info "Moving game logs to ${gamelogdir}" diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index 9643d9d56..ed158f89d 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -5,9 +5,9 @@ # Description: uses gsquery.py to query the server port. # Detects if the server has frozen with the proccess still running. -local commandnane="MONITOR" +local commandname="MONITOR" local commandaction="Monitor" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Forces legecy servers to use gsquery if [ -z "${gsquery}" ]; then diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 353309500..28b6e6594 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM commanf_update.sh function +# LGSM command_update.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description:Handles updating using steamCMD. -local commandnane="UPDATE" +local commandname="UPDATE" local commandaction="Update" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_steamcmd_dl(){ diff --git a/lgsm/functions/update_ts3.sh b/lgsm/functions/update_ts3.sh index 86c29e6ef..3f8fb2161 100644 --- a/lgsm/functions/update_ts3.sh +++ b/lgsm/functions/update_ts3.sh @@ -1,12 +1,12 @@ #!/bin/bash -# LGSM commanf_update.sh function +# LGSM command_update.sh function # Author: Daniel Gibbs # Website: https://gameservermanagers.com # Description:Handles updating of teamspeak 3 servers. -local commandnane="UPDATE" +local commandname="UPDATE" local commandaction="Update" -local selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_ts3_dl(){ fn_fetch_file "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" "${lgsmdir}/tmp" "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" From 6d17df703358a083c460047883e49811e9c8f955 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:05:30 +0100 Subject: [PATCH 144/195] updating test --- tests/tests_jc2server.sh | 144 ++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 76 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 3e62e78d1..4f5605f7b 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -3,14 +3,21 @@ # Server Management Script # Author: Daniel Gibbs # Website: https://gameservermanagers.com -version="271215" +version="101716" #### Variables #### -# Alert Email +# Notification Alerts # (on|off) + +# Email emailalert="off" -email="" +email="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" # Steam login steamuser="anonymous" @@ -44,6 +51,9 @@ engine="avalanche" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +libdir="${lgsmdir}/lib" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" executabledir="${filesdir}" @@ -59,6 +69,7 @@ logdays="7" #gamelogdir="" # No server logs available scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" +consolelogging="on" scriptlog="${scriptlogdir}/${servicename}-script.log" consolelog="${consolelogdir}/${servicename}-console.log" @@ -70,55 +81,62 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M- ##### Script ##### # Do not edit -fn_getgithubfile(){ -filename=$1 -exec=$2 -fileurl=${3:-$filename} -filepath="${rootdir}/${filename}" -filedir=$(dirname "${filepath}") -# If the function file is missing, then download -if [ ! -f "${filepath}" ]; then +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then - mkdir "${filedir}" + mkdir -p "${filedir}" fi - githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" echo -e " fetching ${filename}...\c" - if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then - : + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi else echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" - exit - fi - curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curl}" - echo -e "${githuburl}\n" - exit - else - echo -e "\e[0;32mOK\e[0m" - fi - if [ "${exec}" ]; then - chmod +x "${filepath}" + exit 1 fi + chmod +x "${filedir}/${filename}" fi -if [ "${exec}" ]; then - source "${filepath}" -fi +source "${filedir}/${filename}" } -fn_runfunction(){ - fn_getgithubfile "functions/${functionfile}" 1 +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl } core_functions.sh(){ # Functions are defined in core_functions.sh. functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } +core_dl.sh core_functions.sh fn_currentstatus_tmux(){ @@ -178,17 +196,19 @@ echo "by Daniel Gibbs" echo "https://gameservermanagers.com" echo "=================================" echo "" -sleep 1 echo "=================================" echo "Server Tests" echo "Using: ${gamename}" echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" -sleep 1 -mkdir ${rootdir} - +mkdir "${rootdir}" +echo "0.0 - Enable Dev-Debug" +echo "=================================" +echo "Description:" +echo "Enabling dev-debug to display exit codes" +(command_dev_debug.sh) echo "1.0 - start - no files" echo "=================================" @@ -196,9 +216,13 @@ echo "Description:" echo "test script reaction to missing server files." echo "" (command_start.sh) -echo "" -echo "Test complete!" -sleep 1 +if [ $? == 0 ]; then + fn_print_fail "Test Failure" + exitcode=1 + core_exit.sh +else + fn_print_ok "Test Pass" +fi echo "" echo "1.1 - getopt" echo "=================================" @@ -208,11 +232,8 @@ echo "" (core_getopt.sh) echo "" echo "Test complete!" -sleep 1 echo "" - - echo "2.0 - install" echo "=================================" echo "Description:" @@ -220,11 +241,8 @@ echo "install ${gamename} server." fn_autoinstall echo "" echo "Test complete!" -sleep 1 echo "" - - echo "3.1 - start" echo "=================================" echo "Description:" @@ -234,7 +252,6 @@ fn_setstatus command_start.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "3.2 - start - online" echo "=================================" @@ -245,7 +262,6 @@ fn_setstatus (command_start.sh) echo "" echo "Test complete!" -sleep 1 echo "" echo "3.3 - start - updateonstart" echo "=================================" @@ -259,7 +275,7 @@ fn_setstatus ) echo "" echo "Test complete!" -sleep 1 + echo "" echo "3.4 - stop" echo "=================================" @@ -270,7 +286,6 @@ fn_setstatus command_stop.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "3.5 - stop - offline" echo "=================================" @@ -281,7 +296,6 @@ fn_setstatus (command_stop.sh) echo "" echo "Test complete!" -sleep 1 echo "" echo "3.6 - restart" echo "=================================" @@ -292,7 +306,6 @@ fn_setstatus command_restart.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "3.7 - restart - offline" echo "=================================" @@ -303,11 +316,8 @@ fn_setstatus command_restart.sh echo "" echo "Test complete!" -sleep 1 echo "" - - echo "4.1 - update" echo "=================================" echo "Description:" @@ -317,7 +327,6 @@ fn_setstatus update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.2 - update - change buildid" echo "=================================" @@ -330,7 +339,6 @@ sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.3 - update - change buildid - online" echo "=================================" @@ -343,7 +351,6 @@ sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.4 - update - remove appmanifest file" echo "=================================" @@ -356,7 +363,6 @@ rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.5 - force-update" echo "=================================" @@ -367,7 +373,6 @@ fn_setstatus update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.6 - force-update - online" echo "=================================" @@ -378,7 +383,6 @@ fn_setstatus update_check.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.7 - validate" echo "=================================" @@ -389,7 +393,6 @@ fn_setstatus command_validate.sh echo "" echo "Test complete!" -sleep 1 echo "" echo "4.8 - validate - online" echo "=================================" @@ -400,11 +403,8 @@ fn_setstatus command_validate.sh echo "" echo "Test complete!" -sleep 1 echo "" - - echo "5.1 - monitor - online" echo "=================================" echo "Description:" @@ -414,7 +414,6 @@ fn_setstatus (command_monitor.sh) echo "" echo "Test complete!" -sleep 1 echo "" echo "5.2 - monitor - offline - no lockfile" echo "=================================" @@ -425,7 +424,6 @@ fn_setstatus (command_monitor.sh) echo "" echo "Test complete!" -sleep 1 echo "" echo "5.3 - monitor - offline - with lockfile" echo "=================================" @@ -438,7 +436,6 @@ date > "${rootdir}/${lockselfname}" (command_monitor.sh) echo "" echo "Test complete!" -sleep 1 echo "" echo "5.4 - monitor - gsquery.py failure" echo "=================================" @@ -453,11 +450,8 @@ fn_print_info_nl "Reseting ${servercfg}." install_config.sh echo "" echo "Test complete!" -sleep 1 echo "" - - echo "6.0 - details" echo "=================================" echo "Description:" @@ -467,9 +461,7 @@ fn_setstatus command_details.sh echo "" echo "Test complete!" -sleep 1 echo "" - echo "=================================" echo "Server Tests - Complete!" echo "Using: ${gamename}" @@ -477,9 +469,9 @@ echo "=================================" echo "" requiredstatus="OFFLINE" fn_setstatus -sleep 1 + fn_print_info "Tidying up directories." -sleep 1 + rm -rfv ${serverfiles} echo "END" From 19059b84863d26315fcb6cd04f2ae2b3422e8b22 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:12:18 +0100 Subject: [PATCH 145/195] Starting tests from scratch --- tests/tests_jc2server.sh | 450 +-------------------------------------- 1 file changed, 8 insertions(+), 442 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 4f5605f7b..16238087e 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -5,31 +5,6 @@ # Website: https://gameservermanagers.com version="101716" -#### Variables #### - -# Notification Alerts -# (on|off) - -# Email -emailalert="off" -email="email@example.com" - -# Pushbullet -# https://www.pushbullet.com/#settings -pushbulletalert="off" -pushbullettoken="accesstoken" - -# Steam login -steamuser="anonymous" -steampass="" - -# Start Variables -updateonstart="off" - -fn_parms(){ -parms="" -} - #### Advanced Variables #### # Github Branch Select @@ -39,155 +14,8 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" -# Steam -appid="261140" - -# Server Details -servicename="jc2-server" -gamename="Just Cause 2" -engine="avalanche" - -# Directories -rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" -selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -lockselfname=".${servicename}.lock" -lgsmdir="${rootdir}/lgsm" -functionsdir="${lgsmdir}/functions" -libdir="${lgsmdir}/lib" -filesdir="${rootdir}/serverfiles" -systemdir="${filesdir}" -executabledir="${filesdir}" -executable="./Jcmp-Server" -servercfg="config.lua" -servercfgdir="${filesdir}" -servercfgfullpath="${servercfgdir}/${servercfg}" -servercfgdefault="${servercfgdir}/default_config.lua" -backupdir="${rootdir}/backups" - -# Logging -logdays="7" -#gamelogdir="" # No server logs available -scriptlogdir="${rootdir}/log/script" -consolelogdir="${rootdir}/log/console" -consolelogging="on" - -scriptlog="${scriptlogdir}/${servicename}-script.log" -consolelog="${consolelogdir}/${servicename}-console.log" -emaillog="${scriptlogdir}/${servicename}-email.log" - -scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" -consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" - -##### Script ##### -# Do not edit - -# Fetches core_dl for file downloads -fn_fetch_core_dl(){ -github_file_url_dir="lgsm/functions" -github_file_url_name="${functionfile}" -filedir="${functionsdir}" -filename="${github_file_url_name}" -githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" -# If the file is missing, then download -if [ ! -f "${filedir}/${filename}" ]; then - if [ ! -d "${filedir}" ]; then - mkdir -p "${filedir}" - fi - echo -e " fetching ${filename}...\c" - # Check curl exists and use available path - curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" - for curlcmd in ${curlpaths} - do - if [ -x "${curlcmd}" ]; then - break - fi - done - # If curl exists download file - if [ "$(basename ${curlcmd})" == "curl" ]; then - curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curlfetch}" - echo -e "${githuburl}\n" - exit 1 - else - echo -e "\e[0;32mOK\e[0m" - fi - else - echo -e "\e[0;31mFAIL\e[0m\n" - echo "Curl is not installed!" - echo -e "" - exit 1 - fi - chmod +x "${filedir}/${filename}" -fi -source "${filedir}/${filename}" -} - -core_dl.sh(){ -# Functions are defined in core_functions.sh. -functionfile="${FUNCNAME}" -fn_fetch_core_dl -} - -core_functions.sh(){ -# Functions are defined in core_functions.sh. -functionfile="${FUNCNAME}" -fn_fetch_core_dl -} -core_dl.sh -core_functions.sh - -fn_currentstatus_tmux(){ -pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") -if [ "${pid}" != "0" ]; then - currentstatus="ONLINE" -else - currentstatus="OFFLINE" -fi -} - -fn_currentstatus_ts3(){ -ts3status=$(${executable} status servercfgfullpathfile=${servercfgfullpath}) - -if [ "${ts3status}" == "Server is running" ]; then - currentstatus="ONLINE" -else - currentstatus="OFFLINE" -fi -} - -fn_setstatus(){ - fn_currentstatus_tmux - echo"" - echo "Required status: ${requiredstatus}" - counter=0 - echo "Current status: ${currentstatus}" - while [ "${requiredstatus}" != "${currentstatus}" ]; do - counter=$((counter+1)) - fn_currentstatus_tmux - echo -ne "New status: ${currentstatus}\\r" - - if [ "${requiredstatus}" == "ONLINE" ]; then - (command_start.sh > /dev/null 2>&1) - else - (command_stop.sh > /dev/null 2>&1) - fi - if [ "${counter}" -gt "5" ]; then - currentstatus="FAIL" - echo "Current status: ${currentstatus}" - echo "" - echo "Unable to start or stop server." - exit 1 - fi - done - echo -ne "New status: ${currentstatus}\\r" - echo -e "\n" - echo "Test starting:" - echo "" - sleep 0.5 -} +wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server echo "=================================" echo "TravisCI Tests" @@ -202,276 +30,14 @@ echo "Using: ${gamename}" echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" -mkdir "${rootdir}" - -echo "0.0 - Enable Dev-Debug" -echo "=================================" -echo "Description:" -echo "Enabling dev-debug to display exit codes" -(command_dev_debug.sh) - -echo "1.0 - start - no files" -echo "=================================" -echo "Description:" -echo "test script reaction to missing server files." -echo "" -(command_start.sh) -if [ $? == 0 ]; then - fn_print_fail "Test Failure" - exitcode=1 - core_exit.sh -else - fn_print_ok "Test Pass" -fi -echo "" -echo "1.1 - getopt" -echo "=================================" -echo "Description:" -echo "displaying options messages." -echo "" -(core_getopt.sh) -echo "" -echo "Test complete!" -echo "" - -echo "2.0 - install" -echo "=================================" -echo "Description:" -echo "install ${gamename} server." -fn_autoinstall -echo "" -echo "Test complete!" -echo "" - -echo "3.1 - start" -echo "=================================" -echo "Description:" -echo "start ${gamename} server." -requiredstatus="OFFLINE" -fn_setstatus -command_start.sh -echo "" -echo "Test complete!" -echo "" -echo "3.2 - start - online" -echo "=================================" -echo "Description:" -echo "start ${gamename} server while already running." -requiredstatus="ONLINE" -fn_setstatus -(command_start.sh) -echo "" -echo "Test complete!" -echo "" -echo "3.3 - start - updateonstart" -echo "=================================" -echo "Description:" -echo "will update server on start." -requiredstatus="OFFLINE" -fn_setstatus -( - updateonstart="on" - command_start.sh -) -echo "" -echo "Test complete!" - -echo "" -echo "3.4 - stop" -echo "=================================" -echo "Description:" -echo "stop ${gamename} server." -requiredstatus="ONLINE" -fn_setstatus -command_stop.sh -echo "" -echo "Test complete!" -echo "" -echo "3.5 - stop - offline" -echo "=================================" -echo "Description:" -echo "stop ${gamename} server while already stopped." -requiredstatus="OFFLINE" -fn_setstatus -(command_stop.sh) -echo "" -echo "Test complete!" -echo "" -echo "3.6 - restart" -echo "=================================" -echo "Description:" -echo "restart ${gamename}." -requiredstatus="ONLINE" -fn_setstatus -command_restart.sh -echo "" -echo "Test complete!" -echo "" -echo "3.7 - restart - offline" -echo "=================================" -echo "Description:" -echo "restart ${gamename} while already stopped." -requiredstatus="OFFLINE" -fn_setstatus -command_restart.sh -echo "" -echo "Test complete!" -echo "" - -echo "4.1 - update" -echo "=================================" -echo "Description:" -echo "check for updates." -requiredstatus="OFFLINE" -fn_setstatus -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.2 - update - change buildid" -echo "=================================" -echo "Description:" -echo "change the buildid tricking SteamCMD to update." -requiredstatus="OFFLINE" -fn_setstatus -fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.3 - update - change buildid - online" -echo "=================================" -echo "Description:" -echo "change the buildid tricking SteamCMD to update server while already running." -requiredstatus="ONLINE" -fn_setstatus -fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.4 - update - remove appmanifest file" -echo "=================================" -echo "Description:" -echo "removing appmanifest file will cause script to repair." -requiredstatus="OFFLINE" -fn_setstatus -fn_print_info_nl "removed appmanifest_${appid}.acf." -rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.5 - force-update" -echo "=================================" -echo "Description:" -echo "force-update bypassing update check." -requiredstatus="OFFLINE" -fn_setstatus -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.6 - force-update - online" -echo "=================================" -echo "Description:" -echo "force-update bypassing update check server while already running." -requiredstatus="ONLINE" -fn_setstatus -update_check.sh -echo "" -echo "Test complete!" -echo "" -echo "4.7 - validate" -echo "=================================" -echo "Description:" -echo "validate server files." -requiredstatus="OFFLINE" -fn_setstatus -command_validate.sh -echo "" -echo "Test complete!" -echo "" -echo "4.8 - validate - online" -echo "=================================" -echo "Description:" -echo "validate server files while server while already running." -requiredstatus="ONLINE" -fn_setstatus -command_validate.sh -echo "" -echo "Test complete!" -echo "" - -echo "5.1 - monitor - online" -echo "=================================" -echo "Description:" -echo "run monitor server while already running." -requiredstatus="ONLINE" -fn_setstatus -(command_monitor.sh) -echo "" -echo "Test complete!" -echo "" -echo "5.2 - monitor - offline - no lockfile" -echo "=================================" -echo "Description:" -echo "run monitor while server is offline with no lockfile." -requiredstatus="OFFLINE" -fn_setstatus -(command_monitor.sh) -echo "" -echo "Test complete!" -echo "" -echo "5.3 - monitor - offline - with lockfile" -echo "=================================" -echo "Description:" -echo "run monitor while server is offline with no lockfile." -requiredstatus="OFFLINE" -fn_setstatus -fn_print_info_nl "creating lockfile." -date > "${rootdir}/${lockselfname}" -(command_monitor.sh) -echo "" -echo "Test complete!" -echo "" -echo "5.4 - monitor - gsquery.py failure" -echo "=================================" -echo "Description:" -echo "gsquery.py will fail to query port." -requiredstatus="ONLINE" -fn_setstatus -sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" -(command_monitor.sh) -echo "" -fn_print_info_nl "Reseting ${servercfg}." -install_config.sh -echo "" -echo "Test complete!" -echo "" -echo "6.0 - details" +echo "0.0 - Preparing Enviroment" echo "=================================" echo "Description:" -echo "display details." -requiredstatus="ONLINE" -fn_setstatus -command_details.sh -echo "" -echo "Test complete!" -echo "" -echo "=================================" -echo "Server Tests - Complete!" -echo "Using: ${gamename}" -echo "=================================" -echo "" -requiredstatus="OFFLINE" -fn_setstatus - -fn_print_info "Tidying up directories." - -rm -rfv ${serverfiles} -echo "END" +echo "Preparing Enviroment to run tests" +echo "Downloading jc2server" +wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server +chmod +x +echo "Enable dev-debug" +./jc2server dev-debug \ No newline at end of file From 77df62dbf29eadcd9ed378cc75a03929550d9984 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:14:18 +0100 Subject: [PATCH 146/195] test --- tests/tests_jc2server.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 16238087e..4c43e0f29 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,9 +14,6 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" - -wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server - echo "=================================" echo "TravisCI Tests" echo "Linux Game Server Manager" @@ -38,6 +35,6 @@ echo "Preparing Enviroment to run tests" echo "Downloading jc2server" wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server -chmod +x +chmod +x jc2server echo "Enable dev-debug" ./jc2server dev-debug \ No newline at end of file From 87a7e6c89044b92cded02692a2f4cf741c819764 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:18:38 +0100 Subject: [PATCH 147/195] test --- tests/tests_jc2server.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 4c43e0f29..86c88537f 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -36,5 +36,7 @@ echo "Preparing Enviroment to run tests" echo "Downloading jc2server" wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server chmod +x jc2server +echo "Create log dir" +mkdir -p log/script/ echo "Enable dev-debug" -./jc2server dev-debug \ No newline at end of file +./jc2server dev-debug From a8d8ccc061a3fb2f6f6edb3b119f45df03d90034 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:26:11 +0100 Subject: [PATCH 148/195] test --- tests/tests_jc2server.sh | 52 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 86c88537f..d02130883 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,6 +14,30 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +# End of every test will expect the result to either pass or fail +# If the script does not do as intended the whole test will fail +# if excpecting a pass +fn_test_result_pass(){ + if [ $? != 0 ]; then + fn_print_fail "Test Failure" + exitcode=1 + core_exit.sh + else + fn_print_ok "Test Pass" + fi +} + +# if excpecting a fail +fn_test_result_fail(){ + if [ $? == 0 ]; then + fn_print_fail "Test Failure" + exitcode=1 + core_exit.sh + else + fn_print_ok "Test Pass" + fi +} + echo "=================================" echo "TravisCI Tests" echo "Linux Game Server Manager" @@ -37,6 +61,32 @@ echo "Downloading jc2server" wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server chmod +x jc2server echo "Create log dir" -mkdir -p log/script/ +mkdir -pv log/script/ echo "Enable dev-debug" ./jc2server dev-debug + +echo "1.0 - start - no files" +echo "=================================" +echo "Description:" +echo "test script reaction to missing server files." +echo "" +./jc2server start +fn_test_result_fail + +echo "" +echo "1.1 - getopt" +echo "=================================" +echo "Description:" +echo "displaying options messages." +echo "" +./jc2server +fn_test_result_pass + +echo "" +echo "1.2 - getopt with incorrect args" +echo "=================================" +echo "Description:" +echo "displaying options messages." +echo "" +./jc2server +fn_test_result_fail \ No newline at end of file From 1fcb075383a0b30fa69f3e535be9bde704252fe0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:32:37 +0100 Subject: [PATCH 149/195] test --- tests/tests_jc2server.sh | 79 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index d02130883..d62c8e50e 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,27 +14,89 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +##### Script ##### + +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir -p "${filedir}" + fi + echo -e " fetching ${filename}...\c" + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit 1 + fi + chmod +x "${filedir}/${filename}" +fi +source "${filedir}/${filename}" +} + +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_functions.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl +} + +core_dl.sh +core_functions.sh + + + # End of every test will expect the result to either pass or fail # If the script does not do as intended the whole test will fail # if excpecting a pass fn_test_result_pass(){ if [ $? != 0 ]; then - fn_print_fail "Test Failure" + fn_print_fail "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Pass" + fn_print_ok "Test Passed" fi } # if excpecting a fail fn_test_result_fail(){ if [ $? == 0 ]; then - fn_print_fail "Test Failure" + fn_print_fail "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Pass" + fn_print_ok "Test Passed" fi } @@ -89,4 +151,11 @@ echo "Description:" echo "displaying options messages." echo "" ./jc2server -fn_test_result_fail \ No newline at end of file +fn_test_result_fail + +echo "2.0 - install" +echo "=================================" +echo "Description:" +echo "install Just Cause 2 server." +./jc2server auto-install +fn_test_result_pass \ No newline at end of file From be31b50cb633e38195dcd1ec0250219a1bc99149 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:37:31 +0100 Subject: [PATCH 150/195] test --- tests/tests_jc2server.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index d62c8e50e..b3a37f6cd 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -16,6 +16,23 @@ githubbranch="$TRAVIS_BRANCH" ##### Script ##### +# Directories +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" +lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +libdir="${lgsmdir}/lib" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="./Jcmp-Server" +servercfg="config.lua" +servercfgdir="${filesdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" +servercfgdefault="${servercfgdir}/default_config.lua" +backupdir="${rootdir}/backups" + # Fetches core_dl for file downloads fn_fetch_core_dl(){ github_file_url_dir="lgsm/functions" From 86e0b704b3ce5f7af4f0639ea6773861a486cae0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 19:42:51 +0100 Subject: [PATCH 151/195] test --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index b3a37f6cd..42cd57f25 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -167,7 +167,7 @@ echo "=================================" echo "Description:" echo "displaying options messages." echo "" -./jc2server +./jc2server abc123 fn_test_result_fail echo "2.0 - install" From 2caa124944b9df11506ed76e12d59aa8c1f51d14 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 21:21:47 +0100 Subject: [PATCH 152/195] can now check all files have correct user groups are no longer checked as a user cna have multiple groups --- lgsm/functions/check_permissions.sh | 100 +++++++++------------------- 1 file changed, 30 insertions(+), 70 deletions(-) diff --git a/lgsm/functions/check_permissions.sh b/lgsm/functions/check_permissions.sh index 77622c690..584ea4695 100644 --- a/lgsm/functions/check_permissions.sh +++ b/lgsm/functions/check_permissions.sh @@ -6,50 +6,37 @@ # Description: Checks script, files and folders ownership and permissions. local commandname="CHECK" - -# Useful variables -currentuser="$(whoami)" -currentgroups="$(groups)" -scriptfullpath="${rootdir}/${selfname}" -conclusionpermissionerror="0" +local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_check_ownership(){ - # Check script ownership - if [ ! -O "${scriptfullpath}" ] && [ ! -G "${scriptfullpath}" ]; then - fn_print_fail_nl "Oops ! Ownership issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${selfname}\"" - echo " * To check the owner and allowed groups, run ls -l \"${selfname}\"" - exit 1 - fi - - # Check rootdir ownership - if [ ! -O "${rootdir}" ] && [ ! -G "${rootdir}" ]; then - fn_print_fail_nl "Oops ! Ownership issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own \"${rootdir}\"" - echo " * To check the owner and allowed groups, run ls -dl \"${rootdir}\"" - exit 1 + if [ $(find "${rootdir}" -not -user $(whoami)|wc -l) -ne "0" ]; then + fn_print_fail_nl "Permissions issues found" + fn_script_log_fatal "Permissions issues found" + fn_print_infomation_nl "The current user ($(whoami)) does not have ownership of the following files:" + fn_script_log_info "The current user ($(whoami)) does not have ownership of the following files:" + { + echo -e "User\tGroup\tFile\n" + find "${rootdir}" -not -user $(whoami) -printf "%u\t\t%g\t%p\n" + } | column -s $'\t' -t | tee -a "${scriptlog}" + core_exit.sh fi +} - # Check functions ownership - funownfail="0" +fn_check_permissions(){ if [ -n "${functionsdir}" ]; then - while read -r filename - do - if [ ! -O "${filename}" ] && [ ! -G "${filename}" ]; then - funownfail="1" - conclusionpermissionerror="1" - fi - done <<< "$(find "${functionsdir}" -name "*.sh")" - - if [ "${funownfail}" == "1" ]; then - fn_print_fail_nl "Oops ! Ownership issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} - does not own all scripts in \"${functionsdir}\"" - echo " * To check the owner and allowed groups, run ls -l \"${functionsdir}\"" + if [ $(find "${functionsdir}" -type f -not -executable|wc -l) -ne "0" ]; then + fn_print_fail_nl "Permissions issues found" + fn_script_log_fatal "Permissions issues found" + fn_print_infomation_nl "The following files are not executable:" + fn_script_log_info "The following files are not executable:" + { + echo -e "File\n" + find "${functionsdir}" -type f -not -executable -printf "%p\n" + } | column -s $'\t' -t | tee -a "${scriptlog}" + core_exit.sh fi fi -} -fn_check_permissions(){ # Check rootdir permissions if [ -n "${rootdir}" ]; then # Get permission numbers on folder under the form 775 @@ -58,42 +45,15 @@ fn_check_permissions(){ userrootdirperm="${rootdirperm:0:1}" grouprootdirperm="${rootdirperm:1:1}" if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then - fn_print_fail_nl "Oops ! Permission issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control of \"${rootdir}\"" - echo " * You might wanna run : chmod -R 770 \"${rootdir}\"" - conclusionpermissionerror="1" + fn_print_fail_nl "Permissions issues found" + fn_script_log_fatal "Permissions issues found" + fn_print_infomation_nl "The following directorys does not have the correct permissions:" + fn_script_log_info "The following directorys does not have the correct permissions:" + ls -l "${rootdir}" + core_exit.sh fi fi - - # Check functions permissions - funcpermfail="0" - if [ -n "${functionsdir}" ]; then - while read -r filename - do - funcperm="$(stat -c %a "${filename}")" - userfuncdirperm="${funcperm:0:1}" - groupfuncdirperm="${funcperm:1:1}" - if [ "${userfuncdirperm}" != "7" ] && [ "${groupfuncdirperm}" != "7" ]; then - funcpermfail="1" - conclusionpermissionerror="1" - fi - done <<< "$(find "${functionsdir}" -name "*.sh")" - - if [ "${funcpermfail}" == "1" ]; then - fn_print_fail_nl "Oops ! Permission issue..." - echo " * Current - ${currentuser} - user or its group(s) - ${currentgroups} need full control on scripts in \"${functionsdir}\"" - echo " * You might wanna run : chmod -R 770 \"${functionsdir}\"" - fi - fi -} - -fn_check_permissions_conclusion(){ - # Exit if errors found - if [ "${conclusionpermissionerror}" == "1" ]; then - exit 1 - fi } fn_check_ownership -fn_check_permissions -fn_check_permissions_conclusion \ No newline at end of file +fn_check_permissions \ No newline at end of file From 7c5921cfc4c0681b2162eb2ce7f5cc759ef3c3d8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 21:35:27 +0100 Subject: [PATCH 153/195] test --- tests/tests_jc2server.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 42cd57f25..23a674d76 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -98,22 +98,22 @@ core_functions.sh # if excpecting a pass fn_test_result_pass(){ if [ $? != 0 ]; then - fn_print_fail "Test Failed" + fn_print_fail_nl "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Passed" + fn_print_ok_nl "Test Passed" fi } # if excpecting a fail fn_test_result_fail(){ if [ $? == 0 ]; then - fn_print_fail "Test Failed" + fn_print_fail_nl "Test Failed" exitcode=1 core_exit.sh else - fn_print_ok "Test Passed" + fn_print_ok_nl "Test Passed" fi } @@ -141,6 +141,7 @@ wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranc chmod +x jc2server echo "Create log dir" mkdir -pv log/script/ +rm -rf lgsm/functions/* echo "Enable dev-debug" ./jc2server dev-debug @@ -175,4 +176,9 @@ echo "=================================" echo "Description:" echo "install Just Cause 2 server." ./jc2server auto-install -fn_test_result_pass \ No newline at end of file +fn_test_result_pass + +echo "3.1 - start" +echo "=================================" +echo "Description:" +echo "start ${gamename} server." \ No newline at end of file From f1208836651fc8599b6fc89b4ffaee6717dde940 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 21:42:07 +0100 Subject: [PATCH 154/195] test --- tests/tests_jc2server.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 23a674d76..bd900daca 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -141,7 +141,8 @@ wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranc chmod +x jc2server echo "Create log dir" mkdir -pv log/script/ -rm -rf lgsm/functions/* +echo "Make functions executable" +chmod +x lgsm/functions/* echo "Enable dev-debug" ./jc2server dev-debug @@ -150,6 +151,7 @@ echo "=================================" echo "Description:" echo "test script reaction to missing server files." echo "" +echo "Command: ./jc2server start" ./jc2server start fn_test_result_fail @@ -159,6 +161,7 @@ echo "=================================" echo "Description:" echo "displaying options messages." echo "" +echo "Command: ./jc2server" ./jc2server fn_test_result_pass @@ -168,6 +171,7 @@ echo "=================================" echo "Description:" echo "displaying options messages." echo "" +echo "Command: ./jc2server abc123" ./jc2server abc123 fn_test_result_fail From a430cd44a0b0297b3a5b37f0abbacf4660c000bd Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 21:49:37 +0100 Subject: [PATCH 155/195] removed function_selfname --- lgsm/functions/install_steamcmd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/install_steamcmd.sh b/lgsm/functions/install_steamcmd.sh index e4e7c7325..82cce59a6 100644 --- a/lgsm/functions/install_steamcmd.sh +++ b/lgsm/functions/install_steamcmd.sh @@ -6,7 +6,6 @@ local commandname="INSTALL" local commandaction="Install" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" echo "" echo "Installing SteamCMD" From 4ba347f73bff426d5897ab40b61b06068b9d1f10 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 21:54:25 +0100 Subject: [PATCH 156/195] removed function_selfname --- lgsm/functions/fix.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/fix.sh b/lgsm/functions/fix.sh index 706beac15..6a69bd759 100644 --- a/lgsm/functions/fix.sh +++ b/lgsm/functions/fix.sh @@ -7,7 +7,6 @@ local commandname="FIX" local commandaction="Fix" -local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" # Messages that are displayed for some fixes fn_fix_msg_start(){ From 62d91be867ff35e39c438a66073f68d6970a5f39 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 22:29:28 +0100 Subject: [PATCH 157/195] test --- tests/tests_jc2server.sh | 60 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index bd900daca..64ff795cc 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -33,6 +33,11 @@ servercfgfullpath="${servercfgdir}/${servercfg}" servercfgdefault="${servercfgdir}/default_config.lua" backupdir="${rootdir}/backups" +# Server Details +servicename="jc2-server" +gamename="Just Cause 2" +engine="avalanche" + # Fetches core_dl for file downloads fn_fetch_core_dl(){ github_file_url_dir="lgsm/functions" @@ -91,7 +96,55 @@ fn_fetch_core_dl core_dl.sh core_functions.sh +fn_currentstatus_tmux(){ +pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") +if [ "${pid}" != "0" ]; then + currentstatus="ONLINE" +else + currentstatus="OFFLINE" +fi +} + +fn_currentstatus_ts3(){ +ts3status=$(${executable} status servercfgfullpathfile=${servercfgfullpath}) + +if [ "${ts3status}" == "Server is running" ]; then + currentstatus="ONLINE" +else + currentstatus="OFFLINE" +fi +} +fn_setstatus(){ + fn_currentstatus_tmux + echo"" + echo "Required status: ${requiredstatus}" + counter=0 + echo "Current status: ${currentstatus}" + while [ "${requiredstatus}" != "${currentstatus}" ]; do + counter=$((counter+1)) + fn_currentstatus_tmux + echo -ne "New status: ${currentstatus}\\r" + + if [ "${requiredstatus}" == "ONLINE" ]; then + ./jc2server start > /dev/null 2>&1 + else + ./jc2server start > /dev/null 2>&1 + fi + if [ "${counter}" -gt "5" ]; then + currentstatus="FAIL" + echo "Current status: ${currentstatus}" + echo "" + echo "Unable to start or stop server." + exit 1 + fi + done + echo -ne "New status: ${currentstatus}\\r" + echo -e "\n" + echo "Test starting:" + echo "" + sleep 0.5 +} # End of every test will expect the result to either pass or fail # If the script does not do as intended the whole test will fail @@ -114,6 +167,7 @@ fn_test_result_fail(){ core_exit.sh else fn_print_ok_nl "Test Passed" + echo "" fi } @@ -179,10 +233,14 @@ echo "2.0 - install" echo "=================================" echo "Description:" echo "install Just Cause 2 server." +echo "Command: ./jc2server abc123" ./jc2server auto-install fn_test_result_pass echo "3.1 - start" echo "=================================" echo "Description:" -echo "start ${gamename} server." \ No newline at end of file +echo "start ${gamename} server." +echo "Command: ./jc2server start" +requiredstatus="OFFLINE" +./jc2server start \ No newline at end of file From e50d8afbb5ed09c0856783c21d27611601794f10 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 22:40:54 +0100 Subject: [PATCH 158/195] test --- tests/tests_jc2server.sh | 67 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 64ff795cc..d1406873c 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -156,6 +156,7 @@ fn_test_result_pass(){ core_exit.sh else fn_print_ok_nl "Test Passed" + echo "" fi } @@ -229,6 +230,7 @@ echo "Command: ./jc2server abc123" ./jc2server abc123 fn_test_result_fail +echo "" echo "2.0 - install" echo "=================================" echo "Description:" @@ -237,10 +239,73 @@ echo "Command: ./jc2server abc123" ./jc2server auto-install fn_test_result_pass +echo "" echo "3.1 - start" echo "=================================" echo "Description:" echo "start ${gamename} server." echo "Command: ./jc2server start" requiredstatus="OFFLINE" -./jc2server start \ No newline at end of file +./jc2server start +fn_test_result_pass + +echo "" +echo "3.2 - start - online" +echo "=================================" +echo "Description:" +echo "start ${gamename} server while already running." +echo "Command: ./jc2server start" +requiredstatus="ONLINE" +./jc2server start +fn_test_result_fail + +echo "" +echo "3.3 - stop" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server." +echo "Command: ./jc2server stop" +requiredstatus="ONLINE" +./jc2server stop +fn_test_result_pass + +echo "" +echo "3.4 - stop - offline" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server while already stopped." +echo "Command: ./jc2server stop" +requiredstatus="OFFLINE" +./jc2server stop +fn_test_result_fail + +echo "" +echo "3.6 - restart" +echo "=================================" +echo "Description:" +echo "restart ${gamename}." +echo "Command: ./jc2server restart" +requiredstatus="ONLINE" +./jc2server restart +fn_test_result_pass + +echo "4.1 - update" +echo "=================================" +echo "Description:" +echo "check for updates." +echo "Command: ./jc2server update" +requiredstatus="OFFLINE" +./jc2server update +fn_test_result_pass + +echo "" +echo "4.2 - update - change buildid" +echo "=================================" +echo "Description:" +echo "change the buildid tricking SteamCMD to update." +echo "Command: ./jc2server update" +requiredstatus="OFFLINE" +fn_print_info_nl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +./jc2server update +fn_test_result_pass \ No newline at end of file From 1ecdfe81783c3eb015eccde5363fa667c34b3654 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 10 Jul 2016 22:49:06 +0100 Subject: [PATCH 159/195] test --- tests/tests_jc2server.sh | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index d1406873c..ac499c9d2 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -14,6 +14,9 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +# Steam +appid="261140" + ##### Script ##### # Directories @@ -308,4 +311,57 @@ requiredstatus="OFFLINE" fn_print_info_nl "changed buildid to 0." sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf ./jc2server update +fn_test_result_pass + +echo "" +echo "4.3 - update - change buildid - online" +echo "=================================" +echo "Description:" +echo "change the buildid tricking SteamCMD to update server while already running." +echo "Command: ./jc2server update" +requiredstatus="ONLINE" +fn_print_info_nl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +./jc2server update +fn_test_result_pass + +echo "" +echo "4.4 - update - remove appmanifest file" +echo "=================================" +echo "Description:" +echo "removing appmanifest file will cause script to repair." +echo "Command: ./jc2server update" +requiredstatus="OFFLINE" +fn_print_info_nl "removed appmanifest_${appid}.acf." +rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" +./jc2server update +fn_test_result_pass + +echo "" +echo "4.5 - force-update" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check." +echo "Command: ./jc2server force-update" +requiredstatus="OFFLINE" +./jc2server force-update +fn_test_result_pass + +echo "" +echo "4.7 - validate" +echo "=================================" +echo "Description:" +echo "validate server files." +echo "Command: ./jc2server validate" +requiredstatus="OFFLINE" +./jc2server validate +fn_test_result_pass + +echo "" +echo "4.8 - validate - online" +echo "=================================" +echo "Description:" +echo "validate server files while server while already running." +requiredstatus="ONLINE" +./jc2server validate fn_test_result_pass \ No newline at end of file From cec2a100e65003a0ee16a0838a811e0676ad1d93 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 17:59:28 +0100 Subject: [PATCH 160/195] moar test --- tests/tests_jc2server.sh | 63 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index ac499c9d2..bf20120ea 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -362,6 +362,67 @@ echo "4.8 - validate - online" echo "=================================" echo "Description:" echo "validate server files while server while already running." +echo "Command: ./jc2server validate" requiredstatus="ONLINE" ./jc2server validate -fn_test_result_pass \ No newline at end of file +fn_test_result_pass + +echo "" +echo "5.1 - monitor - online" +echo "=================================" +echo "Description:" +echo "run monitor server while already running." +echo "Command: ./jc2server monitor" +requiredstatus="ONLINE" +./jc2server monitor +fn_test_result_pass + +echo "" +echo "5.2 - monitor - offline - no lockfile" +echo "=================================" +echo "Description:" +echo "run monitor while server is offline with no lockfile." +echo "Command: ./jc2server monitor" +requiredstatus="OFFLINE" +./jc2server monitor + +echo "" +echo "5.3 - monitor - offline - with lockfile" +echo "=================================" +echo "Description:" +echo "run monitor while server is offline with no lockfile." +echo "Command: ./jc2server monitor" +requiredstatus="OFFLINE" +fn_print_info_nl "creating lockfile." +date > "${rootdir}/${lockselfname}" +./jc2server monitor + +echo "" +echo "5.4 - monitor - gsquery.py failure" +echo "=================================" +echo "Description:" +echo "gsquery.py will fail to query port." +echo "Command: ./jc2server monitor" +requiredstatus="ONLINE" +sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" +./jc2server monitor +echo "" +fn_print_info_nl "Reseting ${servercfg}." +wget -p "${servercfgfullpath}" https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/JustCause2/cfg/config.lua + +echo "" +echo "6.0 - details" +echo "=================================" +echo "Description:" +echo "display details." +echo "Command: ./jc2server details" +requiredstatus="ONLINE" +./jc2server details + +echo "" +echo "=================================" +echo "Server Tests - Complete!" +echo "Using: ${gamename}" +echo "=================================" +echo "" +requiredstatus="OFFLINE" \ No newline at end of file From 7c890e1550746670773a7b8d436ce72685c05a62 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:10:30 +0100 Subject: [PATCH 161/195] moar testing code --- tests/tests_jc2server.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index bf20120ea..bdab91f19 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -132,7 +132,7 @@ fn_setstatus(){ if [ "${requiredstatus}" == "ONLINE" ]; then ./jc2server start > /dev/null 2>&1 else - ./jc2server start > /dev/null 2>&1 + ./jc2server stop > /dev/null 2>&1 fi if [ "${counter}" -gt "5" ]; then currentstatus="FAIL" @@ -375,7 +375,7 @@ echo "run monitor server while already running." echo "Command: ./jc2server monitor" requiredstatus="ONLINE" ./jc2server monitor -fn_test_result_pass +fn_test_result_fail echo "" echo "5.2 - monitor - offline - no lockfile" @@ -385,6 +385,7 @@ echo "run monitor while server is offline with no lockfile." echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" ./jc2server monitor +fn_test_result_fail echo "" echo "5.3 - monitor - offline - with lockfile" @@ -396,6 +397,7 @@ requiredstatus="OFFLINE" fn_print_info_nl "creating lockfile." date > "${rootdir}/${lockselfname}" ./jc2server monitor +fn_test_result_pass echo "" echo "5.4 - monitor - gsquery.py failure" @@ -406,6 +408,7 @@ echo "Command: ./jc2server monitor" requiredstatus="ONLINE" sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" ./jc2server monitor +fn_test_result_fail echo "" fn_print_info_nl "Reseting ${servercfg}." wget -p "${servercfgfullpath}" https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/JustCause2/cfg/config.lua @@ -418,6 +421,7 @@ echo "display details." echo "Command: ./jc2server details" requiredstatus="ONLINE" ./jc2server details +fn_test_result_pass echo "" echo "=================================" From df37acc64495885254f40601b602f42c3b8c220b Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:17:18 +0100 Subject: [PATCH 162/195] test correction --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index bdab91f19..ca355826a 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -375,7 +375,7 @@ echo "run monitor server while already running." echo "Command: ./jc2server monitor" requiredstatus="ONLINE" ./jc2server monitor -fn_test_result_fail +fn_test_result_pass echo "" echo "5.2 - monitor - offline - no lockfile" From ffb718aaf163eb61f871d6db99186caa79d92403 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:27:10 +0100 Subject: [PATCH 163/195] more test changes --- tests/tests_jc2server.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index ca355826a..1c51241ee 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -333,7 +333,7 @@ echo "removing appmanifest file will cause script to repair." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_print_info_nl "removed appmanifest_${appid}.acf." -rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" +rm --verbose "${rootdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass @@ -378,26 +378,26 @@ requiredstatus="ONLINE" fn_test_result_pass echo "" -echo "5.2 - monitor - offline - no lockfile" +echo "5.2 - monitor - offline - with lockfile" echo "=================================" echo "Description:" -echo "run monitor while server is offline with no lockfile." +echo "run monitor while server is offline with lockfile." echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" +fn_print_info_nl "creating lockfile." +date > "${rootdir}/${lockselfname}" ./jc2server monitor fn_test_result_fail echo "" -echo "5.3 - monitor - offline - with lockfile" +echo "5.3 - monitor - offline - no lockfile" echo "=================================" echo "Description:" echo "run monitor while server is offline with no lockfile." echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" -fn_print_info_nl "creating lockfile." -date > "${rootdir}/${lockselfname}" ./jc2server monitor -fn_test_result_pass +fn_test_result_fail echo "" echo "5.4 - monitor - gsquery.py failure" From ee07b213576a2606776f249126e4610b393e01ec Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:32:11 +0100 Subject: [PATCH 164/195] adding ls to see what in the dir --- tests/tests_jc2server.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 1c51241ee..97324b97e 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -242,6 +242,10 @@ echo "Command: ./jc2server abc123" ./jc2server auto-install fn_test_result_pass +echo "=================================" +ls -al +echo "=================================" + echo "" echo "3.1 - start" echo "=================================" @@ -309,7 +313,7 @@ echo "change the buildid tricking SteamCMD to update." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +sed -i 's/[0-9]\+/0/' "${rootdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass @@ -321,7 +325,7 @@ echo "change the buildid tricking SteamCMD to update server while already runnin echo "Command: ./jc2server update" requiredstatus="ONLINE" fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +sed -i 's/[0-9]\+/0/' "${rootdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass From 0a9f87ed55c55b0fd571116dc13ae492b5357d00 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:39:02 +0100 Subject: [PATCH 165/195] tests --- tests/tests_jc2server.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 97324b97e..484b0a9a7 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -245,6 +245,8 @@ fn_test_result_pass echo "=================================" ls -al echo "=================================" +ls -al "${serverfiles}" +echo "=================================" echo "" echo "3.1 - start" @@ -313,7 +315,7 @@ echo "change the buildid tricking SteamCMD to update." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' "${rootdir}/steamapps/appmanifest_${appid}.acf" +sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass @@ -325,7 +327,7 @@ echo "change the buildid tricking SteamCMD to update server while already runnin echo "Command: ./jc2server update" requiredstatus="ONLINE" fn_print_info_nl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' "${rootdir}/steamapps/appmanifest_${appid}.acf" +sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass @@ -337,7 +339,7 @@ echo "removing appmanifest file will cause script to repair." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_print_info_nl "removed appmanifest_${appid}.acf." -rm --verbose "${rootdir}/steamapps/appmanifest_${appid}.acf" +rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" ./jc2server update fn_test_result_pass From 973588d3c6c042c9ea87763b5948b5b90f446b60 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:44:18 +0100 Subject: [PATCH 166/195] filesdir --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 484b0a9a7..562ca4d7f 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -245,7 +245,7 @@ fn_test_result_pass echo "=================================" ls -al echo "=================================" -ls -al "${serverfiles}" +ls -al "${filesdir}" echo "=================================" echo "" From 6e75ef48bb04366ab9ab9cf2041074bc2438b169 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 18:48:48 +0100 Subject: [PATCH 167/195] changed rootdir --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 562ca4d7f..2965110e4 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -20,7 +20,7 @@ appid="261140" ##### Script ##### # Directories -rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +rootdir="/home/travis/build/${githubuser}/${githubrepo}" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" lgsmdir="${rootdir}/lgsm" From 7a28922101914a7d1c88a4a455585f828cd5be1d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 22:59:21 +0100 Subject: [PATCH 168/195] command_update.sh --- lgsm/functions/command_start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 26689c29a..1bfa6e9d3 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -172,7 +172,7 @@ logs.sh # Will check for updates is updateonstart is yes if [ "${status}" == "0" ]; then if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then - update_check.sh + command_update.sh fi fi From f85f1bc75f7fdd79229f312c5a5b2a146f14b8ae Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 22:59:35 +0100 Subject: [PATCH 169/195] rootdir --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 2965110e4..562ca4d7f 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -20,7 +20,7 @@ appid="261140" ##### Script ##### # Directories -rootdir="/home/travis/build/${githubuser}/${githubrepo}" +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" lgsmdir="${rootdir}/lgsm" From 0054b041df03215e845d1a70115fccd507ad33ac Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 22:59:42 +0100 Subject: [PATCH 170/195] space --- lgsm/functions/command_install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 1f1022f9f..6d2bcf40e 100644 --- a/lgsm/functions/command_install.sh +++ b/lgsm/functions/command_install.sh @@ -32,6 +32,7 @@ if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == " elif [ "${gamename}" == "Teamspeak 3" ]; then install_ts3db.sh fi + fix.sh install_complete.sh core_exit.sh \ No newline at end of file From 5f53c560b395a4bd810b1ddc09e05cafd1e68518 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:15:28 +0100 Subject: [PATCH 171/195] corrected update function --- lgsm/functions/update_steamcmd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 28b6e6594..5f87ec25c 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -71,8 +71,8 @@ fn_appmanifest_check(){ fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" sleep 1 - update_dl.sh - update_check.sh + fn_update_steamcmd_dl + fn_update_request_log fi elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" == "1" ]; then @@ -88,7 +88,7 @@ fn_appmanifest_check(){ fn_script_log_info "Forcing update to correct issue" sleep 1 update_dl.sh - update_check.sh + fn_update_request_log fi } From b7df022895033394967696b70570451178eaf7e9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:28:36 +0100 Subject: [PATCH 172/195] update_steamsmd_dl --- lgsm/functions/update_steamcmd.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 5f87ec25c..4db3c284e 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -9,7 +9,6 @@ local commandaction="Update" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" fn_update_steamcmd_dl(){ - check.sh info_config.sh fn_print_dots "SteamCMD" @@ -87,7 +86,7 @@ fn_appmanifest_check(){ fn_print_info_nl "Forcing update to correct issue" fn_script_log_info "Forcing update to correct issue" sleep 1 - update_dl.sh + fn_update_steamcmd_dl fn_update_request_log fi } From b1eb6fa49942d27f3dc2d0415b450dcc53d54376 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:45:50 +0100 Subject: [PATCH 173/195] removed unrequired exitbypass --- lgsm/functions/command_restart.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/lgsm/functions/command_restart.sh b/lgsm/functions/command_restart.sh index 06da6afb6..9e1a2142f 100644 --- a/lgsm/functions/command_restart.sh +++ b/lgsm/functions/command_restart.sh @@ -11,5 +11,4 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" info_config.sh exitbypass=1 command_stop.sh -exitbypass=1 command_start.sh \ No newline at end of file From 2e0e9257d595a599907f25b4eb159bc95d7e2547 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:50:11 +0100 Subject: [PATCH 174/195] nl --- lgsm/functions/command_validate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lgsm/functions/command_validate.sh b/lgsm/functions/command_validate.sh index de97c4a70..e5042f269 100644 --- a/lgsm/functions/command_validate.sh +++ b/lgsm/functions/command_validate.sh @@ -29,10 +29,10 @@ fn_validation(){ ${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" validate +quit| tee -a "${scriptlog}" fi if [ $? != 0 ]; then - fn_print_fail "Validating files: SteamCMD" + fn_print_fail_nl "Validating files: SteamCMD" fn_script_log_fatal "Validating files: SteamCMD: FAIL" else - fn_print_ok "Validating files: SteamCMD" + fn_print_ok_nl "Validating files: SteamCMD" fn_script_log_pass "Validating files: SteamCMD: OK" fi fix.sh From da0c2873147f0fae908a4394c46965afd9d9e673 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:50:48 +0100 Subject: [PATCH 175/195] Fully working test (hopefully) --- tests/tests_jc2server.sh | 223 +++++++++++++++++++++++++++++---------- 1 file changed, 166 insertions(+), 57 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 562ca4d7f..ad08850bf 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -5,6 +5,38 @@ # Website: https://gameservermanagers.com version="101716" +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + + +#### Variables #### + +# Notification Alerts +# (on|off) + +# Email +emailalert="off" +email="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" + +# Steam login +steamuser="anonymous" +steampass="" + +# Start Variables +updateonstart="off" + +fn_parms(){ +parms="" +} + #### Advanced Variables #### # Github Branch Select @@ -13,11 +45,15 @@ version="101716" githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" +githubbranch="exitcodes" # Steam appid="261140" -##### Script ##### +# Server Details +servicename="jc2-server" +gamename="Just Cause 2" +engine="avalanche" # Directories rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" @@ -36,10 +72,22 @@ servercfgfullpath="${servercfgdir}/${servercfg}" servercfgdefault="${servercfgdir}/default_config.lua" backupdir="${rootdir}/backups" -# Server Details -servicename="jc2-server" -gamename="Just Cause 2" -engine="avalanche" +# Logging +logdays="7" +#gamelogdir="" # No server logs available +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" +consolelogging="on" + +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" + +##### Script ##### +# Do not edit # Fetches core_dl for file downloads fn_fetch_core_dl(){ @@ -130,9 +178,9 @@ fn_setstatus(){ echo -ne "New status: ${currentstatus}\\r" if [ "${requiredstatus}" == "ONLINE" ]; then - ./jc2server start > /dev/null 2>&1 + (command_start.sh > /dev/null 2>&1) else - ./jc2server stop > /dev/null 2>&1 + (command_stop.sh > /dev/null 2>&1) fi if [ "${counter}" -gt "5" ]; then currentstatus="FAIL" @@ -154,11 +202,17 @@ fn_setstatus(){ # if excpecting a pass fn_test_result_pass(){ if [ $? != 0 ]; then - fn_print_fail_nl "Test Failed" + echo "=================================" + echo "Expected result: PASS" + echo "Actual result: FAIL" + fn_print_fail_nl "TEST FAILED" exitcode=1 core_exit.sh else - fn_print_ok_nl "Test Passed" + echo "=================================" + echo "Expected result: PASS" + echo "Actual result: PASS" + fn_print_ok_nl "TEST PASSED" echo "" fi } @@ -166,11 +220,17 @@ fn_test_result_pass(){ # if excpecting a fail fn_test_result_fail(){ if [ $? == 0 ]; then - fn_print_fail_nl "Test Failed" + echo "=================================" + echo "Expected result: FAIL" + echo "Actual result: PASS" + fn_print_fail_nl "TEST FAILED" exitcode=1 core_exit.sh else - fn_print_ok_nl "Test Passed" + echo "=================================" + echo "Expected result: FAIL" + echo "Actual result: FAIL" + fn_print_ok_nl "TEST PASSED" echo "" fi } @@ -189,38 +249,33 @@ echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" -echo "0.0 - Preparing Enviroment" +echo "0.0 - Enable dev-debug" echo "=================================" echo "Description:" echo "Preparing Enviroment to run tests" - -echo "Downloading jc2server" -wget https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/JustCause2/jc2server -chmod +x jc2server -echo "Create log dir" -mkdir -pv log/script/ -echo "Make functions executable" -chmod +x lgsm/functions/* +echo "" echo "Enable dev-debug" -./jc2server dev-debug +(command_dev_debug.sh) +fn_test_result_pass echo "1.0 - start - no files" echo "=================================" echo "Description:" echo "test script reaction to missing server files." -echo "" echo "Command: ./jc2server start" -./jc2server start +echo "" +(command_start.sh) fn_test_result_fail + echo "" echo "1.1 - getopt" echo "=================================" echo "Description:" echo "displaying options messages." -echo "" echo "Command: ./jc2server" -./jc2server +echo "" +(core_getopt.sh) fn_test_result_pass echo "" @@ -228,25 +283,21 @@ echo "1.2 - getopt with incorrect args" echo "=================================" echo "Description:" echo "displaying options messages." -echo "" echo "Command: ./jc2server abc123" -./jc2server abc123 +echo "" +getopt="abc123" +(core_getopt.sh) fn_test_result_fail echo "" echo "2.0 - install" echo "=================================" echo "Description:" -echo "install Just Cause 2 server." -echo "Command: ./jc2server abc123" -./jc2server auto-install +echo "install ${gamename} server." +echo "Command: ./jc2server auto-install" +(fn_autoinstall) fn_test_result_pass -echo "=================================" -ls -al -echo "=================================" -ls -al "${filesdir}" -echo "=================================" echo "" echo "3.1 - start" @@ -255,7 +306,8 @@ echo "Description:" echo "start ${gamename} server." echo "Command: ./jc2server start" requiredstatus="OFFLINE" -./jc2server start +fn_setstatus +(command_start.sh) fn_test_result_pass echo "" @@ -265,27 +317,40 @@ echo "Description:" echo "start ${gamename} server while already running." echo "Command: ./jc2server start" requiredstatus="ONLINE" -./jc2server start +fn_setstatus +(command_start.sh) fn_test_result_fail echo "" -echo "3.3 - stop" +echo "3.3 - start - updateonstart" +echo "=================================" +echo "Description:" +echo "will update server on start." +echo "Command: ./jc2server start" +requiredstatus="OFFLINE" +fn_setstatus +(updateonstart="on";command_start.sh) +fn_test_result_pass + +echo "" +echo "3.4 - stop" echo "=================================" echo "Description:" echo "stop ${gamename} server." echo "Command: ./jc2server stop" requiredstatus="ONLINE" -./jc2server stop +fn_setstatus +(command_stop.sh) fn_test_result_pass echo "" -echo "3.4 - stop - offline" +echo "3.5 - stop - offline" echo "=================================" echo "Description:" echo "stop ${gamename} server while already stopped." echo "Command: ./jc2server stop" requiredstatus="OFFLINE" -./jc2server stop +(command_stop.sh) fn_test_result_fail echo "" @@ -295,7 +360,19 @@ echo "Description:" echo "restart ${gamename}." echo "Command: ./jc2server restart" requiredstatus="ONLINE" -./jc2server restart +fn_setstatus +command_restart.sh +fn_test_result_pass + +echo "" +echo "3.7 - restart - offline" +echo "=================================" +echo "Description:" +echo "restart ${gamename} while already stopped." +echo "Command: ./jc2server restart" +requiredstatus="OFFLINE" +fn_setstatus +command_restart.sh fn_test_result_pass echo "4.1 - update" @@ -304,7 +381,8 @@ echo "Description:" echo "check for updates." echo "Command: ./jc2server update" requiredstatus="OFFLINE" -./jc2server update +fn_setstatus +(command_update.sh) fn_test_result_pass echo "" @@ -314,9 +392,10 @@ echo "Description:" echo "change the buildid tricking SteamCMD to update." echo "Command: ./jc2server update" requiredstatus="OFFLINE" +fn_setstatus fn_print_info_nl "changed buildid to 0." sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf" -./jc2server update +(command_update.sh) fn_test_result_pass echo "" @@ -326,9 +405,10 @@ echo "Description:" echo "change the buildid tricking SteamCMD to update server while already running." echo "Command: ./jc2server update" requiredstatus="ONLINE" +fn_setstatus fn_print_info_nl "changed buildid to 0." sed -i 's/[0-9]\+/0/' "${filesdir}/steamapps/appmanifest_${appid}.acf" -./jc2server update +(command_update.sh) fn_test_result_pass echo "" @@ -338,9 +418,10 @@ echo "Description:" echo "removing appmanifest file will cause script to repair." echo "Command: ./jc2server update" requiredstatus="OFFLINE" +fn_setstatus fn_print_info_nl "removed appmanifest_${appid}.acf." rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" -./jc2server update +(command_update.sh) fn_test_result_pass echo "" @@ -350,7 +431,19 @@ echo "Description:" echo "force-update bypassing update check." echo "Command: ./jc2server force-update" requiredstatus="OFFLINE" -./jc2server force-update +fn_setstatus +(forceupdate=1;command_update.sh) +fn_test_result_pass + +echo "" +echo "4.6 - force-update - online" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check server while already running." +echo "Command: ./jc2server force-update" +requiredstatus="ONLINE" +fn_setstatus +(forceupdate=1;command_update.sh) fn_test_result_pass echo "" @@ -360,7 +453,8 @@ echo "Description:" echo "validate server files." echo "Command: ./jc2server validate" requiredstatus="OFFLINE" -./jc2server validate +fn_setstatus +(command_validate.sh) fn_test_result_pass echo "" @@ -368,9 +462,11 @@ echo "4.8 - validate - online" echo "=================================" echo "Description:" echo "validate server files while server while already running." +echo "" echo "Command: ./jc2server validate" requiredstatus="ONLINE" -./jc2server validate +fn_setstatus +(command_validate.sh) fn_test_result_pass echo "" @@ -380,9 +476,11 @@ echo "Description:" echo "run monitor server while already running." echo "Command: ./jc2server monitor" requiredstatus="ONLINE" -./jc2server monitor +fn_setstatus +(command_monitor.sh) fn_test_result_pass + echo "" echo "5.2 - monitor - offline - with lockfile" echo "=================================" @@ -390,11 +488,13 @@ echo "Description:" echo "run monitor while server is offline with lockfile." echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" +fn_setstatus fn_print_info_nl "creating lockfile." date > "${rootdir}/${lockselfname}" -./jc2server monitor +(command_monitor.sh) fn_test_result_fail + echo "" echo "5.3 - monitor - offline - no lockfile" echo "=================================" @@ -402,7 +502,8 @@ echo "Description:" echo "run monitor while server is offline with no lockfile." echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" -./jc2server monitor +fn_setstatus +(command_monitor.sh) fn_test_result_fail echo "" @@ -412,12 +513,14 @@ echo "Description:" echo "gsquery.py will fail to query port." echo "Command: ./jc2server monitor" requiredstatus="ONLINE" +fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" -./jc2server monitor +(command_monitor.sh) fn_test_result_fail echo "" fn_print_info_nl "Reseting ${servercfg}." -wget -p "${servercfgfullpath}" https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/JustCause2/cfg/config.lua +install_config.sh +fn_test_result_fail echo "" echo "6.0 - details" @@ -426,7 +529,8 @@ echo "Description:" echo "display details." echo "Command: ./jc2server details" requiredstatus="ONLINE" -./jc2server details +fn_setstatus +command_details.sh fn_test_result_pass echo "" @@ -434,5 +538,10 @@ echo "=================================" echo "Server Tests - Complete!" echo "Using: ${gamename}" echo "=================================" -echo "" -requiredstatus="OFFLINE" \ No newline at end of file +requiredstatus="OFFLINE" +fn_setstatus +sleep 1 +fn_print_info "Tidying up directories." +sleep 1 +rm -rfv "${serverfiles}" +core_exit.sh From a47a56ba9d0920dd07682ed04ff704cf69f0dc72 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 11 Jul 2016 23:56:52 +0100 Subject: [PATCH 176/195] added create log dirs to prep --- tests/tests_jc2server.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index ad08850bf..17992fec8 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -249,12 +249,16 @@ echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" -echo "0.0 - Enable dev-debug" echo "=================================" echo "Description:" -echo "Preparing Enviroment to run tests" echo "" +(install_logs.sh) + + +echo "=================================" +echo "Description:" echo "Enable dev-debug" +echo "" (command_dev_debug.sh) fn_test_result_pass From 653b4e7b5e9b6cc077955fba7c93d9e21bd759b6 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 00:00:45 +0100 Subject: [PATCH 177/195] forgot brackets --- tests/tests_jc2server.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 17992fec8..06a4bb7d1 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -249,12 +249,15 @@ echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" +echo "0.1 - Create log dir's" echo "=================================" echo "Description:" +echo "Create log dir's" echo "" (install_logs.sh) +echo "0.2 - Enable dev-debug" echo "=================================" echo "Description:" echo "Enable dev-debug" @@ -365,7 +368,7 @@ echo "restart ${gamename}." echo "Command: ./jc2server restart" requiredstatus="ONLINE" fn_setstatus -command_restart.sh +(command_restart.sh) fn_test_result_pass echo "" @@ -376,7 +379,7 @@ echo "restart ${gamename} while already stopped." echo "Command: ./jc2server restart" requiredstatus="OFFLINE" fn_setstatus -command_restart.sh +(command_restart.sh) fn_test_result_pass echo "4.1 - update" From a2e6062ab845681f0f5cb6ae2dccff6eba868be4 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 00:10:55 +0100 Subject: [PATCH 178/195] added core_exit.sh --- lgsm/functions/monitor_gsquery.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/monitor_gsquery.sh b/lgsm/functions/monitor_gsquery.sh index ed158f89d..c28bed3bb 100644 --- a/lgsm/functions/monitor_gsquery.sh +++ b/lgsm/functions/monitor_gsquery.sh @@ -89,3 +89,4 @@ if [ "${gsquery}" == "yes" ]; then fi done fi +core_exit.sh \ No newline at end of file From ccb4077c6314b254021e4217a25281a6ef1c2ef5 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 00:20:15 +0100 Subject: [PATCH 179/195] changed to restart --- lgsm/functions/command_monitor.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lgsm/functions/command_monitor.sh b/lgsm/functions/command_monitor.sh index b58340911..44e8506e7 100644 --- a/lgsm/functions/command_monitor.sh +++ b/lgsm/functions/command_monitor.sh @@ -76,7 +76,7 @@ fn_monitor_tmux(){ alert.sh fn_script_log_info "Monitor is starting ${servername}" sleep 1 - command_start.sh + command_restart.sh fi } From dd0c0cd594c2303bcb7746f10468f3ba61042060 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 00:28:07 +0100 Subject: [PATCH 180/195] changed result to pass --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 06a4bb7d1..224acc1cf 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -499,7 +499,7 @@ fn_setstatus fn_print_info_nl "creating lockfile." date > "${rootdir}/${lockselfname}" (command_monitor.sh) -fn_test_result_fail +fn_test_result_pass echo "" From bee84a3033c73a4dcbfd8a7afed911213eac0f04 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 00:38:38 +0100 Subject: [PATCH 181/195] changed test result --- tests/tests_jc2server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 224acc1cf..684aa894c 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -525,9 +525,9 @@ sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" (command_monitor.sh) fn_test_result_fail echo "" -fn_print_info_nl "Reseting ${servercfg}." +fn_print_info_nl "Re-generating ${servercfg}." install_config.sh -fn_test_result_fail +echo "=================================" echo "" echo "6.0 - details" From f1258188ee968f04d493f1b177d7377bcf1782c6 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 08:50:51 +0100 Subject: [PATCH 182/195] added brackets --- tests/tests_jc2server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 684aa894c..0e6ca3e09 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -537,7 +537,7 @@ echo "display details." echo "Command: ./jc2server details" requiredstatus="ONLINE" fn_setstatus -command_details.sh +(command_details.sh) fn_test_result_pass echo "" From f1807e4b2403809860583024600c325b31f01cf0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 09:08:20 +0100 Subject: [PATCH 183/195] updated ts3 server tests --- tests/tests_ts3server.sh | 346 +++++++++++++++++++++++---------------- 1 file changed, 206 insertions(+), 140 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index f4a1d2769..d37fbadb1 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -1,20 +1,50 @@ #!/bin/bash -# TravisCI Tests +# TravisCI Tests: Teamspeak 3 # Server Management Script # Author: Daniel Gibbs # Website: https://gameservermanagers.com -version="071115" +version="101716" + +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + #### Variables #### -# Alert Email +# Notification Alerts # (on|off) + +# Email emailalert="off" -email="" +email="email@example.com" + +# Pushbullet +# https://www.pushbullet.com/#settings +pushbulletalert="off" +pushbullettoken="accesstoken" # Start Variables updateonstart="off" +fn_parms(){ +parms="" +} + +#### Advanced Variables #### + +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="dgibbs64" +githubrepo="linuxgsm" +githubbranch="$TRAVIS_BRANCH" + +# Steam +appid="261140" + # Server Details gamename="Teamspeak 3" servername="Teamspeak 3 Server" @@ -24,6 +54,9 @@ servicename="ts3-server" rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" lockselfname=".${servicename}.lock" +lgsmdir="${rootdir}/lgsm" +functionsdir="${lgsmdir}/functions" +libdir="${lgsmdir}/lib" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}" executabledir="${filesdir}" @@ -34,7 +67,6 @@ servercfgfullpath="${servercfgdir}/${servercfg}" servercfgdefault="${servercfgdir}/lgsm-default.ini" backupdir="${rootdir}/backups" - # Logging logdays="7" gamelogdir="${filesdir}/logs" @@ -45,67 +77,66 @@ emaillog="${scriptlogdir}/${servicename}-email.log" scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" -#### Advanced Variables #### - -# Github Branch Select -# Allows for the use of different function files -# from a different repo and/or branch. -githubuser="dgibbs64" -githubrepo="linuxgsm" -githubbranch="$TRAVIS_BRANCH" ##### Script ##### # Do not edit -fn_getgithubfile(){ -filename=$1 -exec=$2 -fileurl=${3:-$filename} -filepath="${rootdir}/${filename}" -filedir=$(dirname "${filepath}") -# If the function file is missing, then download -if [ ! -f "${filepath}" ]; then +# Fetches core_dl for file downloads +fn_fetch_core_dl(){ +github_file_url_dir="lgsm/functions" +github_file_url_name="${functionfile}" +filedir="${functionsdir}" +filename="${github_file_url_name}" +githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${github_file_url_dir}/${github_file_url_name}" +# If the file is missing, then download +if [ ! -f "${filedir}/${filename}" ]; then if [ ! -d "${filedir}" ]; then - mkdir "${filedir}" + mkdir -p "${filedir}" fi - githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" echo -e " fetching ${filename}...\c" - if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then - : + # Check curl exists and use available path + curlpaths="$(command -v curl 2>/dev/null) $(which curl >/dev/null 2>&1) /usr/bin/curl /bin/curl /usr/sbin/curl /sbin/curl)" + for curlcmd in ${curlpaths} + do + if [ -x "${curlcmd}" ]; then + break + fi + done + # If curl exists download file + if [ "$(basename ${curlcmd})" == "curl" ]; then + curlfetch=$(${curlcmd} -s --fail -o "${filedir}/${filename}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo "${curlfetch}" + echo -e "${githuburl}\n" + exit 1 + else + echo -e "\e[0;32mOK\e[0m" + fi else echo -e "\e[0;31mFAIL\e[0m\n" echo "Curl is not installed!" echo -e "" - exit - fi - curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) - if [ $? -ne 0 ]; then - echo -e "\e[0;31mFAIL\e[0m\n" - echo "${curl}" - echo -e "${githuburl}\n" - exit - else - echo -e "\e[0;32mOK\e[0m" + exit 1 fi - if [ "${exec}" ]; then - chmod +x "${filepath}" - fi -fi -if [ "${exec}" ]; then - source "${filepath}" + chmod +x "${filedir}/${filename}" fi +source "${filedir}/${filename}" } -fn_runfunction(){ - fn_getgithubfile "functions/${functionfile}" 1 +core_dl.sh(){ +# Functions are defined in core_functions.sh. +functionfile="${FUNCNAME}" +fn_fetch_core_dl } core_functions.sh(){ # Functions are defined in core_functions.sh. functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_core_dl } +core_dl.sh core_functions.sh fn_currentstatus_tmux(){ @@ -118,7 +149,7 @@ fn_currentstatus_tmux(){ } fn_currentstatus_ts3(){ -check_status.sh + check_status.sh if [ "${status}" != "0" ]; then currentstatus="ONLINE" else @@ -138,9 +169,9 @@ fn_setstatus(){ echo -ne "New status: ${currentstatus}\\r" if [ "${requiredstatus}" == "ONLINE" ]; then - (command_start.sh) + (command_start.sh > /dev/null 2>&1) else - (command_stop.sh) + (command_stop.sh > /dev/null 2>&1) fi if [ "${counter}" -gt "5" ]; then currentstatus="FAIL" @@ -157,6 +188,44 @@ fn_setstatus(){ sleep 0.5 } +# End of every test will expect the result to either pass or fail +# If the script does not do as intended the whole test will fail +# if excpecting a pass +fn_test_result_pass(){ + if [ $? != 0 ]; then + echo "=================================" + echo "Expected result: PASS" + echo "Actual result: FAIL" + fn_print_fail_nl "TEST FAILED" + exitcode=1 + core_exit.sh + else + echo "=================================" + echo "Expected result: PASS" + echo "Actual result: PASS" + fn_print_ok_nl "TEST PASSED" + echo "" + fi +} + +# if excpecting a fail +fn_test_result_fail(){ + if [ $? == 0 ]; then + echo "=================================" + echo "Expected result: FAIL" + echo "Actual result: PASS" + fn_print_fail_nl "TEST FAILED" + exitcode=1 + core_exit.sh + else + echo "=================================" + echo "Expected result: FAIL" + echo "Actual result: FAIL" + fn_print_ok_nl "TEST PASSED" + echo "" + fi +} + echo "=================================" echo "TravisCI Tests" echo "Linux Game Server Manager" @@ -164,232 +233,229 @@ echo "by Daniel Gibbs" echo "https://gameservermanagers.com" echo "=================================" echo "" -sleep 1 echo "=================================" echo "Server Tests" echo "Using: ${gamename}" +echo "Testing Branch: $TRAVIS_BRANCH" echo "=================================" echo "" -sleep 1 + +echo "0.1 - Create log dir's" +echo "=================================" +echo "Description:" +echo "Create log dir's" +echo "" +(install_logs.sh) +echo "0.2 - Enable dev-debug" +echo "=================================" +echo "Description:" +echo "Enable dev-debug" +echo "" +(command_dev_debug.sh) +fn_test_result_pass echo "1.0 - start - no files" echo "=================================" echo "Description:" echo "test script reaction to missing server files." +echo "Command: ./jc2server start" echo "" (command_start.sh) -echo "" -echo "Test complete!" -sleep 1 +fn_test_result_fail + echo "" echo "1.1 - getopt" echo "=================================" echo "Description:" echo "displaying options messages." +echo "Command: ./jc2server" echo "" (core_getopt.sh) +fn_test_result_pass + echo "" -echo "Test complete!" -sleep 1 +echo "1.2 - getopt with incorrect args" +echo "=================================" +echo "Description:" +echo "displaying options messages." +echo "Command: ./jc2server abc123" echo "" +getopt="abc123" +(core_getopt.sh) +fn_test_result_fail - - +echo "" echo "2.0 - install" echo "=================================" echo "Description:" echo "install ${gamename} server." -fn_autoinstall -echo "" -echo "Test complete!" -sleep 1 -echo "" - +echo "Command: ./jc2server auto-install" +(fn_autoinstall) +fn_test_result_pass +echo "" echo "3.1 - start" echo "=================================" echo "Description:" echo "start ${gamename} server." +echo "Command: ./jc2server start" requiredstatus="OFFLINE" fn_setstatus -command_start.sh -echo "" -echo "Test complete!" -sleep 1 +(command_start.sh) +fn_test_result_pass + echo "" echo "3.2 - start - online" echo "=================================" echo "Description:" echo "start ${gamename} server while already running." +echo "Command: ./jc2server start" requiredstatus="ONLINE" fn_setstatus (command_start.sh) -echo "" -echo "Test complete!" -sleep 1 +fn_test_result_fail + echo "" echo "3.3 - start - updateonstart" echo "=================================" echo "Description:" echo "will update server on start." +echo "Command: ./jc2server start" requiredstatus="OFFLINE" fn_setstatus -( - updateonstart="on" - command_start.sh -) -echo "" -echo "Test complete!" -sleep 1 +(updateonstart="on";command_start.sh) +fn_test_result_pass + echo "" echo "3.4 - stop" echo "=================================" echo "Description:" echo "stop ${gamename} server." +echo "Command: ./jc2server stop" requiredstatus="ONLINE" fn_setstatus -command_stop.sh -echo "" -echo "Test complete!" -sleep 1 +(command_stop.sh) +fn_test_result_pass + echo "" echo "3.5 - stop - offline" echo "=================================" echo "Description:" echo "stop ${gamename} server while already stopped." +echo "Command: ./jc2server stop" requiredstatus="OFFLINE" fn_setstatus (command_stop.sh) -echo "" -echo "Test complete!" -sleep 1 +fn_test_result_fail + echo "" echo "3.6 - restart" echo "=================================" echo "Description:" echo "restart ${gamename}." +echo "Command: ./jc2server restart" requiredstatus="ONLINE" fn_setstatus -command_restart.sh -echo "" -echo "Test complete!" -sleep 1 +(command_restart.sh) +fn_test_result_pass + echo "" echo "3.7 - restart - offline" echo "=================================" echo "Description:" echo "restart ${gamename} while already stopped." +echo "Command: ./jc2server restart" requiredstatus="OFFLINE" fn_setstatus -command_restart.sh -echo "" -echo "Test complete!" -sleep 1 -echo "" - - +(command_restart.sh) +fn_test_result_pass echo "4.1 - update" echo "=================================" echo "Description:" echo "check for updates." +echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_setstatus -update_check.sh -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.1 - update - old version" -echo "=================================" -echo "Description:" -echo "change the version number tricking LGSM to update." -requiredstatus="OFFLINE" -sed -i 's/[0-9]\+/0/g' ${gamelogdir}/ts3server*_0.log -fn_setstatus -update_check.sh -echo "" -echo "Test complete!" -sleep 1 -echo "" +(command_update.sh) +fn_test_result_pass +echo "" echo "5.1 - monitor - online" echo "=================================" echo "Description:" echo "run monitor server while already running." +echo "Command: ./jc2server monitor" requiredstatus="ONLINE" fn_setstatus (command_monitor.sh) +fn_test_result_pass + + echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "5.2 - monitor - offline - no lockfile" +echo "5.2 - monitor - offline - with lockfile" echo "=================================" echo "Description:" -echo "run monitor while server is offline with no lockfile." +echo "run monitor while server is offline with lockfile." +echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" fn_setstatus +fn_print_info_nl "creating lockfile." +date > "${rootdir}/${lockselfname}" (command_monitor.sh) +fn_test_result_pass + + echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "5.3 - monitor - offline - with lockfile" +echo "5.3 - monitor - offline - no lockfile" echo "=================================" echo "Description:" echo "run monitor while server is offline with no lockfile." +echo "Command: ./jc2server monitor" requiredstatus="OFFLINE" fn_setstatus -fn_print_info_nl "creating lockfile." -date > "${rootdir}/${lockselfname}" (command_monitor.sh) -echo "" -echo "Test complete!" -sleep 1 +fn_test_result_fail + echo "" echo "5.4 - monitor - gsquery.py failure" echo "=================================" echo "Description:" echo "gsquery.py will fail to query port." +echo "Command: ./jc2server monitor" requiredstatus="ONLINE" fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" (command_monitor.sh) +fn_test_result_fail echo "" -fn_print_info_nl "Reseting ${servercfg}." +fn_print_info_nl "Re-generating ${servercfg}." install_config.sh -echo "" -echo "Test complete!" -sleep 1 -echo "" - - +echo "=================================" +echo "" echo "6.0 - details" echo "=================================" echo "Description:" echo "display details." +echo "Command: ./jc2server details" requiredstatus="ONLINE" fn_setstatus -command_details.sh -echo "" -echo "Test complete!" -sleep 1 -echo "" +(command_details.sh) +fn_test_result_pass +echo "" echo "=================================" echo "Server Tests - Complete!" echo "Using: ${gamename}" echo "=================================" -echo "" requiredstatus="OFFLINE" fn_setstatus sleep 1 fn_print_info "Tidying up directories." sleep 1 -rm -rfv ${serverfiles} -echo "END" \ No newline at end of file +rm -rfv "${serverfiles}" +core_exit.sh From 6c1bc0d11678b0ef09827116895f178afdaa264f Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 09:08:37 +0100 Subject: [PATCH 184/195] removed fixed githubbranch --- tests/tests_jc2server.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 0e6ca3e09..407227f41 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -45,7 +45,6 @@ parms="" githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" -githubbranch="exitcodes" # Steam appid="261140" From a7c7b353dbe1d6d6ca3da6fce19b4e7b735f6614 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 12:30:28 +0100 Subject: [PATCH 185/195] removed appid --- tests/tests_ts3server.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index d37fbadb1..e4d71f484 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -11,7 +11,6 @@ if [ -f ".dev-debug" ]; then set -x fi - #### Variables #### # Notification Alerts @@ -42,9 +41,6 @@ githubuser="dgibbs64" githubrepo="linuxgsm" githubbranch="$TRAVIS_BRANCH" -# Steam -appid="261140" - # Server Details gamename="Teamspeak 3" servername="Teamspeak 3 Server" @@ -77,7 +73,6 @@ emaillog="${scriptlogdir}/${servicename}-email.log" scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" - ##### Script ##### # Do not edit From 6b21d766c721cc918e563e259b35f8b3215e770a Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 12:30:38 +0100 Subject: [PATCH 186/195] updated status checker --- tests/tests_jc2server.sh | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 407227f41..de39a9a9c 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -1,5 +1,5 @@ #!/bin/bash -# TravisCI Tests +# TravisCI Tests: Just Cause 2 # Server Management Script # Author: Daniel Gibbs # Website: https://gameservermanagers.com @@ -11,7 +11,6 @@ if [ -f ".dev-debug" ]; then set -x fi - #### Variables #### # Notification Alerts @@ -147,22 +146,21 @@ core_dl.sh core_functions.sh fn_currentstatus_tmux(){ -pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") -if [ "${pid}" != "0" ]; then - currentstatus="ONLINE" -else - currentstatus="OFFLINE" -fi + check_status.sh + if [ "${status}" != "0" ]; then + currentstatus="ONLINE" + else + currentstatus="OFFLINE" + fi } fn_currentstatus_ts3(){ -ts3status=$(${executable} status servercfgfullpathfile=${servercfgfullpath}) - -if [ "${ts3status}" == "Server is running" ]; then - currentstatus="ONLINE" -else - currentstatus="OFFLINE" -fi + check_status.sh + if [ "${status}" != "0" ]; then + currentstatus="ONLINE" + else + currentstatus="OFFLINE" + fi } fn_setstatus(){ @@ -273,7 +271,6 @@ echo "" (command_start.sh) fn_test_result_fail - echo "" echo "1.1 - getopt" echo "=================================" @@ -356,6 +353,7 @@ echo "Description:" echo "stop ${gamename} server while already stopped." echo "Command: ./jc2server stop" requiredstatus="OFFLINE" +fn_setstatus (command_stop.sh) fn_test_result_fail From cde3148c9d01c530017641a0becf1f0a04fba1fb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 12:32:17 +0100 Subject: [PATCH 187/195] spaces to tab --- tests/tests_ts3server.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index e4d71f484..94d021b0e 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -158,9 +158,9 @@ fn_setstatus(){ echo "Required status: ${requiredstatus}" counter=0 echo "Current status: ${currentstatus}" - while [ "${requiredstatus}" != "${currentstatus}" ]; do - counter=$((counter+1)) - fn_currentstatus_ts3 + while [ "${requiredstatus}" != "${currentstatus}" ]; do + counter=$((counter+1)) + fn_currentstatus_ts3 echo -ne "New status: ${currentstatus}\\r" if [ "${requiredstatus}" == "ONLINE" ]; then @@ -168,19 +168,19 @@ fn_setstatus(){ else (command_stop.sh > /dev/null 2>&1) fi - if [ "${counter}" -gt "5" ]; then - currentstatus="FAIL" - echo "Current status: ${currentstatus}" - echo "" - echo "Unable to start or stop server." - exit 1 - fi - done - echo -ne "New status: ${currentstatus}\\r" - echo -e "\n" - echo "Test starting:" - echo "" - sleep 0.5 + if [ "${counter}" -gt "5" ]; then + currentstatus="FAIL" + echo "Current status: ${currentstatus}" + echo "" + echo "Unable to start or stop server." + exit 1 + fi + done + echo -ne "New status: ${currentstatus}\\r" + echo -e "\n" + echo "Test starting:" + echo "" + sleep 0.5 } # End of every test will expect the result to either pass or fail From adbe729b0e66eff934ea5e044d956feaa19546b1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 12:49:46 +0100 Subject: [PATCH 188/195] added absolutepath to dev-debug --- lgsm/functions/command_dev_debug.sh | 6 ++--- tests/tests_ts3server.sh | 34 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lgsm/functions/command_dev_debug.sh b/lgsm/functions/command_dev_debug.sh index 08d31e976..bfaa86f18 100644 --- a/lgsm/functions/command_dev_debug.sh +++ b/lgsm/functions/command_dev_debug.sh @@ -9,12 +9,12 @@ local commandaction="Dev-Debug" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -if [ -f ".dev-debug" ]; then - rm .dev-debug +if [ -f "${rootdir}/.dev-debug" ]; then + rm "${rootdir}/.dev-debug" fn_print_ok_nl "Disabled dev-debug" fn_script_log_info "Disabled dev-debug" else - date > .dev-debug + date > "${rootdir}/.dev-debug" fn_print_ok_nl "Enabled dev-debug" fn_script_log_info "Enabled dev-debug" fi diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index 94d021b0e..882c12351 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -255,7 +255,7 @@ echo "1.0 - start - no files" echo "=================================" echo "Description:" echo "test script reaction to missing server files." -echo "Command: ./jc2server start" +echo "Command: ./ts3server start" echo "" (command_start.sh) fn_test_result_fail @@ -265,7 +265,7 @@ echo "1.1 - getopt" echo "=================================" echo "Description:" echo "displaying options messages." -echo "Command: ./jc2server" +echo "Command: ./ts3server" echo "" (core_getopt.sh) fn_test_result_pass @@ -275,7 +275,7 @@ echo "1.2 - getopt with incorrect args" echo "=================================" echo "Description:" echo "displaying options messages." -echo "Command: ./jc2server abc123" +echo "Command: ./ts3server abc123" echo "" getopt="abc123" (core_getopt.sh) @@ -286,7 +286,7 @@ echo "2.0 - install" echo "=================================" echo "Description:" echo "install ${gamename} server." -echo "Command: ./jc2server auto-install" +echo "Command: ./ts3server auto-install" (fn_autoinstall) fn_test_result_pass @@ -296,7 +296,7 @@ echo "3.1 - start" echo "=================================" echo "Description:" echo "start ${gamename} server." -echo "Command: ./jc2server start" +echo "Command: ./ts3server start" requiredstatus="OFFLINE" fn_setstatus (command_start.sh) @@ -307,7 +307,7 @@ echo "3.2 - start - online" echo "=================================" echo "Description:" echo "start ${gamename} server while already running." -echo "Command: ./jc2server start" +echo "Command: ./ts3server start" requiredstatus="ONLINE" fn_setstatus (command_start.sh) @@ -318,7 +318,7 @@ echo "3.3 - start - updateonstart" echo "=================================" echo "Description:" echo "will update server on start." -echo "Command: ./jc2server start" +echo "Command: ./ts3server start" requiredstatus="OFFLINE" fn_setstatus (updateonstart="on";command_start.sh) @@ -329,7 +329,7 @@ echo "3.4 - stop" echo "=================================" echo "Description:" echo "stop ${gamename} server." -echo "Command: ./jc2server stop" +echo "Command: ./ts3server stop" requiredstatus="ONLINE" fn_setstatus (command_stop.sh) @@ -340,7 +340,7 @@ echo "3.5 - stop - offline" echo "=================================" echo "Description:" echo "stop ${gamename} server while already stopped." -echo "Command: ./jc2server stop" +echo "Command: ./ts3server stop" requiredstatus="OFFLINE" fn_setstatus (command_stop.sh) @@ -351,7 +351,7 @@ echo "3.6 - restart" echo "=================================" echo "Description:" echo "restart ${gamename}." -echo "Command: ./jc2server restart" +echo "Command: ./ts3server restart" requiredstatus="ONLINE" fn_setstatus (command_restart.sh) @@ -362,7 +362,7 @@ echo "3.7 - restart - offline" echo "=================================" echo "Description:" echo "restart ${gamename} while already stopped." -echo "Command: ./jc2server restart" +echo "Command: ./ts3server restart" requiredstatus="OFFLINE" fn_setstatus (command_restart.sh) @@ -372,7 +372,7 @@ echo "4.1 - update" echo "=================================" echo "Description:" echo "check for updates." -echo "Command: ./jc2server update" +echo "Command: ./ts3server update" requiredstatus="OFFLINE" fn_setstatus (command_update.sh) @@ -383,7 +383,7 @@ echo "5.1 - monitor - online" echo "=================================" echo "Description:" echo "run monitor server while already running." -echo "Command: ./jc2server monitor" +echo "Command: ./ts3server monitor" requiredstatus="ONLINE" fn_setstatus (command_monitor.sh) @@ -395,7 +395,7 @@ echo "5.2 - monitor - offline - with lockfile" echo "=================================" echo "Description:" echo "run monitor while server is offline with lockfile." -echo "Command: ./jc2server monitor" +echo "Command: ./ts3server monitor" requiredstatus="OFFLINE" fn_setstatus fn_print_info_nl "creating lockfile." @@ -409,7 +409,7 @@ echo "5.3 - monitor - offline - no lockfile" echo "=================================" echo "Description:" echo "run monitor while server is offline with no lockfile." -echo "Command: ./jc2server monitor" +echo "Command: ./ts3server monitor" requiredstatus="OFFLINE" fn_setstatus (command_monitor.sh) @@ -420,7 +420,7 @@ echo "5.4 - monitor - gsquery.py failure" echo "=================================" echo "Description:" echo "gsquery.py will fail to query port." -echo "Command: ./jc2server monitor" +echo "Command: ./ts3server monitor" requiredstatus="ONLINE" fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" @@ -436,7 +436,7 @@ echo "6.0 - details" echo "=================================" echo "Description:" echo "display details." -echo "Command: ./jc2server details" +echo "Command: ./ts3server details" requiredstatus="ONLINE" fn_setstatus (command_details.sh) From 2b1ff033a79e538a54a8c52feb68ea723cf46d21 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 13:04:50 +0100 Subject: [PATCH 189/195] added exitbypass --- lgsm/functions/command_start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index 1bfa6e9d3..288c79e73 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -172,6 +172,7 @@ logs.sh # Will check for updates is updateonstart is yes if [ "${status}" == "0" ]; then if [ "${updateonstart}" == "yes" ]||[ "${updateonstart}" == "1" ]||[ "${updateonstart}" == "on" ]; then + exitbypass=1 command_update.sh fi fi From 309797e2dc91247dd543e7cf75f9451a468dbb0c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 14:01:54 +0100 Subject: [PATCH 190/195] updated appmanifest check --- lgsm/functions/update_steamcmd.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lgsm/functions/update_steamcmd.sh b/lgsm/functions/update_steamcmd.sh index 4db3c284e..f8a4efb06 100644 --- a/lgsm/functions/update_steamcmd.sh +++ b/lgsm/functions/update_steamcmd.sh @@ -74,12 +74,6 @@ fn_appmanifest_check(){ fn_update_request_log fi elif [ "${appmanifestfilewc}" -eq "0" ]; then - if [ "${forceupdate}" == "1" ]; then - fn_print_fail "Still no appmanifest_${appid}.acf found: Unable to update" - fn_script_log_fatal "Warning! Still no appmanifest_${appid}.acf found: Unable to update" - core_exit.sh - fi - forceupdate=1 fn_print_error "No appmanifest_${appid}.acf found" fn_script_log_error "No appmanifest_${appid}.acf found" sleep 1 @@ -88,6 +82,12 @@ fn_appmanifest_check(){ sleep 1 fn_update_steamcmd_dl fn_update_request_log + fn_appmanifest_info + if [ "${appmanifestfilewc}" -eq "0" ]; then + fn_print_fatal "Still no appmanifest_${appid}.acf found" + fn_script_log_fatal "Still no appmanifest_${appid}.acf found" + core_exit.sh + fi fi } From 67dd3430a115c745322d76e5c587e0fc22a31c93 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 14:12:26 +0100 Subject: [PATCH 191/195] added test update - online --- tests/tests_jc2server.sh | 18 ++++++++++++---- tests/tests_ts3server.sh | 45 +++++++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index de39a9a9c..169b6105d 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -169,9 +169,9 @@ fn_setstatus(){ echo "Required status: ${requiredstatus}" counter=0 echo "Current status: ${currentstatus}" - while [ "${requiredstatus}" != "${currentstatus}" ]; do - counter=$((counter+1)) - fn_currentstatus_tmux + while [ "${requiredstatus}" != "${currentstatus}" ]; do + counter=$((counter+1)) + fn_currentstatus_tmux echo -ne "New status: ${currentstatus}\\r" if [ "${requiredstatus}" == "ONLINE" ]; then @@ -379,7 +379,7 @@ fn_setstatus (command_restart.sh) fn_test_result_pass -echo "4.1 - update" +echo "4.1 - update - Offline" echo "=================================" echo "Description:" echo "check for updates." @@ -389,6 +389,16 @@ fn_setstatus (command_update.sh) fn_test_result_pass +echo "4.2 - update - Online" +echo "=================================" +echo "Description:" +echo "check for updates." +echo "Command: ./jc2server update" +requiredstatus="ONLINE" +fn_setstatus +(command_update.sh) +fn_test_result_pass + echo "" echo "4.2 - update - change buildid" echo "=================================" diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index 882c12351..aaa823d6c 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -168,19 +168,19 @@ fn_setstatus(){ else (command_stop.sh > /dev/null 2>&1) fi - if [ "${counter}" -gt "5" ]; then - currentstatus="FAIL" - echo "Current status: ${currentstatus}" - echo "" - echo "Unable to start or stop server." - exit 1 - fi - done - echo -ne "New status: ${currentstatus}\\r" - echo -e "\n" - echo "Test starting:" - echo "" - sleep 0.5 + if [ "${counter}" -gt "5" ]; then + currentstatus="FAIL" + echo "Current status: ${currentstatus}" + echo "" + echo "Unable to start or stop server." + exit 1 + fi + done + echo -ne "New status: ${currentstatus}\\r" + echo -e "\n" + echo "Test starting:" + echo "" + sleep 0.5 } # End of every test will expect the result to either pass or fail @@ -368,11 +368,28 @@ fn_setstatus (command_restart.sh) fn_test_result_pass -echo "4.1 - update" +echo "4.1 - update - Offline" +echo "=================================" +echo "Description:" +echo "check for updates." +echo "Command: ./jc2server update" +requiredstatus="OFFLINE" +fn_setstatus +(command_update.sh) +fn_test_result_pass + +echo "4.2 - update - Online" echo "=================================" echo "Description:" echo "check for updates." echo "Command: ./ts3server update" +requiredstatus="ONLINE" +fn_setstatus +(command_update.sh) +fn_test_result_pass +fn_setstatus +(command_update.sh) +fn_test_result_pass requiredstatus="OFFLINE" fn_setstatus (command_update.sh) From 526047c55cc61a5e6bea6c97320a63afe9e0f0f2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 14:22:37 +0100 Subject: [PATCH 192/195] bug fix --- tests/tests_ts3server.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index aaa823d6c..0971eeb4a 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -371,7 +371,7 @@ fn_test_result_pass echo "4.1 - update - Offline" echo "=================================" echo "Description:" -echo "check for updates." +echo "check for updates while offline." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_setstatus @@ -381,15 +381,8 @@ fn_test_result_pass echo "4.2 - update - Online" echo "=================================" echo "Description:" -echo "check for updates." +echo "check for updates while online." echo "Command: ./ts3server update" -requiredstatus="ONLINE" -fn_setstatus -(command_update.sh) -fn_test_result_pass -fn_setstatus -(command_update.sh) -fn_test_result_pass requiredstatus="OFFLINE" fn_setstatus (command_update.sh) From 1057e0889d33f5c1746f1f3bdd419573cd51dad9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 14:24:49 +0100 Subject: [PATCH 193/195] removed online test not required --- tests/tests_ts3server.sh | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index 0971eeb4a..b9add2928 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -368,26 +368,16 @@ fn_setstatus (command_restart.sh) fn_test_result_pass -echo "4.1 - update - Offline" +echo "4.1 - update" echo "=================================" echo "Description:" -echo "check for updates while offline." +echo "check for updates." echo "Command: ./jc2server update" requiredstatus="OFFLINE" fn_setstatus (command_update.sh) fn_test_result_pass -echo "4.2 - update - Online" -echo "=================================" -echo "Description:" -echo "check for updates while online." -echo "Command: ./ts3server update" -requiredstatus="OFFLINE" -fn_setstatus -(command_update.sh) -fn_test_result_pass - echo "" echo "5.1 - monitor - online" echo "=================================" From c6c988ae9b2e587b002a908f3572689e3171dfd7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 14:36:19 +0100 Subject: [PATCH 194/195] removed update online test --- tests/tests_jc2server.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/tests_jc2server.sh b/tests/tests_jc2server.sh index 169b6105d..cd147a928 100644 --- a/tests/tests_jc2server.sh +++ b/tests/tests_jc2server.sh @@ -379,7 +379,7 @@ fn_setstatus (command_restart.sh) fn_test_result_pass -echo "4.1 - update - Offline" +echo "4.1 - update" echo "=================================" echo "Description:" echo "check for updates." @@ -389,16 +389,6 @@ fn_setstatus (command_update.sh) fn_test_result_pass -echo "4.2 - update - Online" -echo "=================================" -echo "Description:" -echo "check for updates." -echo "Command: ./jc2server update" -requiredstatus="ONLINE" -fn_setstatus -(command_update.sh) -fn_test_result_pass - echo "" echo "4.2 - update - change buildid" echo "=================================" From ad806d5b7322c7f0e5ef2f1208d0a7da5022e925 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 12 Jul 2016 15:04:12 +0100 Subject: [PATCH 195/195] gsquery test not required for ts3 --- tests/tests_ts3server.sh | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/tests/tests_ts3server.sh b/tests/tests_ts3server.sh index b9add2928..b83e1169a 100644 --- a/tests/tests_ts3server.sh +++ b/tests/tests_ts3server.sh @@ -415,22 +415,6 @@ fn_setstatus (command_monitor.sh) fn_test_result_fail -echo "" -echo "5.4 - monitor - gsquery.py failure" -echo "=================================" -echo "Description:" -echo "gsquery.py will fail to query port." -echo "Command: ./ts3server monitor" -requiredstatus="ONLINE" -fn_setstatus -sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" -(command_monitor.sh) -fn_test_result_fail -echo "" -fn_print_info_nl "Re-generating ${servercfg}." -install_config.sh -echo "=================================" - echo "" echo "6.0 - details" echo "================================="