From 87b14ae5b8ae9b502928ad662401a95e7a2f1cee Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 21:39:22 +0000 Subject: [PATCH 01/42] New options menu concept --- functions/fn_getopt | 75 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/functions/fn_getopt b/functions/fn_getopt index 1b9b281d4..0ffdb9c4e 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -2,7 +2,7 @@ # LGSM fn_getopt function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 200615 +# Version: 301015 # Description: getopt arguments. @@ -113,6 +113,75 @@ esac exit } +fn_getopt_gmodserver(){ +case "$getopt" in + start) + fn_start;; + stop) + fn_stop;; + restart) + fn_restart;; + update) + fn_update_check;; + force-update|update-restart) + forceupdate=1; + fn_update_check;; + update-functions|updatefunctions) + fn_update_functions;; + validate) + fn_validate;; + monitor) + fn_monitor;; + email-test|emailtest) + fn_email_test;; + details) + fn_details;; + backup) + fn_backup;; + console) + fn_console;; + debug) + fn_debug;; + install) + fn_install;; + auto-install|autoinstall) + fn_autoinstall;; + content) +echo + fn_content_gmod;; + depsdetect) + fn_deps_detect;; + *) + echo "Usage: $0 [option] + +${gamename} - Linux Game Server Manager - Version ${version} +http://gameservermanagers.com/${selfname}" +echo -e "" +echo -e "\e[93mCommands\e[0m" + +{ + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." + echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content." + +} | column -s $'\t' -t +esac +exit +} + + fn_getopt_unreal(){ case "$getopt" in start) @@ -244,6 +313,8 @@ elif [ "${engine}" == "unreal2" ]; then fi elif [ "${engine}" == "unreal" ]; then fn_getopt_unreal +elif [ "$gamename" == "Garry's Mod" ]; then + fn_getopt_gmodserver else fn_getopt_generic -fi \ No newline at end of file +fi From 4a45f5d4bb159dd50a637f05f3b107359241e219 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 21:47:57 +0000 Subject: [PATCH 02/42] Removed the need for files to be created with column No longer need files to correctly display details in columns --- functions/fn_details | 116 +++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 76 deletions(-) diff --git a/functions/fn_details b/functions/fn_details index ea408876d..dfca7b1f4 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -2,7 +2,7 @@ # LGSM fn_details function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 281015 +# Version: 301015 # Description: Displays server infomation. @@ -20,9 +20,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "\e[34mHostname:\t\e[0m$HOSTNAME" echo -e "\e[34mtmux:\t\e[0m${tmuxv}" echo -e "\e[34mGLIBC:\t\e[0m${glibcv}" -} >> .fn_details_distro -column -s $'\t' -t .fn_details_distro -rm -f .fn_details_distro +} | column -s $'\t' -t } fn_details_performance(){ @@ -32,17 +30,13 @@ 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}" -} >> .fn_details_performance -column -s $'\t' -t .fn_details_performance -rm -f .fn_details_performance +} | 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" -} >> .fn_details_performance -column -s $'\t' -t .fn_details_performance -rm -f .fn_details_performance +} | column -s $'\t' -t } fn_details_disk(){ @@ -58,9 +52,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -d "${backupdir}" ]; then echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" fi -} >> .fn_details_disk -column -s $'\t' -t .fn_details_disk -rm -f .fn_details_disk +} | column -s $'\t' -t } fn_details_gameserver(){ @@ -132,9 +124,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${dbplugin}" ]; then echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}" fi -} >> .fn_details_gameserver -column -s $'\t' -t .fn_details_gameserver -rm -f .fn_details_gameserver +} | column -s $'\t' -t echo -e "" ## script details @@ -187,9 +177,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${networkcfgfullpath}" ]; then echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}" fi -} >> .fn_details_script -column -s $'\t' -t .fn_details_script -rm -f .fn_details_script +} | column -s $'\t' -t } fn_details_backup(){ @@ -205,9 +193,7 @@ else 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}" - } >> .fn_details_backup - column -s $'\t' -t .fn_details_backup - rm -f .fn_details_backup + } | column -s $'\t' -t fi } @@ -260,9 +246,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -288,9 +273,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -316,9 +300,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -353,9 +336,8 @@ fi echo -e "> Game\tINBOUND\t${port}\tudp" echo -e "> Steam: Query\tINBOUND\t${queryport}\tudp" echo -e "> Steam: Master traffic\tINBOUND\t${masterport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -384,9 +366,8 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game/RCON\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -417,9 +398,8 @@ echo -e "" echo -e "> SourceTV\tINBOUND\t${sourcetvport}\tudp" fi echo -e "< Client\tOUTBOUND\t${clientport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -449,9 +429,7 @@ echo -e "" echo -e "> Game/RCON\tINBOUND\t${port}\tudp" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -459,9 +437,8 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -490,9 +467,8 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -520,9 +496,8 @@ echo -e "" echo -e "> Voice\tINBOUND\t${port}\tudp" echo -e "> ServerQuery\tINBOUND\t${queryport}\ttcp" echo -e "> File transfer\tINBOUND\t${fileport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -549,9 +524,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -580,9 +554,8 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -613,9 +586,7 @@ echo -e "" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -623,9 +594,7 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} Telnet\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -633,9 +602,8 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -683,9 +651,7 @@ echo -e "" fi fi echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -694,9 +660,8 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = 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}" -} >> .fn_details_webadmin -column -s $'\t' -t .fn_details_webadmin -rm -f .fn_details_webadmin +} | column -s $'\t' -t + fn_details_statusbottom } @@ -725,9 +690,8 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL\tINI VARIABLE" echo -e "> Game\tINBOUND\t${port}\tudp\tPort=${port}" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } From 1c84eff59edb5406ee4d0ccf0b086b2d0db8b32e Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 21:52:43 +0000 Subject: [PATCH 03/42] as per https://github.com/koalaman/shellcheck/wiki/SC2060 --- functions/fn_details | 2 +- functions/fn_details_config | 2 +- functions/fn_install_glibcfix | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/fn_details b/functions/fn_details index dfca7b1f4..845eafca4 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -144,7 +144,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = # GLIBC required if [ -n "${glibcrequired}" ]; then - if [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" ]; then + if [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" ]; then if [ "${glibcfix}" == "yes" ]; then echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)" else diff --git a/functions/fn_details_config b/functions/fn_details_config index f8727f1f5..b42def2fe 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -8,7 +8,7 @@ ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo -# tr -cd [:digit:] leave only digits +# tr -cd '[:digit:]' leave only digits # tr -d '=\"; ' remove selected charectors =\"; # grep -v "foo" filter out lines that contain foo diff --git a/functions/fn_install_glibcfix b/functions/fn_install_glibcfix index 52868e908..18f1b0840 100644 --- a/functions/fn_install_glibcfix +++ b/functions/fn_install_glibcfix @@ -2,7 +2,7 @@ # LGSM fn_install_glibcfix function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 050715 +# Version: 301015 fn_glibcfixmsg(){ echo "" @@ -48,7 +48,7 @@ if [ -z $(command -v ldd) ]; then esac done # if Glibc less than 1.15 -elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 ]; then +elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 215 ]; then # Blade Symphony if [ "${gamename}" == "Blade Symphony" ]; then glibcversion="2.15" @@ -110,7 +110,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 wget -nv -N https://github.com/dgibbs64/linuxgsm/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" # if Glibc less than 1.13 - elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 213 ]; then + elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 213 ]; then # ARMA 3 if [ "${gamename}" == "ARMA 3" ]; then glibcversion="2.13" From cc91ee4f750ef315e6e7d7d836ed61375019b3e8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 21:57:17 +0000 Subject: [PATCH 04/42] corrected NOT SET not displaying for server password --- functions/fn_details_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_details_config b/functions/fn_details_config index b42def2fe..416d38133 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -309,7 +309,7 @@ elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then # server password if [ -f "${servercfgfullpath}" ]; then - serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password//g' | sed 's/"//g') + serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password //g' | sed 's/"//g') if [ ! -n "${serverpassword}" ]; then serverpassword="NOT SET" fi From 6a34713e1c195110ab189a8d914abaf2d3445ce9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:06:00 +0000 Subject: [PATCH 05/42] Altered as per https://github.com/koalaman/shellcheck/wiki/SC2060 --- functions/fn_details_config | 60 ++++++++++++++++++------------------- functions/fn_details_distro | 4 +-- functions/fn_install_ts3 | 4 +-- functions/fn_monitor_query | 8 ++--- functions/fn_start | 6 ++-- functions/fn_update_check | 8 ++--- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/functions/fn_details_config b/functions/fn_details_config index 416d38133..815153f23 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -52,7 +52,7 @@ if [ "${engine}" == "avalanche" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -62,7 +62,7 @@ if [ "${engine}" == "avalanche" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -95,7 +95,7 @@ elif [ "${engine}" == "dontstarve" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -115,7 +115,7 @@ elif [ "${engine}" == "dontstarve" ]; then # tickrate if [ -f "${servercfgfullpath}" ]; then - tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${tickrate}" ]; then tickrate="NOT SET" fi @@ -125,7 +125,7 @@ elif [ "${engine}" == "dontstarve" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -148,7 +148,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -158,7 +158,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -201,7 +201,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -211,7 +211,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -219,7 +219,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="0" @@ -227,7 +227,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # master port if [ -f "${servercfgfullpath}" ]; then - masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${masterport}" ]; then masterport="0" @@ -259,7 +259,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -279,7 +279,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -364,7 +364,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="9987" @@ -372,7 +372,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="10011" @@ -380,7 +380,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # file port if [ -f "${servercfgfullpath}" ]; then - fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${fileport}" ]; then fileport="30033" @@ -422,7 +422,7 @@ elif [ "${engine}" == "teeworlds" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="8303" @@ -430,7 +430,7 @@ elif [ "${engine}" == "teeworlds" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="12" fi @@ -444,7 +444,7 @@ elif [ "${engine}" == "terraria" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -484,7 +484,7 @@ elif [ "${engine}" == "unity3d" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -522,7 +522,7 @@ elif [ "${engine}" == "unity3d" ]; then # telnet port if [ -f "${servercfgfullpath}" ]; then - telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${telnetport}" ]; then telnetport="0" @@ -540,7 +540,7 @@ elif [ "${engine}" == "unity3d" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -570,7 +570,7 @@ elif [ "${engine}" == "unity3d" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -620,7 +620,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -636,7 +636,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # gamespy query port if [ -f "${servercfgfullpath}" ]; then - gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${gsqueryport}" ]; then gsqueryport="0" @@ -662,7 +662,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -750,7 +750,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -760,7 +760,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd "[:digit:]") + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -768,7 +768,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # rcon port if [ -f "${servercfgfullpath}" ]; then - rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${rconport}" ]; then rconport="0" @@ -776,7 +776,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="0" diff --git a/functions/fn_details_distro b/functions/fn_details_distro index b438f012f..11122d7f6 100644 --- a/functions/fn_details_distro +++ b/functions/fn_details_distro @@ -2,7 +2,7 @@ # LGSM fn_details_distro function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 270515 +# Version: 301015 # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for fn_details, fn_debug and fn_email. @@ -29,7 +29,7 @@ glibcv=$(ldd --version |grep ldd|awk '{print $NF}') # e.g: tmux 1.6 if [ -z "$(command -v tmux)" ]; then tmuxv="\e[0;31mNOT INSTALLED!\e[0m" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd [:digit:])" -lt "16" ]; then +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 tmuxv=$(tmux -V) diff --git a/functions/fn_install_ts3 b/functions/fn_install_ts3 index 67c6d5c9d..78246c0cf 100644 --- a/functions/fn_install_ts3 +++ b/functions/fn_install_ts3 @@ -2,7 +2,7 @@ # LGSM fn_install_ts3 function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 270715 +# Version: 301015 fn_details_distro # Gets the teamspeak server architecture @@ -19,7 +19,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 > .ts3_version_numbers_unsorted.tmp # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index e58387cc8..0b575bb42 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -2,7 +2,7 @@ # LGSM fn_monitor_query function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 030715 +# Version: 301015 # Description: uses gsquery.py to directly query the server. # Detects if the server has frozen. @@ -10,15 +10,15 @@ local modulename="Monitor" if [ -f "${rootdir}/gsquery.py" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd [:digit:]) + gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd '[:digit:]') port=$((${gameport} + 1)) elif [ "${engine}" == "spark" ]; then port=$((${port} + 1)) elif [ "${engine}" == "realvirtuality" ]; then - queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd [:digit:]) + queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd '[:digit:]') port=${queryport} elif [ "${engine}" == "unity3d" ]; then - gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd [:digit:]) + gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd '[:digit:]') port=$((${gameport} + 1)) fi fn_printinfo "Detected gsquery.py" diff --git a/functions/fn_start b/functions/fn_start index 8bb90da71..66d9ae355 100644 --- a/functions/fn_start +++ b/functions/fn_start @@ -2,7 +2,7 @@ # LGSM fn_start function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 291015 +# Version: 301015 # Description: Starts the server. @@ -126,11 +126,11 @@ 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 +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd [:digit:])" -eq "18" ]; then +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" diff --git a/functions/fn_update_check b/functions/fn_update_check index 9f289fe29..f41203b50 100644 --- a/functions/fn_update_check +++ b/functions/fn_update_check @@ -2,7 +2,7 @@ # LGSM fn_update_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 281015 +# Version: 301015 # Description: Checks if a server update is available. @@ -219,7 +219,7 @@ ts3arch=$(ls $(find ${filesdir}/ -name 'ts3server_*_*' 2> /dev/null | grep -v 't 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 # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp @@ -253,8 +253,8 @@ else fi # Removes dots so if can compare version numbers -currentbuilddigit=$(echo "${currentbuild}"|tr -cd "[:digit:]") -availablebuilddigit=$(echo "${availablebuild}"|tr -cd "[:digit:]") +currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') +availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then echo -e "\n" echo -e "Update available:" From c7f07c56e2c5761e2bce500d68f7e40b28dfe365 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:18:50 +0000 Subject: [PATCH 06/42] Revert "Removed the need for files to be created with column" This reverts commit 4a45f5d4bb159dd50a637f05f3b107359241e219. --- functions/fn_details | 116 ++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 40 deletions(-) diff --git a/functions/fn_details b/functions/fn_details index 845eafca4..a69830fa9 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -2,7 +2,7 @@ # LGSM fn_details function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 281015 # Description: Displays server infomation. @@ -20,7 +20,9 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "\e[34mHostname:\t\e[0m$HOSTNAME" echo -e "\e[34mtmux:\t\e[0m${tmuxv}" echo -e "\e[34mGLIBC:\t\e[0m${glibcv}" -} | column -s $'\t' -t +} >> .fn_details_distro +column -s $'\t' -t .fn_details_distro +rm -f .fn_details_distro } fn_details_performance(){ @@ -30,13 +32,17 @@ 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}" -} | column -s $'\t' -t +} >> .fn_details_performance +column -s $'\t' -t .fn_details_performance +rm -f .fn_details_performance 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" -} | column -s $'\t' -t +} >> .fn_details_performance +column -s $'\t' -t .fn_details_performance +rm -f .fn_details_performance } fn_details_disk(){ @@ -52,7 +58,9 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -d "${backupdir}" ]; then echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" fi -} | column -s $'\t' -t +} >> .fn_details_disk +column -s $'\t' -t .fn_details_disk +rm -f .fn_details_disk } fn_details_gameserver(){ @@ -124,7 +132,9 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${dbplugin}" ]; then echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}" fi -} | column -s $'\t' -t +} >> .fn_details_gameserver +column -s $'\t' -t .fn_details_gameserver +rm -f .fn_details_gameserver echo -e "" ## script details @@ -177,7 +187,9 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${networkcfgfullpath}" ]; then echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}" fi -} | column -s $'\t' -t +} >> .fn_details_script +column -s $'\t' -t .fn_details_script +rm -f .fn_details_script } fn_details_backup(){ @@ -193,7 +205,9 @@ else 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}" - } | column -s $'\t' -t + } >> .fn_details_backup + column -s $'\t' -t .fn_details_backup + rm -f .fn_details_backup fi } @@ -246,8 +260,9 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -273,8 +288,9 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -300,8 +316,9 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -336,8 +353,9 @@ fi echo -e "> Game\tINBOUND\t${port}\tudp" echo -e "> Steam: Query\tINBOUND\t${queryport}\tudp" echo -e "> Steam: Master traffic\tINBOUND\t${masterport}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -366,8 +384,9 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game/RCON\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -398,8 +417,9 @@ echo -e "" echo -e "> SourceTV\tINBOUND\t${sourcetvport}\tudp" fi echo -e "< Client\tOUTBOUND\t${clientport}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -429,7 +449,9 @@ echo -e "" echo -e "> Game/RCON\tINBOUND\t${port}\tudp" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" -} | column -s $'\t' -t +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -437,8 +459,9 @@ 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}" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -467,8 +490,9 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -496,8 +520,9 @@ echo -e "" echo -e "> Voice\tINBOUND\t${port}\tudp" echo -e "> ServerQuery\tINBOUND\t${queryport}\ttcp" echo -e "> File transfer\tINBOUND\t${fileport}\ttcp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -524,8 +549,9 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\ttcp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -554,8 +580,9 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -586,7 +613,9 @@ echo -e "" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" -} | column -s $'\t' -t +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -594,7 +623,9 @@ 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}" -} | column -s $'\t' -t +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports echo -e "" echo -e "\e[92m${servername} Telnet\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -602,8 +633,9 @@ 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}" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } @@ -651,7 +683,9 @@ echo -e "" fi fi echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" -} | column -s $'\t' -t +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -660,8 +694,9 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = 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}" -} | column -s $'\t' -t - +} >> .fn_details_webadmin +column -s $'\t' -t .fn_details_webadmin +rm -f .fn_details_webadmin fn_details_statusbottom } @@ -690,8 +725,9 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL\tINI VARIABLE" echo -e "> Game\tINBOUND\t${port}\tudp\tPort=${port}" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} | column -s $'\t' -t - +} >> .fn_details_ports +column -s $'\t' -t .fn_details_ports +rm -f .fn_details_ports fn_details_statusbottom } From 3e5254000ab7abe3780075fc4e73564f25f0b1ba Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:18:55 +0000 Subject: [PATCH 07/42] Revert "as per https://github.com/koalaman/shellcheck/wiki/SC2060" This reverts commit 1c84eff59edb5406ee4d0ccf0b086b2d0db8b32e. --- functions/fn_details | 2 +- functions/fn_details_config | 2 +- functions/fn_install_glibcfix | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/fn_details b/functions/fn_details index a69830fa9..ea408876d 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -154,7 +154,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = # GLIBC required if [ -n "${glibcrequired}" ]; then - if [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" ]; then + if [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" ]; then if [ "${glibcfix}" == "yes" ]; then echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)" else diff --git a/functions/fn_details_config b/functions/fn_details_config index 815153f23..1a6119e7f 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -8,7 +8,7 @@ ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo -# tr -cd '[:digit:]' leave only digits +# tr -cd [:digit:] leave only digits # tr -d '=\"; ' remove selected charectors =\"; # grep -v "foo" filter out lines that contain foo diff --git a/functions/fn_install_glibcfix b/functions/fn_install_glibcfix index 18f1b0840..52868e908 100644 --- a/functions/fn_install_glibcfix +++ b/functions/fn_install_glibcfix @@ -2,7 +2,7 @@ # LGSM fn_install_glibcfix function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 050715 fn_glibcfixmsg(){ echo "" @@ -48,7 +48,7 @@ if [ -z $(command -v ldd) ]; then esac done # if Glibc less than 1.15 -elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 215 ]; then +elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 ]; then # Blade Symphony if [ "${gamename}" == "Blade Symphony" ]; then glibcversion="2.15" @@ -110,7 +110,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 21 wget -nv -N https://github.com/dgibbs64/linuxgsm/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" # if Glibc less than 1.13 - elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 213 ]; then + elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 213 ]; then # ARMA 3 if [ "${gamename}" == "ARMA 3" ]; then glibcversion="2.13" From c184fa3a068593495926b0643043f5ca01819823 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:18:58 +0000 Subject: [PATCH 08/42] Revert "corrected NOT SET not displaying for server password" This reverts commit cc91ee4f750ef315e6e7d7d836ed61375019b3e8. --- functions/fn_details_config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_details_config b/functions/fn_details_config index 1a6119e7f..5f7fa48be 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -309,7 +309,7 @@ elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then # server password if [ -f "${servercfgfullpath}" ]; then - serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password //g' | sed 's/"//g') + serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password//g' | sed 's/"//g') if [ ! -n "${serverpassword}" ]; then serverpassword="NOT SET" fi From 1c036c0d748ecf47045a9b83fa212962a8f59de1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:19:02 +0000 Subject: [PATCH 09/42] Revert "Altered as per https://github.com/koalaman/shellcheck/wiki/SC2060" This reverts commit 6a34713e1c195110ab189a8d914abaf2d3445ce9. --- functions/fn_details_config | 60 ++++++++++++++++++------------------- functions/fn_details_distro | 4 +-- functions/fn_install_ts3 | 4 +-- functions/fn_monitor_query | 8 ++--- functions/fn_start | 6 ++-- functions/fn_update_check | 8 ++--- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/functions/fn_details_config b/functions/fn_details_config index 5f7fa48be..f8727f1f5 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -52,7 +52,7 @@ if [ "${engine}" == "avalanche" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd '[:digit:]') + slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -62,7 +62,7 @@ if [ "${engine}" == "avalanche" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -95,7 +95,7 @@ elif [ "${engine}" == "dontstarve" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -115,7 +115,7 @@ elif [ "${engine}" == "dontstarve" ]; then # tickrate if [ -f "${servercfgfullpath}" ]; then - tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") if [ ! -n "${tickrate}" ]; then tickrate="NOT SET" fi @@ -125,7 +125,7 @@ elif [ "${engine}" == "dontstarve" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -148,7 +148,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -158,7 +158,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -201,7 +201,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -211,7 +211,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') + port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -219,7 +219,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') + queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${queryport}" ]; then queryport="0" @@ -227,7 +227,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # master port if [ -f "${servercfgfullpath}" ]; then - masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') + masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${masterport}" ]; then masterport="0" @@ -259,7 +259,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -279,7 +279,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') + port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -364,7 +364,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="9987" @@ -372,7 +372,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${queryport}" ]; then queryport="10011" @@ -380,7 +380,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # file port if [ -f "${servercfgfullpath}" ]; then - fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${fileport}" ]; then fileport="30033" @@ -422,7 +422,7 @@ elif [ "${engine}" == "teeworlds" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="8303" @@ -430,7 +430,7 @@ elif [ "${engine}" == "teeworlds" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd '[:digit:]') + slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="12" fi @@ -444,7 +444,7 @@ elif [ "${engine}" == "terraria" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "port=" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "port=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -484,7 +484,7 @@ elif [ "${engine}" == "unity3d" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -522,7 +522,7 @@ elif [ "${engine}" == "unity3d" ]; then # telnet port if [ -f "${servercfgfullpath}" ]; then - telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd '[:digit:]') + telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${telnetport}" ]; then telnetport="0" @@ -540,7 +540,7 @@ elif [ "${engine}" == "unity3d" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd '[:digit:]') + slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -570,7 +570,7 @@ elif [ "${engine}" == "unity3d" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -620,7 +620,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd '[:digit:]') + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -636,7 +636,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # gamespy query port if [ -f "${servercfgfullpath}" ]; then - gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') + gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${gsqueryport}" ]; then gsqueryport="0" @@ -662,7 +662,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') + webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -750,7 +750,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]') + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd "[:digit:]") if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -760,7 +760,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd '[:digit:]') + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd "[:digit:]") fi if [ ! -n "${port}" ]; then port="0" @@ -768,7 +768,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # rcon port if [ -f "${servercfgfullpath}" ]; then - rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') + rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${rconport}" ]; then rconport="0" @@ -776,7 +776,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') + queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") fi if [ ! -n "${queryport}" ]; then queryport="0" diff --git a/functions/fn_details_distro b/functions/fn_details_distro index 11122d7f6..b438f012f 100644 --- a/functions/fn_details_distro +++ b/functions/fn_details_distro @@ -2,7 +2,7 @@ # LGSM fn_details_distro function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 270515 # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for fn_details, fn_debug and fn_email. @@ -29,7 +29,7 @@ glibcv=$(ldd --version |grep ldd|awk '{print $NF}') # e.g: tmux 1.6 if [ -z "$(command -v tmux)" ]; then tmuxv="\e[0;31mNOT INSTALLED!\e[0m" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:])' -lt "16" ]; then +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 tmuxv=$(tmux -V) diff --git a/functions/fn_install_ts3 b/functions/fn_install_ts3 index 78246c0cf..67c6d5c9d 100644 --- a/functions/fn_install_ts3 +++ b/functions/fn_install_ts3 @@ -2,7 +2,7 @@ # LGSM fn_install_ts3 function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 270715 fn_details_distro # Gets the teamspeak server architecture @@ -19,7 +19,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 > .ts3_version_numbers_unsorted.tmp # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index 0b575bb42..e58387cc8 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -2,7 +2,7 @@ # LGSM fn_monitor_query function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 030715 # Description: uses gsquery.py to directly query the server. # Detects if the server has frozen. @@ -10,15 +10,15 @@ local modulename="Monitor" if [ -f "${rootdir}/gsquery.py" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd '[:digit:]') + gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd [:digit:]) port=$((${gameport} + 1)) elif [ "${engine}" == "spark" ]; then port=$((${port} + 1)) elif [ "${engine}" == "realvirtuality" ]; then - queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd '[:digit:]') + queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd [:digit:]) port=${queryport} elif [ "${engine}" == "unity3d" ]; then - gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd '[:digit:]') + gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd [:digit:]) port=$((${gameport} + 1)) fi fn_printinfo "Detected gsquery.py" diff --git a/functions/fn_start b/functions/fn_start index 66d9ae355..8bb90da71 100644 --- a/functions/fn_start +++ b/functions/fn_start @@ -2,7 +2,7 @@ # LGSM fn_start function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 291015 # Description: Starts the server. @@ -126,11 +126,11 @@ 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 +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ]; then +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" diff --git a/functions/fn_update_check b/functions/fn_update_check index f41203b50..9f289fe29 100644 --- a/functions/fn_update_check +++ b/functions/fn_update_check @@ -2,7 +2,7 @@ # LGSM fn_update_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 281015 # Description: Checks if a server update is available. @@ -219,7 +219,7 @@ ts3arch=$(ls $(find ${filesdir}/ -name 'ts3server_*_*' 2> /dev/null | grep -v 't 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 # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp @@ -253,8 +253,8 @@ else fi # Removes dots so if can compare version numbers -currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') -availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') +currentbuilddigit=$(echo "${currentbuild}"|tr -cd "[:digit:]") +availablebuilddigit=$(echo "${availablebuild}"|tr -cd "[:digit:]") if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then echo -e "\n" echo -e "Update available:" From 6fe808f42a58af1b9007f618dd5306a269e14bdf Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:22:07 +0000 Subject: [PATCH 10/42] Reverted to master fn_getopt --- functions/fn_getopt | 75 ++------------------------------------------- 1 file changed, 2 insertions(+), 73 deletions(-) diff --git a/functions/fn_getopt b/functions/fn_getopt index 0ffdb9c4e..1b9b281d4 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -2,7 +2,7 @@ # LGSM fn_getopt function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 200615 # Description: getopt arguments. @@ -113,75 +113,6 @@ esac exit } -fn_getopt_gmodserver(){ -case "$getopt" in - start) - fn_start;; - stop) - fn_stop;; - restart) - fn_restart;; - update) - fn_update_check;; - force-update|update-restart) - forceupdate=1; - fn_update_check;; - update-functions|updatefunctions) - fn_update_functions;; - validate) - fn_validate;; - monitor) - fn_monitor;; - email-test|emailtest) - fn_email_test;; - details) - fn_details;; - backup) - fn_backup;; - console) - fn_console;; - debug) - fn_debug;; - install) - fn_install;; - auto-install|autoinstall) - fn_autoinstall;; - content) -echo - fn_content_gmod;; - depsdetect) - fn_deps_detect;; - *) - echo "Usage: $0 [option] - -${gamename} - Linux Game Server Manager - Version ${version} -http://gameservermanagers.com/${selfname}" -echo -e "" -echo -e "\e[93mCommands\e[0m" - -{ - echo -e "\e[34mstart\t\e[0mStart the server." - echo -e "\e[34mstop\t\e[0mStop the server." - echo -e "\e[34mrestart\t\e[0mRestart the server." - echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." - echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." - echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." - echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." - echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mCreate archive of the server." - echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mInstall the server." - echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." - echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content." - -} | column -s $'\t' -t -esac -exit -} - - fn_getopt_unreal(){ case "$getopt" in start) @@ -313,8 +244,6 @@ elif [ "${engine}" == "unreal2" ]; then fi elif [ "${engine}" == "unreal" ]; then fn_getopt_unreal -elif [ "$gamename" == "Garry's Mod" ]; then - fn_getopt_gmodserver else fn_getopt_generic -fi +fi \ No newline at end of file From 6bc5d75e78490f94cad4043edc7f9e949cdd76f3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:30:53 +0000 Subject: [PATCH 11/42] Added menu concept back in --- functions/fn_getopt | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/functions/fn_getopt b/functions/fn_getopt index 1b9b281d4..aba034efe 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -113,6 +113,74 @@ esac exit } +fn_getopt_gmodserver(){ +case "$getopt" in + start) + fn_start;; + stop) + fn_stop;; + restart) + fn_restart;; + update) + fn_update_check;; + force-update|update-restart) + forceupdate=1; + fn_update_check;; + update-functions|updatefunctions) + fn_update_functions;; + validate) + fn_validate;; + monitor) + fn_monitor;; + email-test|emailtest) + fn_email_test;; + details) + fn_details;; + backup) + fn_backup;; + console) + fn_console;; + debug) + fn_debug;; + install) + fn_install;; + auto-install|autoinstall) + fn_autoinstall;; + content) +echo + fn_content_gmod;; + depsdetect) + fn_deps_detect;; + *) + echo "Usage: $0 [option] + +${gamename} - Linux Game Server Manager - Version ${version} +http://gameservermanagers.com/${selfname}" +echo -e "" +echo -e "\e[93mCommands\e[0m" + +{ + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." + echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content." + +} | column -s $'\t' -t +esac +exit +} + fn_getopt_unreal(){ case "$getopt" in start) From 3773818f2cbd762cba51e8827328f040b75649d3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:31:13 +0000 Subject: [PATCH 12/42] date --- functions/fn_getopt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_getopt b/functions/fn_getopt index aba034efe..56d3507f5 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -2,7 +2,7 @@ # LGSM fn_getopt function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 200615 +# Version: 301015 # Description: getopt arguments. From da0dc10e999f79a1807de8ebddf009c3585c10ee Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:37:19 +0000 Subject: [PATCH 13/42] Adding deps to tests Want to see the results --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a2d1726d6..8c7e9a36b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: bash before_script: - curl -L "https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz" | tar zx + - sudo apt-get install tmux mailutils postfix lib32gcc1 libstdc++6 libstdc++6:i386 - mkdir /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles - touch /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles/serverconfig.xml From f46be948e2d41602478be7bc76f8c5f14fdfddc9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:38:38 +0000 Subject: [PATCH 14/42] correction --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8c7e9a36b..52a01b49d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,8 @@ language: bash before_script: - curl -L "https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz" | tar zx - - sudo apt-get install tmux mailutils postfix lib32gcc1 libstdc++6 libstdc++6:i386 + - sudo apt-get update -qq + - sudo apt-get install -y tmux mailutils postfix lib32gcc1 libstdc++6 libstdc++6:i386 - mkdir /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles - touch /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles/serverconfig.xml From 053c62ef58afff8f05ab3731f42a13adbe808897 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 22:46:10 +0000 Subject: [PATCH 15/42] minor bug --- functions/fn_details_distro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_details_distro b/functions/fn_details_distro index 11122d7f6..4246d4a89 100644 --- a/functions/fn_details_distro +++ b/functions/fn_details_distro @@ -29,7 +29,7 @@ glibcv=$(ldd --version |grep ldd|awk '{print $NF}') # e.g: tmux 1.6 if [ -z "$(command -v tmux)" ]; then tmuxv="\e[0;31mNOT INSTALLED!\e[0m" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:])' -lt "16" ]; then +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 tmuxv=$(tmux -V) From 3f9eb50c05affc3fcee5d8b14beb2eb1845ed55c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Fri, 30 Oct 2015 23:04:23 +0000 Subject: [PATCH 16/42] trying container infra on travis --- .travis.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52a01b49d..95a170f9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,25 @@ language: bash +sudo: false +env: +- DISTRO=ubuntu-trusty before_script: - curl -L "https://shunit2.googlecode.com/files/shunit2-2.1.6.tgz" | tar zx - - sudo apt-get update -qq - - sudo apt-get install -y tmux mailutils postfix lib32gcc1 libstdc++6 libstdc++6:i386 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - tmux + - mailutils + - postfix + - lib32gcc1 + - libstdc++6 + - libstdc++6:i386 + - telnet + - expect + - mkdir /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles - touch /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles/serverconfig.xml From 5c171bedd082b026b94ee90d389b42084b654339 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 03:24:40 +0000 Subject: [PATCH 17/42] removed space --- Arma3/arma3server | 1 - 1 file changed, 1 deletion(-) diff --git a/Arma3/arma3server b/Arma3/arma3server index 4620961fe..437d05a88 100644 --- a/Arma3/arma3server +++ b/Arma3/arma3server @@ -1,4 +1,3 @@ - #!/bin/bash # ARMA 3 # Server Management Script From 5d3337c8a4a139b6864494c8356532f9dcc30bdb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 03:27:57 +0000 Subject: [PATCH 18/42] Started work on test script --- test.sh | 353 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100644 test.sh diff --git a/test.sh b/test.sh new file mode 100644 index 000000000..f2e6cc30c --- /dev/null +++ b/test.sh @@ -0,0 +1,353 @@ +#!/bin/bash +# Just Cause 2 +# Server Management Script +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +version="150715" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="off" +email="email@example.com" + +# Steam login +steamuser="anonymous" +steampass="" + +# Start Variables +updateonstart="off" + +fn_parms(){ +parms="" +} + +#### Advanced Variables #### + +# Steam +appid="261140" + +# Server Details +servicename="jc2-server" +gamename="Just Cause 2" +engine="avalanche" + +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +selfname="$(basename $0)" +lockselfname=".${servicename}.lock" +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" + +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 + +fn_runfunction(){ +# Functions are downloaded and run with this function +if [ ! -f "${rootdir}/functions/${functionfile}" ]; then + cd "${rootdir}" + if [ ! -d "functions" ]; then + mkdir functions + fi + cd functions + echo -e " loading ${functionfile}...\c" + wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- + chmod +x "${functionfile}" + cd "${rootdir}" +fi +source "${rootdir}/functions/${functionfile}" +} + +fn_functions(){ +# Functions are defined in fn_functions. +functionfile="${FUNCNAME}" +fn_runfunction +} + +fn_functions + +getopt=$1 + +fn_currentstatus(){ +pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") +if [ "${pid}" == "0" ]; then + currentstatus="OFFLINE" +else + currentstatus="ONLINE" +fi +} + +fn_setstatus(){ + fn_currentstatus + + echo"" + echo "Required status: ${requiredstatus}" + while [ "${requiredstatus}" != "${currentstatus}" ]; do + fn_currentstatus + echo -ne "Current status: ${currentstatus}\\r" + if [ "${requiredstatus}" == "ONLINE" ]; then + (fn_start > /dev/null 2>&1) + else + (fn_stop > /dev/null 2>&1) + fi + done + echo -ne "Current status: ${currentstatus}\\r" + echo -e "\n" + echo "Test starting:" + echo "" + sleep 0.5 +} + +echo "1.0 - start - no files" +echo "=================================" +echo "Description:" +echo "Test script reaction to missing server files." +requiredstatus="OFFLINE" +fn_setstatus +(fn_start) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "2.0 - install" +echo "=================================" +echo "Description:" +echo "install ${gamename} server." +requiredstatus="OFFLINE" +fn_setstatus +fn_autoinstall +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.1 - start" +echo "=================================" +echo "Description:" +echo "start ${gamename} server." +requiredstatus="OFFLINE" +fn_setstatus +fn_start +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.2 - start - online" +echo "=================================" +echo "Description:" +echo "start ${gamename} server while already running." +requiredstatus="ONLINE" +fn_setstatus +(fn_start) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.3 - stop" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server." +requiredstatus="ONLINE" +fn_setstatus +fn_stop +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.4 - stop - offline" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server while already stopped." +requiredstatus="OFFLINE" +fn_setstatus +(fn_stop) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.5 - restart" +echo "=================================" +echo "Description:" +echo "restart ${gamename}." +requiredstatus="ONLINE" +fn_setstatus +fn_restart +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.5 - restart - offline" +echo "=================================" +echo "Description:" +echo "restart ${gamename} while already stopped." +requiredstatus="OFFLINE" +fn_setstatus +fn_restart +echo "" +echo "Test complete!" +sleep 1 +echo "" + +echo "4.1 - update" +echo "=================================" +echo "Description:" +echo "check for updates." +requiredstatus="OFFLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.2 - update - change buildid" +echo "=================================" +echo "Description:" +echo "change the buildid tricking SteamCMD to update." +requiredstatus="OFFLINE" +fn_setstatus +fn_printinfonl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +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_printinfonl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +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_printinfonl "removed appmanifest_${appid}.acf." +rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.5 - force-update" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check." +requiredstatus="OFFLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.6 - force-update - online" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check server while already running." +requiredstatus="ONLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.7 - validate" +echo "=================================" +echo "Description:" +echo "validate server files." +requiredstatus="OFFLINE" +fn_setstatus +fn_validate +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.8 - validate - online" +echo "=================================" +echo "Description:" +echo "validate server files while server while already running." +requiredstatus="ONLINE" +fn_setstatus +fn_validate +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "5.1 - monitor - online" +echo "=================================" +echo "Description:" +echo "run monitor server while already running." +requiredstatus="ONLINE" +fn_setstatus +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +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 +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "5.2 - monitor - offline - with lockfile" +echo "=================================" +echo "Description:" +echo "run monitor while server is offline with no lockfile" +requiredstatus="OFFLINE" +fn_setstatus +fn_printinfonl "creating lockfile." +date > "${rootdir}/${lockselfname}" +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "5.2 - monitor - gsquery.py failure" +echo "=================================" +echo "Description:" +echo "gsquery.py will fail to query port" +requiredstatus="ONLINE" +fn_setstatus +port=${port+1} +(fn_monitor) +port=${port-1} +echo "" +echo "Test complete!" +sleep 1 +echo "" + From ddf9b26de8d25d0b7c4f545050036274126ccae3 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 12:19:16 +0000 Subject: [PATCH 19/42] New test script --- .travis.yml | 158 +--------------------------------------------------- test.sh | 66 ++++++++++++++++++---- 2 files changed, 57 insertions(+), 167 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95a170f9d..85148ae4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,162 +20,6 @@ addons: - telnet - expect - - - mkdir /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles - - touch /home/travis/build/dgibbs64/linuxgsm/7DaysToDie/serverfiles/serverconfig.xml - - - mkdir /home/travis/build/dgibbs64/linuxgsm/CounterStrike/serverfiles/ - - mkdir /home/travis/build/dgibbs64/linuxgsm/CounterStrike/serverfiles/cstrike - - - mkdir /home/travis/build/dgibbs64/linuxgsm/CounterStrikeGlobalOffensive/serverfiles/ - - mkdir /home/travis/build/dgibbs64/linuxgsm/CounterStrikeGlobalOffensive/serverfiles/csgo - - mkdir /home/travis/build/dgibbs64/linuxgsm/CounterStrikeGlobalOffensive/serverfiles/csgo/cfg - - - mkdir /home/travis/build/dgibbs64/linuxgsm/JustCause2/serverfiles/ - - touch /home/travis/build/dgibbs64/linuxgsm/JustCause2/serverfiles/default_config.lua - - - mkdir /home/travis/build/dgibbs64/linuxgsm/KillingFloor/serverfiles - - mkdir /home/travis/build/dgibbs64/linuxgsm/KillingFloor/serverfiles/System - - touch /home/travis/build/dgibbs64/linuxgsm/KillingFloor/serverfiles/System/Default.ini - - - mkdir /home/travis/build/dgibbs64/linuxgsm/ProjectZomboid/Zomboid - - mkdir /home/travis/build/dgibbs64/linuxgsm/ProjectZomboid/Zomboid/Server - - mkdir /home/travis/build/dgibbs64/linuxgsm/ProjectZomboid/serverfiles - - mkdir /home/travis/build/dgibbs64/linuxgsm/ProjectZomboid/serverfiles/projectzomboid - - - mkdir /home/travis/build/dgibbs64/linuxgsm/SeriousSam3BFE/serverfiles - - mkdir /home/travis/build/dgibbs64/linuxgsm/SeriousSam3BFE/serverfiles/Content/ - - mkdir /home/travis/build/dgibbs64/linuxgsm/SeriousSam3BFE/serverfiles/Content/SeriousSam3 - - mkdir /home/travis/build/dgibbs64/linuxgsm/SeriousSam3BFE/serverfiles/Content/SeriousSam3/Config - - mkdir /home/travis/build/dgibbs64/linuxgsm/SeriousSam3BFE/serverfiles/Bin - - - mkdir /home/travis/build/dgibbs64/linuxgsm/UnrealTournament2004/serverfiles - - mkdir /home/travis/build/dgibbs64/linuxgsm/UnrealTournament2004/serverfiles/System - - touch /home/travis/build/dgibbs64/linuxgsm/UnrealTournament2004/serverfiles/System/ut2k4-server.ini - - - mkdir /home/travis/build/dgibbs64/linuxgsm/UnrealTournament99/serverfiles - - mkdir /home/travis/build/dgibbs64/linuxgsm/UnrealTournament99/serverfiles/System - - touch /home/travis/build/dgibbs64/linuxgsm/UnrealTournament99/serverfiles/System/ut99-server.ini - - mkdir /home/travis/build/dgibbs64/linuxgsm/TeamSpeak3/serverfiles script: - - bash 7DaysToDie/sdtdserver auto-install - - bash 7DaysToDie/sdtdserver start - - bash 7DaysToDie/sdtdserver stop - - bash 7DaysToDie/sdtdserver restart - - bash 7DaysToDie/sdtdserver validate - - bash 7DaysToDie/sdtdserver monitor - - bash 7DaysToDie/sdtdserver email-test - - bash 7DaysToDie/sdtdserver details - - - bash Arma3/arma3server auto-install - - bash Arma3/arma3server start - - bash Arma3/arma3server stop - - bash Arma3/arma3server restart - - bash Arma3/arma3server validate - - bash Arma3/arma3server monitor - - bash Arma3/arma3server email-test - - bash Arma3/arma3server details - - - bash CounterStrike/csserver auto-install - - bash CounterStrike/csserver start - - bash CounterStrike/csserver stop - - bash CounterStrike/csserver restart - - bash CounterStrike/csserver validate - - bash CounterStrike/csserver monitor - - bash CounterStrike/csserver email-test - - bash CounterStrike/csserver details - - - bash CounterStrikeGlobalOffensive/csgoserver auto-install - - bash CounterStrikeGlobalOffensive/csgoserver start - - bash CounterStrikeGlobalOffensive/csgoserver stop - - bash CounterStrikeGlobalOffensive/csgoserver restart - - bash CounterStrikeGlobalOffensive/csgoserver validate - - bash CounterStrikeGlobalOffensive/csgoserver monitor - - bash CounterStrikeGlobalOffensive/csgoserver email-test - - bash CounterStrikeGlobalOffensive/csgoserver details - - - bash JustCause2/jc2server auto-install - - bash JustCause2/jc2server start - - bash JustCause2/jc2server stop - - bash JustCause2/jc2server restart - - bash JustCause2/jc2server validate - - bash JustCause2/jc2server monitor - - bash JustCause2/jc2server email-test - - bash JustCause2/jc2server details - - - bash KillingFloor/kfserver auto-install - - bash KillingFloor/kfserver start - - bash KillingFloor/kfserver stop - - bash KillingFloor/kfserver restart - - bash KillingFloor/kfserver validate - - bash KillingFloor/kfserver monitor - - bash KillingFloor/kfserver email-test - - bash KillingFloor/kfserver details - - - bash NaturalSelection2/ns2server auto-install - - bash NaturalSelection2/ns2server start - - bash NaturalSelection2/ns2server stop - - bash NaturalSelection2/ns2server restart - - bash NaturalSelection2/ns2server validate - - bash NaturalSelection2/ns2server monitor - - bash NaturalSelection2/ns2server email-test - - bash NaturalSelection2/ns2server details - - - bash ProjectZomboid/pzserver auto-install - - bash ProjectZomboid/pzserver start - - bash ProjectZomboid/pzserver stop - - bash ProjectZomboid/pzserver restart - - bash ProjectZomboid/pzserver validate - - bash ProjectZomboid/pzserver monitor - - bash ProjectZomboid/pzserver email-test - - bash ProjectZomboid/pzserver details - - - bash SeriousSam3BFE/ss3sserver auto-install - - bash SeriousSam3BFE/ss3sserver start - - bash SeriousSam3BFE/ss3sserver stop - - bash SeriousSam3BFE/ss3sserver restart - - bash SeriousSam3BFE/ss3sserver validate - - bash SeriousSam3BFE/ss3sserver monitor - - bash SeriousSam3BFE/ss3sserver email-test - - bash SeriousSam3BFE/ss3sserver details - - - bash StarBound/sbserver auto-install - - bash StarBound/sbserver start - - bash StarBound/sbserver stop - - bash StarBound/sbserver restart - - bash StarBound/sbserver validate - - bash StarBound/sbserver monitor - - bash StarBound/sbserver email-test - - bash StarBound/sbserver details - - - bash Terraria/terrariaserver auto-install - - bash Terraria/terrariaserver start - - bash Terraria/terrariaserver stop - - bash Terraria/terrariaserver restart - - bash Terraria/terrariaserver validate - - bash Terraria/terrariaserver monitor - - bash Terraria/terrariaserver email-test - - bash Terraria/terrariaserver details - - - bash UnrealTournament2004/ut2k4server start - - bash UnrealTournament2004/ut2k4server stop - - bash UnrealTournament2004/ut2k4server restart - - bash UnrealTournament2004/ut2k4server monitor - - bash UnrealTournament2004/ut2k4server email-test - - bash UnrealTournament2004/ut2k4server details - - - bash UnrealTournament99/ut99server start - - bash UnrealTournament99/ut99server stop - - bash UnrealTournament99/ut99server restart - - bash UnrealTournament99/ut99server monitor - - bash UnrealTournament99/ut99server email-test - - bash UnrealTournament99/ut99server details - - - bash TeamSpeak3/ts3server start - - bash TeamSpeak3/ts3server stop - - bash TeamSpeak3/ts3server restart - - bash TeamSpeak3/ts3server update - - bash TeamSpeak3/ts3server monitor - - bash TeamSpeak3/ts3server email-test - - bash TeamSpeak3/ts3server details + - bash test.sh \ No newline at end of file diff --git a/test.sh b/test.sh index f2e6cc30c..ce8efa06e 100644 --- a/test.sh +++ b/test.sh @@ -9,8 +9,8 @@ version="150715" # Notification Email # (on|off) -emailnotification="off" -email="email@example.com" +emailnotification="on" +email="me@danielgibbs.co.uk" # Steam login steamuser="anonymous" @@ -103,14 +103,24 @@ fn_setstatus(){ echo"" echo "Required status: ${requiredstatus}" + counter=0 while [ "${requiredstatus}" != "${currentstatus}" ]; do + counter=$((counter+1)) fn_currentstatus + echo -ne "Current status: ${currentstatus}\\r" if [ "${requiredstatus}" == "ONLINE" ]; then (fn_start > /dev/null 2>&1) else (fn_stop > /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 + fi done echo -ne "Current status: ${currentstatus}\\r" echo -e "\n" @@ -119,6 +129,16 @@ fn_setstatus(){ sleep 0.5 } +echo "=================================" +echo "TravisCI Tests" +echo "Linux Game Server Manager" +echo "by Daniel Gibbs" +echo "http://gameservermanagers.com" +echo "=================================" +echo "" + + + echo "1.0 - start - no files" echo "=================================" echo "Description:" @@ -130,6 +150,9 @@ echo "" echo "Test complete!" sleep 1 echo "" + + + echo "2.0 - install" echo "=================================" echo "Description:" @@ -141,6 +164,9 @@ echo "" echo "Test complete!" sleep 1 echo "" + + + echo "3.1 - start" echo "=================================" echo "Description:" @@ -208,6 +234,8 @@ echo "Test complete!" sleep 1 echo "" + + echo "4.1 - update" echo "=================================" echo "Description:" @@ -302,6 +330,9 @@ echo "" echo "Test complete!" sleep 1 echo "" + + + echo "5.1 - monitor - online" echo "=================================" echo "Description:" @@ -316,7 +347,7 @@ echo "" echo "5.2 - monitor - offline - no lockfile" echo "=================================" echo "Description:" -echo "run monitor while server is offline with no lockfile" +echo "run monitor while server is offline with no lockfile." requiredstatus="OFFLINE" fn_setstatus (fn_monitor) @@ -324,10 +355,10 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "5.2 - monitor - offline - with lockfile" +echo "5.3 - 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 no lockfile." requiredstatus="OFFLINE" fn_setstatus fn_printinfonl "creating lockfile." @@ -337,17 +368,32 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "5.2 - monitor - gsquery.py failure" +echo "5.4 - monitor - gsquery.py failure" echo "=================================" echo "Description:" -echo "gsquery.py will fail to query port" +echo "gsquery.py will fail to query port." requiredstatus="ONLINE" fn_setstatus -port=${port+1} -(fn_monitor) -port=${port-1} +sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" +fn_monitor +echo "" +fn_printinfonl "Reseting ${servercfg}." +fn_install_config echo "" echo "Test complete!" sleep 1 echo "" + + +echo "6.0 - details" +echo "=================================" +echo "Description:" +echo "gsquery.py will fail to query port." +requiredstatus="ONLINE" +fn_setstatus +fn_details +echo "" +echo "Test complete!" +sleep 1 +echo "" \ No newline at end of file From 9a9c80f743bda08cbf7f861383be3bbf5f1284c8 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 18:39:24 +0000 Subject: [PATCH 20/42] further test improvements --- test.sh | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/test.sh b/test.sh index ce8efa06e..839b7538c 100644 --- a/test.sh +++ b/test.sh @@ -34,7 +34,7 @@ gamename="Just Cause 2" engine="avalanche" # Directories -rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/jc2server" selfname="$(basename $0)" lockselfname=".${servicename}.lock" filesdir="${rootdir}/serverfiles" @@ -136,7 +136,14 @@ echo "by Daniel Gibbs" echo "http://gameservermanagers.com" echo "=================================" echo "" - +sleep 1 +echo "=================================" +echo "Generic Server Tests" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 +mkdir ${rootfdir} echo "1.0 - start - no files" @@ -189,7 +196,21 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "3.3 - stop" +echo "3.3 - start - updateonstart" +echo "=================================" +echo "Description:" +echo "will update server on start." +requiredstatus="ONLINE" +fn_setstatus +( + updateonstart="on" + fn_start +) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.4 - stop" echo "=================================" echo "Description:" echo "stop ${gamename} server." @@ -200,7 +221,7 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "3.4 - stop - offline" +echo "3.5 - stop - offline" echo "=================================" echo "Description:" echo "stop ${gamename} server while already stopped." @@ -211,7 +232,7 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "3.5 - restart" +echo "3.6 - restart" echo "=================================" echo "Description:" echo "restart ${gamename}." @@ -222,7 +243,7 @@ echo "" echo "Test complete!" sleep 1 echo "" -echo "3.5 - restart - offline" +echo "3.7 - restart - offline" echo "=================================" echo "Description:" echo "restart ${gamename} while already stopped." @@ -396,4 +417,68 @@ fn_details echo "" echo "Test complete!" sleep 1 -echo "" \ No newline at end of file +echo "" + +echo "=================================" +echo "Generic Server Tests - Complete!" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 +fn_printinfo "Tidying up directories." +sleep 1 +rm -rfv ${rootdir} +echo "END" + +#!/bin/bash +# Teamspeak 3 +# Server Management Script +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +version="040715" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="on" +email="me@Danielgibbs.co.uk" + +# Start Variables +updateonstart="off" + +# Server Details +gamename="Teamspeak 3" +servername="Teamspeak 3 Server" +servicename="ts3-server" + +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/ts3server" +selfname="$(basename $0)" +lockselfname=".${servicename}.lock" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="./ts3server_startscript.sh" +servercfg="${servicename}.ini" +servercfgdir="${filesdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${filesdir}/logs" +scriptlogdir="${rootdir}/log/script" + +scriptlog="${scriptlogdir}/${servicename}-script.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" + + +echo "=================================" +echo "Generic Server Tests" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 \ No newline at end of file From 4fbbf95246dc6601dcbab31c79ac1952d648e4ba Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 18:40:43 +0000 Subject: [PATCH 21/42] removed unrequired exit was returning a wrong exit code --- functions/fn_getopt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/functions/fn_getopt b/functions/fn_getopt index 1b9b281d4..e495fc566 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -2,7 +2,7 @@ # LGSM fn_getopt function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 200615 +# Version: 311015 # Description: getopt arguments. @@ -46,7 +46,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|force-update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install}" - exit 1;; esac exit } @@ -79,7 +78,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|update-functions|monitor|email-test|details|backup|install|auto-install}" - exit 1;; esac exit } @@ -108,7 +106,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|backup|console|debug}" - exit 1;; esac exit } @@ -143,7 +140,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}" - exit 1;; esac exit } @@ -191,7 +187,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}" - exit 1;; esac exit } @@ -227,7 +222,6 @@ case "$getopt" in fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}" - exit 1;; esac exit } From 4a66d6de7f4b723177c5ee4fd3f44dd95a5b2474 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 18:53:19 +0000 Subject: [PATCH 22/42] Added exit codes where needed --- functions/fn_backup | 4 ++-- functions/fn_check_ip | 4 ++-- functions/fn_check_root | 4 ++-- functions/fn_check_systemdir | 4 ++-- functions/fn_check_tmux | 4 ++-- functions/fn_compress_unreal2maps | 4 ++-- functions/fn_compress_ut99maps | 4 ++-- functions/fn_console | 4 ++-- functions/fn_debug | 4 ++-- functions/fn_install_ts3 | 10 +++++----- functions/fn_monitor | 8 ++++---- functions/fn_monitor_query | 8 ++++---- functions/fn_update_check | 12 ++++++------ functions/fn_update_dl | 6 +++--- 14 files changed, 40 insertions(+), 40 deletions(-) diff --git a/functions/fn_backup b/functions/fn_backup index c1365d321..3d3f5a7a9 100644 --- a/functions/fn_backup +++ b/functions/fn_backup @@ -2,7 +2,7 @@ # LGSM fn_backup function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 311015 # Description: Creates a .tar.gz file in the backup directory. @@ -22,7 +22,7 @@ while true; do read -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; - [Nn]* ) echo Exiting; return 1;; + [Nn]* ) echo Exiting; return;; * ) echo "Please answer yes or no.";; esac done diff --git a/functions/fn_check_ip b/functions/fn_check_ip index 81f6ab6c0..06ce0adc1 100644 --- a/functions/fn_check_ip +++ b/functions/fn_check_ip @@ -2,7 +2,7 @@ # LGSM fn_check_ip function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 120715 +# Version: 311015 # 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". @@ -24,7 +24,7 @@ if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then echo -en "" echo -en "http://gameservermanagers.com/network-interfaces" echo -en "" - exit + exit 1 else ip=${getip} fi diff --git a/functions/fn_check_root b/functions/fn_check_root index b91536803..64ee2cca2 100644 --- a/functions/fn_check_root +++ b/functions/fn_check_root @@ -2,9 +2,9 @@ # LGSM fn_check_root function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 311015 if [ $(whoami) = "root" ]; then fn_printfailnl "Do NOT run this script as root!" - exit + exit 1 fi \ No newline at end of file diff --git a/functions/fn_check_systemdir b/functions/fn_check_systemdir index ae4a85e88..47a3f4860 100644 --- a/functions/fn_check_systemdir +++ b/functions/fn_check_systemdir @@ -2,9 +2,9 @@ # LGSM fn_check_systemdir function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 311015 if [ ! -e "${systemdir}" ]; then fn_printfailnl "Cannot access ${systemdir}: No such directory" - exit + exit 1 fi \ No newline at end of file diff --git a/functions/fn_check_tmux b/functions/fn_check_tmux index 387617be8..49ab4f18d 100644 --- a/functions/fn_check_tmux +++ b/functions/fn_check_tmux @@ -2,7 +2,7 @@ # LGSM fn_check_tmux function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 291015 +# Version: 311015 # Checks if tmux is installed as too many users do not RTFM or know how to use Google. @@ -16,5 +16,5 @@ else # Suitable passive agressive message echo " * Please see the the following link." echo " * http://gameservermanagers.com/tmux-not-found" - exit + exit 127 fi \ No newline at end of file diff --git a/functions/fn_compress_unreal2maps b/functions/fn_compress_unreal2maps index 0b859f3d6..00b35ae09 100644 --- a/functions/fn_compress_unreal2maps +++ b/functions/fn_compress_unreal2maps @@ -2,7 +2,7 @@ # LGSM fn_compress_unreal2maps function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 311015 fn_check_root clear @@ -20,7 +20,7 @@ while true; do read -p "Start compression [y/N]" yn case $yn in [Yy]* ) break;; - [Nn]* ) echo Exiting; return 1;; + [Nn]* ) echo Exiting; return;; * ) echo "Please answer yes or no.";; esac done diff --git a/functions/fn_compress_ut99maps b/functions/fn_compress_ut99maps index ed098217a..2f608c0a3 100644 --- a/functions/fn_compress_ut99maps +++ b/functions/fn_compress_ut99maps @@ -2,7 +2,7 @@ # LGSM fn_compress_ut99maps function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 311015 fn_check_root clear @@ -20,7 +20,7 @@ while true; do read -p "Start compression [y/N]" yn case $yn in [Yy]* ) break;; - [Nn]* ) echo Exiting; return 1;; + [Nn]* ) echo Exiting; return;; * ) echo "Please answer yes or no.";; esac done diff --git a/functions/fn_console b/functions/fn_console index cec27686d..38e055f3f 100644 --- a/functions/fn_console +++ b/functions/fn_console @@ -2,7 +2,7 @@ # LGSM fn_console function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 260515 +# Version: 311015 # Description: Gives access to the server tmux console. @@ -20,7 +20,7 @@ while true; do read -e -i "y" -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; - [Nn]* ) echo Exiting; return 1;; + [Nn]* ) echo Exiting; return;; * ) echo "Please answer yes or no.";; esac done diff --git a/functions/fn_debug b/functions/fn_debug index 93fb240aa..d303e6498 100644 --- a/functions/fn_debug +++ b/functions/fn_debug @@ -2,7 +2,7 @@ # LGSM fn_debug function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 160415 +# Version: 311015 # Description: Runs the server without tmux. Runs direct from the terminal. @@ -37,7 +37,7 @@ while true; do read -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; - [Nn]* ) echo Exiting; return 1;; + [Nn]* ) echo Exiting; return;; * ) echo "Please answer yes or no.";; esac done diff --git a/functions/fn_install_ts3 b/functions/fn_install_ts3 index 78246c0cf..bde40acfe 100644 --- a/functions/fn_install_ts3 +++ b/functions/fn_install_ts3 @@ -2,7 +2,7 @@ # LGSM fn_install_ts3 function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 311015 fn_details_distro # Gets the teamspeak server architecture @@ -12,7 +12,7 @@ elif [ "${arch}" == "i386" ]||[ "${arch}" == "i686" ]; then ts3arch="x86" else fn_printfailure "${arch} is an unsupported architecture" - exit + exit 1 fi # Grabs all version numbers not in correct order @@ -45,7 +45,7 @@ if [ -z "${availablebuild}" ]; then sleep 1 fn_printfail "Checking for update: teamspeak.com: Not returning version info" sleep 2 - exit + exit 1 fi cd "${rootdir}" @@ -63,7 +63,7 @@ else sleep 1 cat ".${servicename}-tar-error.tmp" rm ".${servicename}-tar-error.tmp" - exit + exit $? fi echo -e "copying to ${filesdir}...\c" cp -R "${rootdir}/teamspeak3-server_linux-${ts3arch}/"* "${filesdir}" 2> ".${servicename}-cp-error.tmp" @@ -75,7 +75,7 @@ else sleep 1 cat ".${servicename}-cp-error.tmp" rm ".${servicename}-cp-error.tmp" - exit + exit $? fi rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}" diff --git a/functions/fn_monitor b/functions/fn_monitor index 7f27718e7..3978aa43d 100644 --- a/functions/fn_monitor +++ b/functions/fn_monitor @@ -2,7 +2,7 @@ # LGSM fn_monitor function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 150815 +# Version: 311015 # Description: Monitors server by checking for running proccesses # then passes to fn_monitor_query. @@ -22,7 +22,7 @@ if [ ! -f "${rootdir}/${lockselfname}" ]; then sleep 1 echo -en "\n" echo "To enable monitor run ./${selfname} start" - exit + exit 1 fi fn_printdots "Checking session: CHECKING" fn_scriptlog "Checking session: CHECKING" @@ -67,7 +67,7 @@ if [ ! -f "${rootdir}/${lockselfname}" ]; then sleep 1 echo -en "\n" echo "To enable monitor run ./${selfname} start" - exit + exit 1 fi updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) @@ -85,7 +85,7 @@ if [ "${updatecheck}" = "0" ]||[ "${gamename}" == "Unreal Tournament 99" ]||[ "$ if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then fn_monitor_query fi - exit + exit $? else fn_printfail "Checking session: FAIL" fn_scriptlog "Checking session: FAIL" diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index 0b575bb42..f56b6cf23 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -2,7 +2,7 @@ # LGSM fn_monitor_query function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 311015 # Description: uses gsquery.py to directly query the server. # Detects if the server has frozen. @@ -56,7 +56,7 @@ if [ -f "${rootdir}/gsquery.py" ]; then fn_email fi fn_restart - exit + exit 1 elif [ "${exitcode}" == "0" ]; then fn_printok "Querying port: ${ip}:${port} : OK" fn_scriptlog "Querying port: ${ip}:${port} : OK" @@ -79,7 +79,7 @@ if [ -f "${rootdir}/gsquery.py" ]; then echo "As user ${owner} or root run the following command." whoami=$(whoami) echo -en "\nchown ${whoami}:${whoami} ${rootdir}/gsquery.py\n\n" - exit + exit 1 fi else fn_printfail "Querying port: ${ip}:${port} : UNKNOWN ERROR" @@ -87,7 +87,7 @@ if [ -f "${rootdir}/gsquery.py" ]; then sleep 1 echo -en "\n" ${rootdir}/gsquery.py -a ${ip} -p ${port} -e ${engine} - exit + exit 1 fi else fn_printfailnl "Could not find ${rootdir}/gsquery.py" diff --git a/functions/fn_update_check b/functions/fn_update_check index f41203b50..443a88f1c 100644 --- a/functions/fn_update_check +++ b/functions/fn_update_check @@ -2,7 +2,7 @@ # LGSM fn_update_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 311015 # Description: Checks if a server update is available. @@ -40,7 +40,7 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then for appfile in ${appmanifestfile}; do echo " ${appfile}" done - exit + exit 1 else sleep 1 fn_printok "Removed x${appmanifestfilewc1} appmanifest_${appid}.acf files" @@ -56,7 +56,7 @@ elif [ "${appmanifestfilewc}" -eq "0" ]; then if [ "${forceupdate}" -eq "1" ]; then fn_printfail "Still no appmanifest_${appid}.acf found: Unable to update" fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update" - exit + exit 1 fi forceupdate=1 fn_printwarn "No appmanifest_${appid}.acf found" @@ -128,7 +128,7 @@ if [ -z "${availablebuild}" ]; then sleep 1 fn_printfailnl "Checking for update: SteamCMD: Not returning version info" fn_scriptlog "Failure! Checking for update: SteamCMD: Not returning version info" - exit + exit 1 else fn_printok "Checking for update: SteamCMD" fn_scriptlog "Success! Checking for update: SteamCMD" @@ -205,7 +205,7 @@ if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then fn_printfailnl "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" - exit + exit 1 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}') @@ -245,7 +245,7 @@ if [ -z "${availablebuild}" ]; then fn_printfail "Checking for update: teamspeak.com: Not returning version info" fn_scriptlog "Failure! Checking for update: teamspeak.com: Not returning version info" sleep 2 - exit + exit 1 else fn_printok "Checking for update: teamspeak.com" fn_scriptlog "Success! Checking for update: teamspeak.com" diff --git a/functions/fn_update_dl b/functions/fn_update_dl index c4500c331..b22bc7d95 100644 --- a/functions/fn_update_dl +++ b/functions/fn_update_dl @@ -2,7 +2,7 @@ # LGSM fn_update_dl function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 040715 +# Version: 311015 # Description: Runs a server update. @@ -66,7 +66,7 @@ else cat "${scriptlogdir}/.${servicename}-tar-error.tmp" >> "${scriptlog}" rm "${scriptlogdir}/.${servicename}-tar-error.tmp" fn_scriptlog "Failure! Unable to update" - exit + exit ${status} fi echo -e "copying to ${filesdir}...\c" fn_scriptlog "Copying to ${filesdir}" @@ -82,7 +82,7 @@ else cat "${scriptlogdir}/.${servicename}-cp-error.tmp" >> "${scriptlog}" rm "${scriptlogdir}/.${servicename}-cp-error.tmp" fn_scriptlog "Failure! Unable to update" - exit + exit ${status} fi rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}" From 79c511d8e6841d9d7112c8489232bb04d3caaee7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 19:32:39 +0000 Subject: [PATCH 23/42] Updated tests --- tests/test.sh | 432 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 432 insertions(+) create mode 100644 tests/test.sh diff --git a/tests/test.sh b/tests/test.sh new file mode 100644 index 000000000..edddbd25b --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,432 @@ +#!/bin/bash +# Just Cause 2 +# Server Management Script +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +version="150715" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="on" +email="me@danielgibbs.co.uk" + +# Steam login +steamuser="anonymous" +steampass="" + +# Start Variables +updateonstart="off" + +fn_parms(){ +parms="" +} + +#### Advanced Variables #### + +# Steam +appid="261140" + +# Server Details +servicename="jc2-server" +gamename="Just Cause 2" +engine="avalanche" + +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/jc2server" +selfname="$(basename $0)" +lockselfname=".${servicename}.lock" +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" + +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 + +fn_runfunction(){ +# Functions are downloaded and run with this function +if [ ! -f "${rootdir}/functions/${functionfile}" ]; then + cd "${rootdir}" + if [ ! -d "functions" ]; then + mkdir functions + fi + cd functions + echo -e " loading ${functionfile}...\c" + wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- + chmod +x "${functionfile}" + cd "${rootdir}" +fi +source "${rootdir}/functions/${functionfile}" +} + +fn_functions(){ +# Functions are defined in fn_functions. +functionfile="${FUNCNAME}" +fn_runfunction +} + +fn_functions + +getopt=$1 + +fn_currentstatus(){ +pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") +if [ "${pid}" == "0" ]; then + currentstatus="OFFLINE" +else + currentstatus="ONLINE" +fi +} + +fn_setstatus(){ + fn_currentstatus + + echo"" + echo "Required status: ${requiredstatus}" + counter=0 + while [ "${requiredstatus}" != "${currentstatus}" ]; do + counter=$((counter+1)) + fn_currentstatus + + echo -ne "Current status: ${currentstatus}\\r" + if [ "${requiredstatus}" == "ONLINE" ]; then + (fn_start > /dev/null 2>&1) + else + (fn_stop > /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 + fi + done + echo -ne "Current status: ${currentstatus}\\r" + echo -e "\n" + echo "Test starting:" + echo "" + sleep 0.5 +} + +echo "=================================" +echo "TravisCI Tests" +echo "Linux Game Server Manager" +echo "by Daniel Gibbs" +echo "http://gameservermanagers.com" +echo "=================================" +echo "" +sleep 1 +echo "=================================" +echo "Generic Server Tests" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 +mkdir ${rootfdir} + + +echo "1.0 - start - no files" +echo "=================================" +echo "Description:" +echo "Test script reaction to missing server files." +requiredstatus="OFFLINE" +fn_setstatus +(fn_start) +echo "" +echo "Test complete!" +sleep 1 +echo "" + + + +echo "2.0 - install" +echo "=================================" +echo "Description:" +echo "install ${gamename} server." +requiredstatus="OFFLINE" +fn_setstatus +fn_autoinstall +echo "" +echo "Test complete!" +sleep 1 +echo "" + + + +echo "3.1 - start" +echo "=================================" +echo "Description:" +echo "start ${gamename} server." +requiredstatus="OFFLINE" +fn_setstatus +fn_start +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.2 - start - online" +echo "=================================" +echo "Description:" +echo "start ${gamename} server while already running." +requiredstatus="ONLINE" +fn_setstatus +(fn_start) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.3 - start - updateonstart" +echo "=================================" +echo "Description:" +echo "will update server on start." +requiredstatus="ONLINE" +fn_setstatus +( + updateonstart="on" + fn_start +) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.4 - stop" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server." +requiredstatus="ONLINE" +fn_setstatus +fn_stop +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.5 - stop - offline" +echo "=================================" +echo "Description:" +echo "stop ${gamename} server while already stopped." +requiredstatus="OFFLINE" +fn_setstatus +(fn_stop) +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.6 - restart" +echo "=================================" +echo "Description:" +echo "restart ${gamename}." +requiredstatus="ONLINE" +fn_setstatus +fn_restart +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "3.7 - restart - offline" +echo "=================================" +echo "Description:" +echo "restart ${gamename} while already stopped." +requiredstatus="OFFLINE" +fn_setstatus +fn_restart +echo "" +echo "Test complete!" +sleep 1 +echo "" + + + +echo "4.1 - update" +echo "=================================" +echo "Description:" +echo "check for updates." +requiredstatus="OFFLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.2 - update - change buildid" +echo "=================================" +echo "Description:" +echo "change the buildid tricking SteamCMD to update." +requiredstatus="OFFLINE" +fn_setstatus +fn_printinfonl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +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_printinfonl "changed buildid to 0." +sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +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_printinfonl "removed appmanifest_${appid}.acf." +rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.5 - force-update" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check." +requiredstatus="OFFLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.6 - force-update - online" +echo "=================================" +echo "Description:" +echo "force-update bypassing update check server while already running." +requiredstatus="ONLINE" +fn_setstatus +fn_update_check +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.7 - validate" +echo "=================================" +echo "Description:" +echo "validate server files." +requiredstatus="OFFLINE" +fn_setstatus +fn_validate +echo "" +echo "Test complete!" +sleep 1 +echo "" +echo "4.8 - validate - online" +echo "=================================" +echo "Description:" +echo "validate server files while server while already running." +requiredstatus="ONLINE" +fn_setstatus +fn_validate +echo "" +echo "Test complete!" +sleep 1 +echo "" + + + +echo "5.1 - monitor - online" +echo "=================================" +echo "Description:" +echo "run monitor server while already running." +requiredstatus="ONLINE" +fn_setstatus +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +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 +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +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_printinfonl "creating lockfile." +date > "${rootdir}/${lockselfname}" +(fn_monitor) +echo "" +echo "Test complete!" +sleep 1 +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}" +fn_monitor +echo "" +fn_printinfonl "Reseting ${servercfg}." +fn_install_config +echo "" +echo "Test complete!" +sleep 1 +echo "" + + + +echo "6.0 - details" +echo "=================================" +echo "Description:" +echo "gsquery.py will fail to query port." +requiredstatus="ONLINE" +fn_setstatus +fn_details +echo "" +echo "Test complete!" +sleep 1 +echo "" + +echo "=================================" +echo "Generic Server Tests - Complete!" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 +fn_printinfo "Tidying up directories." +sleep 1 +rm -rfv ${rootdir} +echo "END" + From 10e0ad8916479eff84efe35b0c7f799725bd8aed Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 19:38:59 +0000 Subject: [PATCH 24/42] added new set of tests for travisci --- .travis.yml | 2 +- tests/test.sh | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 85148ae4e..4e39e2473 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,4 +22,4 @@ addons: script: - - bash test.sh \ No newline at end of file + - bash tests/test.sh \ No newline at end of file diff --git a/tests/test.sh b/tests/test.sh index edddbd25b..839b7538c 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -430,3 +430,55 @@ sleep 1 rm -rfv ${rootdir} echo "END" +#!/bin/bash +# Teamspeak 3 +# Server Management Script +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +version="040715" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="on" +email="me@Danielgibbs.co.uk" + +# Start Variables +updateonstart="off" + +# Server Details +gamename="Teamspeak 3" +servername="Teamspeak 3 Server" +servicename="ts3-server" + +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/ts3server" +selfname="$(basename $0)" +lockselfname=".${servicename}.lock" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}" +executabledir="${filesdir}" +executable="./ts3server_startscript.sh" +servercfg="${servicename}.ini" +servercfgdir="${filesdir}" +servercfgfullpath="${servercfgdir}/${servercfg}" +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${filesdir}/logs" +scriptlogdir="${rootdir}/log/script" + +scriptlog="${scriptlogdir}/${servicename}-script.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" + + +echo "=================================" +echo "Generic Server Tests" +echo "Using: ${gamename}" +echo "=================================" +echo "" +sleep 1 \ No newline at end of file From 5eb96d39bc2bab10f6e2385186716e9c006df6e7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 31 Oct 2015 19:43:28 +0000 Subject: [PATCH 25/42] fixed mkdir --- tests/test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 839b7538c..cbe7fdbaf 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -35,6 +35,7 @@ engine="avalanche" # Directories rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/jc2server" +mkdir "${rootdir}" selfname="$(basename $0)" lockselfname=".${servicename}.lock" filesdir="${rootdir}/serverfiles" @@ -143,7 +144,6 @@ echo "Using: ${gamename}" echo "=================================" echo "" sleep 1 -mkdir ${rootfdir} echo "1.0 - start - no files" @@ -396,7 +396,7 @@ echo "gsquery.py will fail to query port." requiredstatus="ONLINE" fn_setstatus sed -i 's/[0-9]\+/0/' "${servercfgfullpath}" -fn_monitor +(fn_monitor) echo "" fn_printinfonl "Reseting ${servercfg}." fn_install_config From 4a151c3d17bafd9958b8dbad348d379ff1baebbe Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:28:37 +0000 Subject: [PATCH 26/42] added updated options messages Updated all options messages and added short switches for my convenience --- functions/fn_getopt | 406 +++++++++++++++++++++++++++----------------- 1 file changed, 251 insertions(+), 155 deletions(-) diff --git a/functions/fn_getopt b/functions/fn_getopt index 56d3507f5..20007fcd1 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -2,301 +2,397 @@ # LGSM fn_getopt function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 011115 # Description: getopt arguments. fn_getopt_generic(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update) + u|update) fn_update_check;; - force-update) + fu|force-update|update-restart) forceupdate=1; fn_update_check;; - update-restart) - forceupdate=1; - fn_update_check;; - update-functions) + uf|update-functions) fn_update_functions;; - validate) + v|validate) fn_validate;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - console) + c|console) fn_console;; - debug) + d|debug) fn_debug;; - install) + i|install) fn_install;; - auto-install) + ai|auto-install) fn_autoinstall;; - depsdetect) - fn_deps_detect;; + dd|depsdetect) + fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update|force-update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." + echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + } | column -s $'\t' -t + esac exit } fn_getopt_teamspeak3(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update) + u|update) fn_update_check;; - update-functions) + uf|update-functions) fn_update_functions;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - install) + i|install) fn_install;; - auto-install) + ai|auto-install) fn_autoinstall;; - depsdetect) - fn_deps_detect;; + dd|depsdetect) + fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update|update-functions|monitor|email-test|details|backup|install|auto-install}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from teamspeak.com." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + } | column -s $'\t' -t + esac exit } fn_getopt_mumble(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update-functions) + uf|update-functions) fn_update_functions;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - backup) + b|backup) fn_backup;; console) fn_console;; - debug) + d|debug) fn_debug;; - depsdetect) - fn_deps_detect;; + dd|depsdetect) + fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|backup|console|debug}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + } | column -s $'\t' -t + esac exit } fn_getopt_gmodserver(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update) + u|update) fn_update_check;; - force-update|update-restart) + fu|force-update|update-restart) forceupdate=1; fn_update_check;; - update-functions|updatefunctions) + uf|update-functions) fn_update_functions;; - validate) + v|validate) fn_validate;; - monitor) + m|monitor) fn_monitor;; - email-test|emailtest) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - console) + c|console) fn_console;; - debug) + d|debug) fn_debug;; - install) + i|install) fn_install;; - auto-install|autoinstall) + ai|auto-install) fn_autoinstall;; - content) -echo + dd|depsdetect) + fn_deps_detect;; + gc|gmod-content) fn_content_gmod;; - depsdetect) - fn_deps_detect;; *) - echo "Usage: $0 [option] - -${gamename} - Linux Game Server Manager - Version ${version} -http://gameservermanagers.com/${selfname}" -echo -e "" -echo -e "\e[93mCommands\e[0m" - -{ - echo -e "\e[34mstart\t\e[0mStart the server." - echo -e "\e[34mstop\t\e[0mStop the server." - echo -e "\e[34mrestart\t\e[0mRestart the server." - echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." - echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." - echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." - echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." - echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." - echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." - echo -e "\e[34mbackup\t\e[0mCreate archive of the server." - echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." - echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." - echo -e "\e[34minstall\t\e[0mInstall the server." - echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." - echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content." - -} | column -s $'\t' -t -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." + echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content." + } | column -s $'\t' -t + esac exit } fn_getopt_unreal(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update-functions) + uf|update-functions) fn_update_functions;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - console) + c|console) fn_console;; - debug) + d|debug) fn_debug;; - install) + i|install) fn_install;; - map-compressor) + mc|map-compressor) fn_compress_ut99maps;; - depsdetect) + dd|depsdetect) fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." + } | column -s $'\t' -t + esac exit } fn_getopt_unreal2(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update) + u|update) fn_update_check;; - force-update) + fu|force-update|update-restart) forceupdate=1; fn_update_check;; - update-restart) - forceupdate=1; - fn_update_check;; - update-functions) + uf|update-functions) fn_update_functions;; - validate) + v|validate) fn_validate;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - console) + c|console) fn_console;; - debug) + d|debug) fn_debug;; - install) + i|install) fn_install;; - auto-install) + ai|auto-install) fn_autoinstall;; - map-compressor) + dd|depsdetect) + fn_deps_detect;; + mc|map-compressor) fn_compress_unreal2maps;; - depsdetect) - fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate\t\e[0mChecks and applies updates from SteamCMD." + echo -e "\e[34mforce-update\t\e[0mBypasses the check and applies updates from SteamCMD." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mvalidate\t\e[0mValidate server files with SteamCMD." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts." + echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." + } | column -s $'\t' -t + esac exit } fn_getopt_ut2k4(){ case "$getopt" in - start) + st|start) fn_start;; - stop) + sp|stop) fn_stop;; - restart) + r|restart) fn_restart;; - update-functions) + uf|update-functions) fn_update_functions;; - monitor) + m|monitor) fn_monitor;; - email-test) + et|email-test) fn_email_test;; - details) + d|details) fn_details;; - backup) + b|backup) fn_backup;; - console) + c|console) fn_console;; - debug) + d|debug) fn_debug;; - install) + i|install) fn_install;; - map-compressor) - fn_compress_unreal2maps;; - depsdetect) + mc|map-compressor) + fn_compress_ut99maps;; + dd|depsdetect) fn_deps_detect;; *) - echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}" - exit 1;; -esac + echo "Usage: $0 [option]" + echo "${gamename} - Linux Game Server Manager - Version ${version}" + echo "http://gameservermanagers.com/${selfname}" + echo -e "" + echo -e "\e[93mCommands\e[0m" + { + echo -e "\e[34mstart\t\e[0mStart the server." + echo -e "\e[34mstop\t\e[0mStop the server." + echo -e "\e[34mrestart\t\e[0mRestart the server." + echo -e "\e[34mupdate-functions\t\e[0mRemoves all functions so latest can be downloaded." + echo -e "\e[34mmonitor\t\e[0mChecks that the server is running." + echo -e "\e[34memail-test\t\e[0mSends test monitor email." + echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server." + echo -e "\e[34mbackup\t\e[0mCreate archive of the server." + echo -e "\e[34mconsole\t\e[0mConsole allows you to access the live view of a server." + echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal." + echo -e "\e[34minstall\t\e[0mInstall the server." + echo -e "\e[34mmap-compressor\t\e[0mCompresses all ${gamename} server maps." + } | column -s $'\t' -t + esac exit } From d84e5e48100b7cbac44687f4939a0490e14c947d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:40:06 +0000 Subject: [PATCH 27/42] Newer version put back in to branch --- functions/fn_details | 118 +++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 77 deletions(-) diff --git a/functions/fn_details b/functions/fn_details index ea408876d..845eafca4 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -2,7 +2,7 @@ # LGSM fn_details function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 281015 +# Version: 301015 # Description: Displays server infomation. @@ -20,9 +20,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = echo -e "\e[34mHostname:\t\e[0m$HOSTNAME" echo -e "\e[34mtmux:\t\e[0m${tmuxv}" echo -e "\e[34mGLIBC:\t\e[0m${glibcv}" -} >> .fn_details_distro -column -s $'\t' -t .fn_details_distro -rm -f .fn_details_distro +} | column -s $'\t' -t } fn_details_performance(){ @@ -32,17 +30,13 @@ 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}" -} >> .fn_details_performance -column -s $'\t' -t .fn_details_performance -rm -f .fn_details_performance +} | 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" -} >> .fn_details_performance -column -s $'\t' -t .fn_details_performance -rm -f .fn_details_performance +} | column -s $'\t' -t } fn_details_disk(){ @@ -58,9 +52,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -d "${backupdir}" ]; then echo -e "\e[34mBackups:\t\e[0m${backupdirdu}" fi -} >> .fn_details_disk -column -s $'\t' -t .fn_details_disk -rm -f .fn_details_disk +} | column -s $'\t' -t } fn_details_gameserver(){ @@ -132,9 +124,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${dbplugin}" ]; then echo -e "\e[34mdbplugin:\t\e[0m${dbplugin}" fi -} >> .fn_details_gameserver -column -s $'\t' -t .fn_details_gameserver -rm -f .fn_details_gameserver +} | column -s $'\t' -t echo -e "" ## script details @@ -154,7 +144,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = # GLIBC required if [ -n "${glibcrequired}" ]; then - if [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" ]; then + if [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt "$(echo "${glibcrequired}" | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" ]; then if [ "${glibcfix}" == "yes" ]; then echo -e "\e[34mGLIBC required:\t\e[0;31m${glibcrequired} \e[0m(\e[0;32mUsing GLIBC fix\e[0m)" else @@ -187,9 +177,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = if [ -n "${networkcfgfullpath}" ]; then echo -e "\e[34mNetwork config file:\t\e[0m${networkcfgfullpath}" fi -} >> .fn_details_script -column -s $'\t' -t .fn_details_script -rm -f .fn_details_script +} | column -s $'\t' -t } fn_details_backup(){ @@ -205,9 +193,7 @@ else 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}" - } >> .fn_details_backup - column -s $'\t' -t .fn_details_backup - rm -f .fn_details_backup + } | column -s $'\t' -t fi } @@ -260,9 +246,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -288,9 +273,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -316,9 +300,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -353,9 +336,8 @@ fi echo -e "> Game\tINBOUND\t${port}\tudp" echo -e "> Steam: Query\tINBOUND\t${queryport}\tudp" echo -e "> Steam: Master traffic\tINBOUND\t${masterport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -384,9 +366,8 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game/RCON\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -417,9 +398,8 @@ echo -e "" echo -e "> SourceTV\tINBOUND\t${sourcetvport}\tudp" fi echo -e "< Client\tOUTBOUND\t${clientport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -449,9 +429,7 @@ echo -e "" echo -e "> Game/RCON\tINBOUND\t${port}\tudp" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -459,9 +437,8 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -490,9 +467,8 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -520,9 +496,8 @@ echo -e "" echo -e "> Voice\tINBOUND\t${port}\tudp" echo -e "> ServerQuery\tINBOUND\t${queryport}\ttcp" echo -e "> File transfer\tINBOUND\t${fileport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -549,9 +524,8 @@ echo -e "" { echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" echo -e "> Game\tINBOUND\t${port}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -580,9 +554,8 @@ echo -e "" echo -e "> Game\tINBOUND\t${port}\ttcp" echo -e "> Query\tINBOUND\t${queryport}\ttcp" echo -e "> Rcon\tINBOUND\t${rconport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -613,9 +586,7 @@ echo -e "" echo -e "> Query\tINBOUND\t${queryport}\tudp" echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp" echo -e "> Telnet\tINBOUND\t${telnetport}\ttcp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -623,9 +594,7 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} Telnet\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -633,9 +602,8 @@ 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}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } @@ -683,9 +651,7 @@ echo -e "" fi fi echo -e "> WebAdmin\tINBOUND\t${webadminport}\ttcp\tListenPort=${webadminport}" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t echo -e "" echo -e "\e[92m${servername} WebAdmin\e[0m" printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = @@ -694,9 +660,8 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = 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}" -} >> .fn_details_webadmin -column -s $'\t' -t .fn_details_webadmin -rm -f .fn_details_webadmin +} | column -s $'\t' -t + fn_details_statusbottom } @@ -725,9 +690,8 @@ echo -e "" echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL\tINI VARIABLE" echo -e "> Game\tINBOUND\t${port}\tudp\tPort=${port}" echo -e "> Query\tINBOUND\t${queryport}\tudp" -} >> .fn_details_ports -column -s $'\t' -t .fn_details_ports -rm -f .fn_details_ports +} | column -s $'\t' -t + fn_details_statusbottom } From 01744b9f99c8afaf44973c6848d21ae243bfebd7 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:40:42 +0000 Subject: [PATCH 28/42] newer version put back in to branch --- functions/fn_details_config | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/functions/fn_details_config b/functions/fn_details_config index f8727f1f5..815153f23 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -8,7 +8,7 @@ ## Examples of filtering to get info from config files # sed 's/foo//g' - remove foo -# tr -cd [:digit:] leave only digits +# tr -cd '[:digit:]' leave only digits # tr -d '=\"; ' remove selected charectors =\"; # grep -v "foo" filter out lines that contain foo @@ -52,7 +52,7 @@ if [ "${engine}" == "avalanche" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -62,7 +62,7 @@ if [ "${engine}" == "avalanche" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "BindPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -95,7 +95,7 @@ elif [ "${engine}" == "dontstarve" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -115,7 +115,7 @@ elif [ "${engine}" == "dontstarve" ]; then # tickrate if [ -f "${servercfgfullpath}" ]; then - tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${tickrate}" ]; then tickrate="NOT SET" fi @@ -125,7 +125,7 @@ elif [ "${engine}" == "dontstarve" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -148,7 +148,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -158,7 +158,7 @@ elif [ "${engine}" == "projectzomboid" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "DefaultPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -201,7 +201,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "maxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -211,7 +211,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "serverport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -219,7 +219,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + queryport=$(grep "steamqueryport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="0" @@ -227,7 +227,7 @@ elif [ "${engine}" == "realvirtuality" ]; then # master port if [ -f "${servercfgfullpath}" ]; then - masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd "[:digit:]") + masterport=$(grep "steamport=" "${servercfgfullpath}" | grep -v // | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${masterport}" ]; then masterport="0" @@ -259,7 +259,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd "[:digit:]") + slots=$(grep "gam_ctMaxPlayers" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -279,7 +279,7 @@ elif [ "${engine}" == "seriousengine35" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "prj_uwPort" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -309,7 +309,7 @@ elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then # server password if [ -f "${servercfgfullpath}" ]; then - serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password//g' | sed 's/"//g') + serverpassword=$(grep "sv_password" "${servercfgfullpath}" | sed 's/sv_password //g' | sed 's/"//g') if [ ! -n "${serverpassword}" ]; then serverpassword="NOT SET" fi @@ -364,7 +364,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "default_voice_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="9987" @@ -372,7 +372,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + queryport=$(grep "query_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="10011" @@ -380,7 +380,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then # file port if [ -f "${servercfgfullpath}" ]; then - fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + fileport=$(grep "filetransfer_port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${fileport}" ]; then fileport="30033" @@ -422,7 +422,7 @@ elif [ "${engine}" == "teeworlds" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="8303" @@ -430,7 +430,7 @@ elif [ "${engine}" == "teeworlds" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "sv_max_clients" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="12" fi @@ -444,7 +444,7 @@ elif [ "${engine}" == "terraria" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "port=" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "port=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -484,7 +484,7 @@ elif [ "${engine}" == "unity3d" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + webadminport=$(grep "ControlPanelPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -522,7 +522,7 @@ elif [ "${engine}" == "unity3d" ]; then # telnet port if [ -f "${servercfgfullpath}" ]; then - telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd "[:digit:]") + telnetport=$(grep "TelnetPort" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${telnetport}" ]; then telnetport="0" @@ -540,7 +540,7 @@ elif [ "${engine}" == "unity3d" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "ServerMaxPlayerCount" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -570,7 +570,7 @@ elif [ "${engine}" == "unity3d" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd "[:digit:]") + port=$(grep "sv_port" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -620,7 +620,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd "[:digit:]") + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "Master" | grep -v "LAN" | grep -v "Proxy" | grep -v "Listen" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -636,7 +636,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # gamespy query port if [ -f "${servercfgfullpath}" ]; then - gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + gsqueryport=$(grep "OldQueryPortNumber=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${gsqueryport}" ]; then gsqueryport="0" @@ -662,7 +662,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # webadmin port if [ -f "${servercfgfullpath}" ]; then - webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd "[:digit:]") + webadminport=$(grep "ListenPort=" "${servercfgfullpath}" | tr -d '\r' | tr -cd '[:digit:]') fi if [ ! -n "${webadminport}" ]; then webadminport="0" @@ -750,7 +750,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # slots if [ -f "${servercfgfullpath}" ]; then - slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd "[:digit:]") + slots=$(grep "MaxPlayers=" "${servercfgfullpath}" | tr -cd '[:digit:]') if [ ! -n "${slots}" ]; then slots="NOT SET" fi @@ -760,7 +760,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # port if [ -f "${servercfgfullpath}" ]; then - port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd "[:digit:]") + port=$(grep "Port=" "${servercfgfullpath}" | grep -v "RCONPort=" | grep -v "QueryPort=" | tr -cd '[:digit:]') fi if [ ! -n "${port}" ]; then port="0" @@ -768,7 +768,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # rcon port if [ -f "${servercfgfullpath}" ]; then - rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + rconport=$(grep "RCONPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${rconport}" ]; then rconport="0" @@ -776,7 +776,7 @@ elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # query port if [ -f "${servercfgfullpath}" ]; then - queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd "[:digit:]") + queryport=$(grep "QueryPort=" "${servercfgfullpath}" | tr -cd '[:digit:]') fi if [ ! -n "${queryport}" ]; then queryport="0" From 97372c24ac7e4ed2cc32fbfaad76503c4c0011cb Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:42:12 +0000 Subject: [PATCH 29/42] date corrected --- functions/fn_details_distro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/fn_details_distro b/functions/fn_details_distro index b11b27b14..4246d4a89 100644 --- a/functions/fn_details_distro +++ b/functions/fn_details_distro @@ -2,7 +2,7 @@ # LGSM fn_details_distro function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 270515 +# Version: 301015 # Description: Variables providing useful info on the Operating System such as disk and performace info. # Used for fn_details, fn_debug and fn_email. From 291bc8a0280209c51a4e45edf6d422bcfb806201 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:42:43 +0000 Subject: [PATCH 30/42] added newer version --- functions/fn_install_glibcfix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/fn_install_glibcfix b/functions/fn_install_glibcfix index 52868e908..18f1b0840 100644 --- a/functions/fn_install_glibcfix +++ b/functions/fn_install_glibcfix @@ -2,7 +2,7 @@ # LGSM fn_install_glibcfix function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 050715 +# Version: 301015 fn_glibcfixmsg(){ echo "" @@ -48,7 +48,7 @@ if [ -z $(command -v ldd) ]; then esac done # if Glibc less than 1.15 -elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 ]; then +elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 215 ]; then # Blade Symphony if [ "${gamename}" == "Blade Symphony" ]; then glibcversion="2.15" @@ -110,7 +110,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 wget -nv -N https://github.com/dgibbs64/linuxgsm/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" # if Glibc less than 1.13 - elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 213 ]; then + elif [ "$(ldd --version | sed -n '1 p' | tr -cd '[:digit:]' | tail -c 3)" -lt 213 ]; then # ARMA 3 if [ "${gamename}" == "ARMA 3" ]; then glibcversion="2.13" From 111d12359a5240fa3ebda8c55d66637b65e1d1e1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:43:30 +0000 Subject: [PATCH 31/42] added newer version --- functions/fn_install_ts3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/fn_install_ts3 b/functions/fn_install_ts3 index 81c229f88..bde40acfe 100644 --- a/functions/fn_install_ts3 +++ b/functions/fn_install_ts3 @@ -2,7 +2,7 @@ # LGSM fn_install_ts3 function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 270715 +# Version: 311015 fn_details_distro # Gets the teamspeak server architecture @@ -19,7 +19,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 > .ts3_version_numbers_unsorted.tmp # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp From 7222b48160edcecb687633911c4238f465322138 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:44:00 +0000 Subject: [PATCH 32/42] added newer version --- functions/fn_monitor_query | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index 33b158ac3..f56b6cf23 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -2,7 +2,7 @@ # LGSM fn_monitor_query function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 030715 +# Version: 311015 # Description: uses gsquery.py to directly query the server. # Detects if the server has frozen. @@ -10,15 +10,15 @@ local modulename="Monitor" if [ -f "${rootdir}/gsquery.py" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then - gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd [:digit:]) + gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd '[:digit:]') port=$((${gameport} + 1)) elif [ "${engine}" == "spark" ]; then port=$((${port} + 1)) elif [ "${engine}" == "realvirtuality" ]; then - queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd [:digit:]) + queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd '[:digit:]') port=${queryport} elif [ "${engine}" == "unity3d" ]; then - gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd [:digit:]) + gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd '[:digit:]') port=$((${gameport} + 1)) fi fn_printinfo "Detected gsquery.py" From 841d9fc5c087c4ace5dab8e668aa36e43c7fb7b1 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:44:31 +0000 Subject: [PATCH 33/42] added newer version --- functions/fn_start | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/fn_start b/functions/fn_start index 8bb90da71..66d9ae355 100644 --- a/functions/fn_start +++ b/functions/fn_start @@ -2,7 +2,7 @@ # LGSM fn_start function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 291015 +# Version: 301015 # Description: Starts the server. @@ -126,11 +126,11 @@ 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 +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" -elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd [:digit:])" -eq "18" ]; then +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 "http://gameservermanagers.com/tmux-upgrade" >> "${consolelog}" echo "Currently installed: $(tmux -V)" >> "${consolelog}" From 5d323790522e37b7b4891948e329216b8bf43794 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 17:45:16 +0000 Subject: [PATCH 34/42] newer version --- functions/fn_update_check | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/functions/fn_update_check b/functions/fn_update_check index 6ac663ef6..443a88f1c 100644 --- a/functions/fn_update_check +++ b/functions/fn_update_check @@ -2,11 +2,7 @@ # LGSM fn_update_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -<<<<<<< HEAD -# Version: 281015 -======= # Version: 311015 ->>>>>>> refs/remotes/origin/master # Description: Checks if a server update is available. @@ -223,7 +219,7 @@ ts3arch=$(ls $(find ${filesdir}/ -name 'ts3server_*_*' 2> /dev/null | grep -v 't 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 # removes digits to allow sorting of numbers -cat .ts3_version_numbers_unsorted.tmp |tr -cd "[:digit:][*\n]" > .ts3_version_numbers_digit.tmp +cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp # Sorts numbers in to correct order # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp @@ -257,8 +253,8 @@ else fi # Removes dots so if can compare version numbers -currentbuilddigit=$(echo "${currentbuild}"|tr -cd "[:digit:]") -availablebuilddigit=$(echo "${availablebuild}"|tr -cd "[:digit:]") +currentbuilddigit=$(echo "${currentbuild}"|tr -cd '[:digit:]') +availablebuilddigit=$(echo "${availablebuild}"|tr -cd '[:digit:]') if [ "${currentbuilddigit}" -ne "${availablebuilddigit}" ]; then echo -e "\n" echo -e "Update available:" From 8e93ab4d9f725b003d68953a3f4f7d1437742e46 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 23:22:44 +0000 Subject: [PATCH 35/42] quotes --- functions/fn_check_steamuser | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/fn_check_steamuser b/functions/fn_check_steamuser index 5080c98d8..e62086201 100644 --- a/functions/fn_check_steamuser +++ b/functions/fn_check_steamuser @@ -2,16 +2,16 @@ # LGSM fn_check_steamuser function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 040715 +# Version: 011115 if [ -z "${steamuser}" ]||[ "${steamuser}" == "username" ]; then fn_printwarnnl "Steam login not set. Using anonymous login." - if [ -d ${scriptlogdir} ]; then + if [ -d "${scriptlogdir}" ]; then fn_scriptlog "Steam login not set. Using anonymous login." fi if [ "${steamuser}" == "username" ]; then echo " * Change steamuser=\"username\" to a valid steam login." - if [ -d ${scriptlogdir} ]; then + if [ -d "${scriptlogdir}" ]; then fn_scriptlog "Change steamuser=\"username\" to a valid steam login." fi fi From 01be80d4b376e31b5c19e80f762d43086fa85cf2 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 23:39:13 +0000 Subject: [PATCH 36/42] Updated fn_check_steamuser to exit if user not set Instead of continuing with an install or update that will fail script will now exir --- functions/fn_check_steamuser | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/functions/fn_check_steamuser b/functions/fn_check_steamuser index e62086201..264d7cb49 100644 --- a/functions/fn_check_steamuser +++ b/functions/fn_check_steamuser @@ -2,20 +2,22 @@ # LGSM fn_check_steamuser function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 011115 +# Version: 040715 -if [ -z "${steamuser}" ]||[ "${steamuser}" == "username" ]; then - fn_printwarnnl "Steam login not set. Using anonymous login." - if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "Steam login not set. Using anonymous login." - fi - if [ "${steamuser}" == "username" ]; then - echo " * Change steamuser=\"username\" to a valid steam login." - if [ -d "${scriptlogdir}" ]; then - fn_scriptlog "Change steamuser=\"username\" to a valid steam login." - fi - fi - steamuser="anonymous" - steampass="" - sleep 2 +if [ "${steamuser}" == "username" ]; then + fn_printfailnl "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." + exit 1 + fi +fi +if [ -z "${steamuser}" ]; then + fn_printwarnnl "Steam login not set. Using anonymous login." + if [ -d ${scriptlogdir} ]; then + fn_scriptlog "Steam login not set. Using anonymous login." + fi + steamuser="anonymous" + steampass="" + sleep 2 fi From 75c9710a997362525016ddec8542844f388ddfc0 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 1 Nov 2015 23:46:11 +0000 Subject: [PATCH 37/42] fixed if statement error --- functions/fn_update_check | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/fn_update_check b/functions/fn_update_check index 443a88f1c..8ccda2105 100644 --- a/functions/fn_update_check +++ b/functions/fn_update_check @@ -2,7 +2,7 @@ # LGSM fn_update_check function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 311015 +# Version: 011115 # Description: Checks if a server update is available. @@ -53,7 +53,7 @@ if [ "${appmanifestfilewc}" -ge "2" ]; then fn_update_check fi elif [ "${appmanifestfilewc}" -eq "0" ]; then - if [ "${forceupdate}" -eq "1" ]; then + if [ "${forceupdate}" == "1" ]; then fn_printfail "Still no appmanifest_${appid}.acf found: Unable to update" fn_scriptlog "Warning! Still no appmanifest_${appid}.acf found: Unable to update" exit 1 @@ -135,7 +135,7 @@ else sleep 1 fi -if [ "${currentbuild}" -ne "${availablebuild}" ]; then +if [ "${currentbuild}" != "${availablebuild}" ]; then echo -e "\n" echo -e "Update available:" sleep 1 From 9d2bb49639c72d33af515d4bb7a2e5cefe9da60c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 5 Nov 2015 11:41:35 +0000 Subject: [PATCH 38/42] deleted this test.sh --- test.sh | 484 -------------------------------------------------------- 1 file changed, 484 deletions(-) delete mode 100644 test.sh diff --git a/test.sh b/test.sh deleted file mode 100644 index 839b7538c..000000000 --- a/test.sh +++ /dev/null @@ -1,484 +0,0 @@ -#!/bin/bash -# Just Cause 2 -# Server Management Script -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -version="150715" - -#### Variables #### - -# Notification Email -# (on|off) -emailnotification="on" -email="me@danielgibbs.co.uk" - -# Steam login -steamuser="anonymous" -steampass="" - -# Start Variables -updateonstart="off" - -fn_parms(){ -parms="" -} - -#### Advanced Variables #### - -# Steam -appid="261140" - -# Server Details -servicename="jc2-server" -gamename="Just Cause 2" -engine="avalanche" - -# Directories -rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/jc2server" -selfname="$(basename $0)" -lockselfname=".${servicename}.lock" -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" - -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 - -fn_runfunction(){ -# Functions are downloaded and run with this function -if [ ! -f "${rootdir}/functions/${functionfile}" ]; then - cd "${rootdir}" - if [ ! -d "functions" ]; then - mkdir functions - fi - cd functions - echo -e " loading ${functionfile}...\c" - wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- - chmod +x "${functionfile}" - cd "${rootdir}" -fi -source "${rootdir}/functions/${functionfile}" -} - -fn_functions(){ -# Functions are defined in fn_functions. -functionfile="${FUNCNAME}" -fn_runfunction -} - -fn_functions - -getopt=$1 - -fn_currentstatus(){ -pid=$(tmux list-sessions 2>&1 | awk '{print $1}' | grep -Ec "^${servicename}:") -if [ "${pid}" == "0" ]; then - currentstatus="OFFLINE" -else - currentstatus="ONLINE" -fi -} - -fn_setstatus(){ - fn_currentstatus - - echo"" - echo "Required status: ${requiredstatus}" - counter=0 - while [ "${requiredstatus}" != "${currentstatus}" ]; do - counter=$((counter+1)) - fn_currentstatus - - echo -ne "Current status: ${currentstatus}\\r" - if [ "${requiredstatus}" == "ONLINE" ]; then - (fn_start > /dev/null 2>&1) - else - (fn_stop > /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 - fi - done - echo -ne "Current status: ${currentstatus}\\r" - echo -e "\n" - echo "Test starting:" - echo "" - sleep 0.5 -} - -echo "=================================" -echo "TravisCI Tests" -echo "Linux Game Server Manager" -echo "by Daniel Gibbs" -echo "http://gameservermanagers.com" -echo "=================================" -echo "" -sleep 1 -echo "=================================" -echo "Generic Server Tests" -echo "Using: ${gamename}" -echo "=================================" -echo "" -sleep 1 -mkdir ${rootfdir} - - -echo "1.0 - start - no files" -echo "=================================" -echo "Description:" -echo "Test script reaction to missing server files." -requiredstatus="OFFLINE" -fn_setstatus -(fn_start) -echo "" -echo "Test complete!" -sleep 1 -echo "" - - - -echo "2.0 - install" -echo "=================================" -echo "Description:" -echo "install ${gamename} server." -requiredstatus="OFFLINE" -fn_setstatus -fn_autoinstall -echo "" -echo "Test complete!" -sleep 1 -echo "" - - - -echo "3.1 - start" -echo "=================================" -echo "Description:" -echo "start ${gamename} server." -requiredstatus="OFFLINE" -fn_setstatus -fn_start -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.2 - start - online" -echo "=================================" -echo "Description:" -echo "start ${gamename} server while already running." -requiredstatus="ONLINE" -fn_setstatus -(fn_start) -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.3 - start - updateonstart" -echo "=================================" -echo "Description:" -echo "will update server on start." -requiredstatus="ONLINE" -fn_setstatus -( - updateonstart="on" - fn_start -) -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.4 - stop" -echo "=================================" -echo "Description:" -echo "stop ${gamename} server." -requiredstatus="ONLINE" -fn_setstatus -fn_stop -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.5 - stop - offline" -echo "=================================" -echo "Description:" -echo "stop ${gamename} server while already stopped." -requiredstatus="OFFLINE" -fn_setstatus -(fn_stop) -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.6 - restart" -echo "=================================" -echo "Description:" -echo "restart ${gamename}." -requiredstatus="ONLINE" -fn_setstatus -fn_restart -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "3.7 - restart - offline" -echo "=================================" -echo "Description:" -echo "restart ${gamename} while already stopped." -requiredstatus="OFFLINE" -fn_setstatus -fn_restart -echo "" -echo "Test complete!" -sleep 1 -echo "" - - - -echo "4.1 - update" -echo "=================================" -echo "Description:" -echo "check for updates." -requiredstatus="OFFLINE" -fn_setstatus -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.2 - update - change buildid" -echo "=================================" -echo "Description:" -echo "change the buildid tricking SteamCMD to update." -requiredstatus="OFFLINE" -fn_setstatus -fn_printinfonl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -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_printinfonl "changed buildid to 0." -sed -i 's/[0-9]\+/0/' ${filesdir}/steamapps/appmanifest_${appid}.acf -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -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_printinfonl "removed appmanifest_${appid}.acf." -rm --verbose "${filesdir}/steamapps/appmanifest_${appid}.acf" -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.5 - force-update" -echo "=================================" -echo "Description:" -echo "force-update bypassing update check." -requiredstatus="OFFLINE" -fn_setstatus -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.6 - force-update - online" -echo "=================================" -echo "Description:" -echo "force-update bypassing update check server while already running." -requiredstatus="ONLINE" -fn_setstatus -fn_update_check -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.7 - validate" -echo "=================================" -echo "Description:" -echo "validate server files." -requiredstatus="OFFLINE" -fn_setstatus -fn_validate -echo "" -echo "Test complete!" -sleep 1 -echo "" -echo "4.8 - validate - online" -echo "=================================" -echo "Description:" -echo "validate server files while server while already running." -requiredstatus="ONLINE" -fn_setstatus -fn_validate -echo "" -echo "Test complete!" -sleep 1 -echo "" - - - -echo "5.1 - monitor - online" -echo "=================================" -echo "Description:" -echo "run monitor server while already running." -requiredstatus="ONLINE" -fn_setstatus -(fn_monitor) -echo "" -echo "Test complete!" -sleep 1 -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 -(fn_monitor) -echo "" -echo "Test complete!" -sleep 1 -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_printinfonl "creating lockfile." -date > "${rootdir}/${lockselfname}" -(fn_monitor) -echo "" -echo "Test complete!" -sleep 1 -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}" -fn_monitor -echo "" -fn_printinfonl "Reseting ${servercfg}." -fn_install_config -echo "" -echo "Test complete!" -sleep 1 -echo "" - - - -echo "6.0 - details" -echo "=================================" -echo "Description:" -echo "gsquery.py will fail to query port." -requiredstatus="ONLINE" -fn_setstatus -fn_details -echo "" -echo "Test complete!" -sleep 1 -echo "" - -echo "=================================" -echo "Generic Server Tests - Complete!" -echo "Using: ${gamename}" -echo "=================================" -echo "" -sleep 1 -fn_printinfo "Tidying up directories." -sleep 1 -rm -rfv ${rootdir} -echo "END" - -#!/bin/bash -# Teamspeak 3 -# Server Management Script -# Author: Daniel Gibbs -# Website: http://gameservermanagers.com -version="040715" - -#### Variables #### - -# Notification Email -# (on|off) -emailnotification="on" -email="me@Danielgibbs.co.uk" - -# Start Variables -updateonstart="off" - -# Server Details -gamename="Teamspeak 3" -servername="Teamspeak 3 Server" -servicename="ts3-server" - -# Directories -rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/ts3server" -selfname="$(basename $0)" -lockselfname=".${servicename}.lock" -filesdir="${rootdir}/serverfiles" -systemdir="${filesdir}" -executabledir="${filesdir}" -executable="./ts3server_startscript.sh" -servercfg="${servicename}.ini" -servercfgdir="${filesdir}" -servercfgfullpath="${servercfgdir}/${servercfg}" -backupdir="${rootdir}/backups" - -# Logging -logdays="7" -gamelogdir="${filesdir}/logs" -scriptlogdir="${rootdir}/log/script" - -scriptlog="${scriptlogdir}/${servicename}-script.log" -emaillog="${scriptlogdir}/${servicename}-email.log" - -scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" - - -echo "=================================" -echo "Generic Server Tests" -echo "Using: ${gamename}" -echo "=================================" -echo "" -sleep 1 \ No newline at end of file From 4ced108b32a55ef9813235cefc57d2c9d811c5ff Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 5 Nov 2015 11:41:46 +0000 Subject: [PATCH 39/42] minor change to test --- tests/test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test.sh b/tests/test.sh index cbe7fdbaf..531066649 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -144,6 +144,7 @@ echo "Using: ${gamename}" echo "=================================" echo "" sleep 1 +mkdir ${rootfdir} echo "1.0 - start - no files" From 082e494fcad78e67ba42114683dcafbf7416220c Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 5 Nov 2015 11:48:40 +0000 Subject: [PATCH 40/42] Added default y in to y/n options Because im lazy --- functions/fn_debug | 4 ++-- functions/fn_install_glibcfix | 4 ++-- functions/fn_install_gsquery | 4 ++-- functions/fn_install_retry | 4 ++-- functions/fn_install_serverfiles | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/fn_debug b/functions/fn_debug index d303e6498..ce2f91ce9 100644 --- a/functions/fn_debug +++ b/functions/fn_debug @@ -2,7 +2,7 @@ # LGSM fn_debug function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 311015 +# Version: 051115 # Description: Runs the server without tmux. Runs direct from the terminal. @@ -34,7 +34,7 @@ echo -e "Press CTRL+c to drop out of debug mode." fn_printwarningnl "If ${servicename} is already running it will be stopped." 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;; diff --git a/functions/fn_install_glibcfix b/functions/fn_install_glibcfix index 18f1b0840..11dc3362d 100644 --- a/functions/fn_install_glibcfix +++ b/functions/fn_install_glibcfix @@ -2,7 +2,7 @@ # LGSM fn_install_glibcfix function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 301015 +# Version: 051115 fn_glibcfixmsg(){ echo "" @@ -40,7 +40,7 @@ if [ -z $(command -v ldd) ]; then sleep 1 echo "" while true; do - read -p "Continue install? [y/N]" yn + read -e -i "y" -p "Continue install? [Y/n]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; exit;; diff --git a/functions/fn_install_gsquery b/functions/fn_install_gsquery index ca2647908..896e01eff 100644 --- a/functions/fn_install_gsquery +++ b/functions/fn_install_gsquery @@ -2,7 +2,7 @@ # LGSM fn_install_gsquery function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 070715 +# Version: 051115 fn_dlgsquery(){ cd "${rootdir}" @@ -17,7 +17,7 @@ if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine} echo "============================" if [ -z ${autoinstall} ]; then while true; do - read -p "Do you want to install GameServerQuery? [y/N]" yn + read -e -i "y" -p "Do you want to install GameServerQuery? [Y/n]" yn case $yn in [Yy]* ) fn_dlgsquery;break;; [Nn]* ) echo ""; echo "Not installing GameServerQuery.";break;; diff --git a/functions/fn_install_retry b/functions/fn_install_retry index 0f3117e21..7146327e1 100644 --- a/functions/fn_install_retry +++ b/functions/fn_install_retry @@ -2,10 +2,10 @@ # LGSM fn_install_retry function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 210115 +# Version: 051115 while true; do - read -p "Retry install? [y/N]" yn + read -e -i "y" -p "Retry install? [Y/n]" yn case $yn in [Yy]* ) fn_install; exit;; [Nn]* ) echo Exiting; exit;; diff --git a/functions/fn_install_serverfiles b/functions/fn_install_serverfiles index ffeeebdd1..961106370 100644 --- a/functions/fn_install_serverfiles +++ b/functions/fn_install_serverfiles @@ -2,7 +2,7 @@ # LGSM fn_install_serverfiles function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 040715 +# Version: 051115 fn_steaminstallcommand(){ fn_check_steamuser @@ -78,7 +78,7 @@ if [ -z "${autoinstall}" ]; then echo "" echo "=================================" while true; do - read -p "Was the install successful? [y/N]" yn + read -e -i "y" -p "Was the install successful? [Y/n]" yn case $yn in [Yy]* ) break;; [Nn]* ) fn_install_retry;; From f5f8be127630a57bd7a502a0a80adf56a9eb8942 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 5 Nov 2015 19:10:41 +0000 Subject: [PATCH 41/42] Added pvkiiserver --- .../cfg/lgsm-default.cfg | 119 ++++++++++++++++++ PiratesVikingandKnightsII/pvkiiserver | 98 +++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 PiratesVikingandKnightsII/cfg/lgsm-default.cfg create mode 100644 PiratesVikingandKnightsII/pvkiiserver diff --git a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg new file mode 100644 index 000000000..8469f1014 --- /dev/null +++ b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg @@ -0,0 +1,119 @@ +// **************************************************************************** +// * +// Pirates, Vikings, and Knights II * +// Version 150815 * +// * +// **************************************************************************** + +// ............................. Basic Settings ............................. // + +// Hostname for server. +hostname "" + +// RCON - remote console password. +rcon_password "" + +// Server password - for private servers. +sv_password "" + +// Contact email for server sysop. +sv_contact "email@example.com" + +// LAN Mode - If set the server will not show on the internet. +// Default: sv_lan 0 +sv_lan 0 + +// ............................... Map Cycles ............................... // +// You can create your own custom mapcycle. +mapcyclefile "mapcycle.txt" + +// ....................... Time Limits/Round Settings ....................... // + +// Time spend on a single map (in minutes) before switching to a new one automatically. +// Default: mp_timelimit 0 +mp_timelimit 20 + +// Wait for the end of round before changing map. +// Default: mp_timelimit_waitroundend 0 +mp_timelimit_waitroundend 1 + +// Round duration in minutes. +// Default: mp_roundtime 3 +mp_roundtime 3 + +// Round limit in number of rounds. +// Default: mp_roundlimit 0 + +// Win limit in number of rounds. +// Default: mp_winlimit 0 +mp_winlimit 0 + +// ........................ Server Specific Commands ........................ // + +// Server tags - Tags show up on the in-game server browser. This helps +// users filter servers. +// vanilla - he server runs the default settings. +// custom - the server runs custom gameplay settings or mods. +// example: sv_tags "custom, fastdl" +sv_tags "" + +// Friendly fire - Allows team members to injure other members of their team. +// Default: mp_friendlyfire 0 +mp_friendlyfire 0 + +// ............................. Communication ............................. // + +// Enable communication over voice via microphone. +// Default: sv_voiceenable 1 +sv_voiceenable 1 + +// Players can hear all other players, no team restrictions. +// Default: sv_alltalk 0 +sv_alltalk 0 + +// ............................. Fast Download .............................. // +// info: Allows custom maps to be downloaded to the client. + +// Allows clients to download custom maps and textures etc. from the server at 20 kbps. +// Default: sv_allowdownload 1 +sv_allowdownload 1 + +// Allows clients to download custom maps, textures etc. from a web server with no transfer limit. +// Example: +// server location: maps/custommap.bsp +// web server location: http://example.com/custom/maps/custommap.bsp +// sv_downloadurl "http://example.com/custom" +// Default: sv_downloadurl "" +sv_downloadurl "" + +// ................................ Ban List ............................... // + +// personal banlist based on user IDs. +exec banned_user.cfg + +// personal banlist based on user IPs. +exec banned_ip.cfg + +writeid +writeip + +// ............................. Server Logging ............................. // + +//Enables logging to file, console, and udp < on | off >. +log on + +// Log server bans in the server logs. +// Default: sv_logbans 1 +sv_logbans 1 + +// Echo log information to the console. +// Default: sv_logecho 1 +sv_logecho 1 + +// Log server information in the log file. +// Default: sv_logfile 1 +sv_logfile 1 + +// Log server information to only one file. +// Default: sv_log_onefile 0 +sv_log_onefile 0 diff --git a/PiratesVikingandKnightsII/pvkiiserver b/PiratesVikingandKnightsII/pvkiiserver new file mode 100644 index 000000000..baa625b47 --- /dev/null +++ b/PiratesVikingandKnightsII/pvkiiserver @@ -0,0 +1,98 @@ +#!/bin/bash +# No More Room in Hell +# Server Management Script +# Author: Daniel Gibbs +# Website: http://gameservermanagers.com +version="051115" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="off" +email="email@example.com" + +# Steam login +steamuser="anonymous" +steampass="" + +# Start Variables +defaultmap="bt_island" +maxplayers="24" +port="27015" +sourcetvport="27020" +clientport="27005" +ip="0.0.0.0" +updateonstart="off" + +# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server +fn_parms(){ +parms="-game pvkii -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}" +} + +#### Advanced Variables #### + +# Steam +appid="17575" + +# Server Details +servicename="pvkii-server" +gamename="Pirates, Vikings, and Knights II" +engine="source" + +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +selfname="$(basename $0)" +lockselfname=".${servicename}.lock" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}/pvkii" +executabledir="${filesdir}" +executable="./srcds_run" +servercfg="${servicename}.cfg" +servercfgdir="${systemdir}/cfg" +servercfgfullpath="${servercfgdir}/${servercfg}" +servercfgdefault="${servercfgdir}/lgsm-default.cfg" +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${systemdir}/logs" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" + +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 + +fn_runfunction(){ +# Functions are downloaded and run with this function +if [ ! -f "${rootdir}/functions/${functionfile}" ]; then + cd "${rootdir}" + if [ ! -d "functions" ]; then + mkdir functions + fi + cd functions + echo -e " loading ${functionfile}...\c" + wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- + chmod +x "${functionfile}" + cd "${rootdir}" +fi +source "${rootdir}/functions/${functionfile}" +} + +fn_functions(){ +# Functions are defined in fn_functions. +functionfile="${FUNCNAME}" +fn_runfunction +} + +fn_functions + +getopt=$1 +fn_getopt From 1a3557fadddcb7630ee9b4acdb8ea8346a8eb3fc Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 5 Nov 2015 19:11:44 +0000 Subject: [PATCH 42/42] added pvkiiserver --- functions/fn_install_config | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/fn_install_config b/functions/fn_install_config index 1dfa75168..3cc70d389 100644 --- a/functions/fn_install_config +++ b/functions/fn_install_config @@ -2,7 +2,7 @@ # LGSM fn_install_config function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -# Version: 291015 +# Version: 051115 fn_defaultconfig(){ echo "creating ${servercfg} config file." @@ -281,6 +281,11 @@ elif [ "${gamename}" == "Natural Selection 2" ]; then echo -e "no configs required." sleep 1 echo "" +elif [ "${gamename}" == "Pirates, Vikings, and Knights II" ]; then + echo -e "downloading lgsm-default.cfg...\c" + wget -N /dev/null ${githuburl}/PiratesVikingandKnightsII/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq + sleep 1 + fn_sourceconfig elif [ "${gamename}" == "Red Orchestra: Ostfront 41-45" ]; then fn_unreal2config elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then