From 3e8b7b9982372dc463bba5d6581a23f4fe79f5c9 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Sep 2014 11:43:59 +0100 Subject: [PATCH] Synced scripts and bug fixes * Synced the scripts so all functions correctly match * updated fn_autoip so 127.0.0.0 range should be ignored * glibcfix function added where required * Fixed update-restart bug causing the lockfile to be created in the wrong directory #172 * gmodserver libsteamfix added * General code tidy up --- Arma3/arma3server | 79 +++++++++++++--------- BladeSymphony/bsserver | 76 ++++++++++++--------- CounterStrike/csserver | 79 +++++++++++++--------- CounterStrikeConditionZero/csczserver | 83 +++++++++++++---------- CounterStrikeGlobalOffensive/csgoserver | 81 ++++++++++++---------- CounterStrikeSource/cssserver | 79 +++++++++++++--------- DayOfDefeat/dodserver | 81 ++++++++++++---------- DayOfDefeatSource/dodsserver | 79 +++++++++++++--------- FistfulOfFrags/fofserver | 76 ++++++++++++--------- GarrysMod/gmodserver | 90 ++++++++++++++++--------- HalfLife2Deathmatch/hl2dmserver | 81 ++++++++++++---------- HalfLifeDeathmatchClassic/hldmcserver | 79 +++++++++++++--------- Insurgency/insserver | 76 ++++++++++++--------- KillingFloor/kfserver | 21 +++--- Left4Dead/l4dserver | 83 +++++++++++++---------- Left4Dead2/l4d2server | 78 ++++++++++++--------- NaturalSelection2/ns2server | 76 ++++++++++++--------- NoMoreRoomInHell/nmrihserver | 78 ++++++++++++--------- RedOrchestra/roserver | 83 ++++++++++++++--------- TeamFortress2/tf2server | 79 +++++++++++++--------- TeamFortressClassic/tfcserver | 79 +++++++++++++--------- UnrealTournament2004/ut2k4server | 19 +++--- UnrealTournament99/ut99server | 75 ++++++++++++--------- 23 files changed, 1003 insertions(+), 707 deletions(-) diff --git a/Arma3/arma3server b/Arma3/arma3server index 6ae9e204f..9e6eaa4a4 100644 --- a/Arma3/arma3server +++ b/Arma3/arma3server @@ -34,7 +34,7 @@ servicename="arma3-server" gamename="ARMA 3" engine="realvirtuality" -# Directorys +# Directories rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" lockselfname=$(echo ".${servicename}.lock") @@ -47,7 +47,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed -e 's/\//g'| tr -d '=\"; ') @@ -115,7 +114,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -160,28 +159,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -251,8 +262,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -303,8 +314,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -372,9 +383,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -405,11 +416,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -419,9 +430,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -435,14 +445,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -459,9 +469,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -473,26 +483,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -511,11 +521,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -562,8 +572,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -586,6 +596,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -594,13 +607,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -716,7 +729,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -726,7 +739,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -736,7 +749,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -744,7 +757,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -753,7 +766,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/BladeSymphony/bsserver b/BladeSymphony/bsserver index b22483066..8edd0b662 100644 --- a/BladeSymphony/bsserver +++ b/BladeSymphony/bsserver @@ -117,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -162,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -716,7 +730,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -726,7 +740,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -736,7 +750,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -744,7 +758,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -753,7 +767,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/CounterStrike/csserver b/CounterStrike/csserver index ebcc59d0b..a4ef70cb0 100644 --- a/CounterStrike/csserver +++ b/CounterStrike/csserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -51,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -117,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +690,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +729,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +758,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/CounterStrikeConditionZero/csczserver b/CounterStrikeConditionZero/csczserver index 4f6933c63..69e809cb9 100644 --- a/CounterStrikeConditionZero/csczserver +++ b/CounterStrikeConditionZero/csczserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -51,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -117,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +690,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +729,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +758,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac @@ -876,7 +889,7 @@ case "$1" in update-restart) fn_stopserver fn_updateserver - fn_startserver;; + fn_startserver;; validate) fn_validateserver;; validate-restart) @@ -901,4 +914,4 @@ case "$1" in echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install}" exit 1;; esac -exit +exit \ No newline at end of file diff --git a/CounterStrikeGlobalOffensive/csgoserver b/CounterStrikeGlobalOffensive/csgoserver index 50f23dfa3..e3bb136fb 100644 --- a/CounterStrikeGlobalOffensive/csgoserver +++ b/CounterStrikeGlobalOffensive/csgoserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -69,7 +69,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -135,7 +134,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -158,8 +157,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -180,28 +179,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -271,8 +282,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -323,8 +334,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -392,9 +403,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -425,11 +436,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -439,9 +450,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -455,14 +465,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -479,9 +489,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -493,26 +503,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -531,11 +541,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -582,8 +592,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -607,6 +617,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -615,13 +628,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -707,7 +720,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -746,7 +759,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -775,7 +788,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac @@ -882,7 +895,7 @@ case "$1" in update-restart) fn_stopserver fn_updateserver - fn_startserver;; + fn_startserver;; validate) fn_validateserver;; validate-restart) diff --git a/CounterStrikeSource/cssserver b/CounterStrikeSource/cssserver index 95e7e025f..ded6e152d 100644 --- a/CounterStrikeSource/cssserver +++ b/CounterStrikeSource/cssserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -52,7 +52,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -118,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -141,8 +140,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -163,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -254,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -306,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -375,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -408,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -422,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -438,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -462,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -476,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -514,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -565,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -589,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -597,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -678,7 +691,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -717,7 +730,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -746,7 +759,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/DayOfDefeat/dodserver b/DayOfDefeat/dodserver index c579d63a9..d915eed60 100644 --- a/DayOfDefeat/dodserver +++ b/DayOfDefeat/dodserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -51,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -117,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +690,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +729,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +758,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac @@ -879,7 +892,7 @@ case "$1" in update-restart) fn_stopserver fn_updateserver - fn_startserver;; + fn_startserver;; validate) fn_validateserver;; validate-restart) diff --git a/DayOfDefeatSource/dodsserver b/DayOfDefeatSource/dodsserver index 79048b513..949a32c6b 100644 --- a/DayOfDefeatSource/dodsserver +++ b/DayOfDefeatSource/dodsserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -52,7 +52,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -118,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -141,8 +140,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -163,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -254,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -306,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -375,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -408,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -422,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -438,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -462,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -476,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -514,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -565,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -589,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -597,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -678,7 +691,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -717,7 +730,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -746,7 +759,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/FistfulOfFrags/fofserver b/FistfulOfFrags/fofserver index 17fc0066f..a18fb90e9 100644 --- a/FistfulOfFrags/fofserver +++ b/FistfulOfFrags/fofserver @@ -117,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -162,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -716,7 +730,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -726,7 +740,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -736,7 +750,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -744,7 +758,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -753,7 +767,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/GarrysMod/gmodserver b/GarrysMod/gmodserver index 050cd6f8a..3526270f7 100644 --- a/GarrysMod/gmodserver +++ b/GarrysMod/gmodserver @@ -122,7 +122,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -167,28 +167,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -258,8 +270,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -310,8 +322,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -379,9 +391,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -412,11 +424,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -426,9 +438,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -442,14 +453,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -466,9 +477,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -480,26 +491,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -518,11 +529,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -569,8 +580,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -593,6 +604,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -601,13 +615,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -715,13 +729,13 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libc.so.6 wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libm.so.6 wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/GarrysMod/dependencies/libpthread.so.0 - cp -v "${filesdir}/bin/libsteam.so" "${HOME}/.steam/sdk32/libsteam.so" + sleep 1 echo "" elif [ "${gamename}" == "Natural Selection 2" ];then echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -731,7 +745,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -741,7 +755,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -749,7 +763,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -758,7 +772,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -771,6 +785,17 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 fi } +fn_libsteamfix(){ + echo "Applying libsteam.so fix" + echo "=================================" + sleep 1 + mkdir -pv "${HOME}/.steam" + mkdir -pv "${HOME}/.steam/sdk32" + cp -v "${filesdir}/bin/libsteam.so" "${HOME}/.steam/sdk32/libsteam.so" + sleep 1 + echo "" +} + fn_header(){ clear echo "=================================" @@ -908,6 +933,7 @@ fn_header fn_steamdl fn_steaminstall fn_steamfix +fn_libsteamfix fn_loginstall fn_getquery fn_glibcfix diff --git a/HalfLife2Deathmatch/hl2dmserver b/HalfLife2Deathmatch/hl2dmserver index 30daaec3e..8269fbe7b 100644 --- a/HalfLife2Deathmatch/hl2dmserver +++ b/HalfLife2Deathmatch/hl2dmserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -52,7 +52,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -118,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -141,8 +140,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -163,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -254,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -306,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -375,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -408,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -422,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -438,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -462,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -476,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -514,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -565,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -589,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -597,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -678,7 +691,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -717,7 +730,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -746,7 +759,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac @@ -853,7 +866,7 @@ case "$1" in update-restart) fn_stopserver fn_updateserver - fn_startserver;; + fn_startserver;; validate) fn_validateserver;; validate-restart) diff --git a/HalfLifeDeathmatchClassic/hldmcserver b/HalfLifeDeathmatchClassic/hldmcserver index 1c8f12314..543a3e6db 100644 --- a/HalfLifeDeathmatchClassic/hldmcserver +++ b/HalfLifeDeathmatchClassic/hldmcserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -51,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -117,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +690,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +729,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +758,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/Insurgency/insserver b/Insurgency/insserver index 9c89f6a47..47dbbf824 100644 --- a/Insurgency/insserver +++ b/Insurgency/insserver @@ -117,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -162,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -716,7 +730,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -726,7 +740,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -736,7 +750,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -744,7 +758,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -753,7 +767,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/KillingFloor/kfserver b/KillingFloor/kfserver index a6d9844db..732dbd081 100644 --- a/KillingFloor/kfserver +++ b/KillingFloor/kfserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -134,8 +134,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -479,15 +479,16 @@ fn_monitorserver(){ fn_rootcheck fn_syscheck fn_autoip +fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" +sleep 1 if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" + echo "To enable monitor run ${selfname} start" exit fi -fn_printdots "Monitoring ${servicename}: ${servername}" -fn_scriptlog "Monitoring ${servername}" -sleep 1 updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" @@ -609,7 +610,7 @@ if [ ${tmuxwc} -eq 1 ]; then exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -741,7 +742,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -780,7 +781,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -809,7 +810,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/Left4Dead/l4dserver b/Left4Dead/l4dserver index 0e76e6a82..a8800c91e 100644 --- a/Left4Dead/l4dserver +++ b/Left4Dead/l4dserver @@ -2,10 +2,8 @@ # Left 4 Dead # Server Management Script # Author: Daniel Gibbs -# Contributor: Summit Singh Thakur -# Author Website: http://danielgibbs.co.uk -# Contributor Website: http://www.summit.im -# Version: 170914 +# Website: http://danielgibbs.co.uk +# Version: 200914 #### Variables #### @@ -53,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -119,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -142,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -164,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -255,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -307,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -376,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -409,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -423,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -439,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -463,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -477,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -515,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -566,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -590,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -598,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -690,7 +701,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -729,7 +740,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -758,7 +769,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/Left4Dead2/l4d2server b/Left4Dead2/l4d2server index b474ec1b6..a24605b78 100644 --- a/Left4Dead2/l4d2server +++ b/Left4Dead2/l4d2server @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -117,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +140,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +691,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +730,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +759,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/NaturalSelection2/ns2server b/NaturalSelection2/ns2server index 927c96f27..a5313ad86 100644 --- a/NaturalSelection2/ns2server +++ b/NaturalSelection2/ns2server @@ -114,7 +114,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -159,28 +159,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -250,8 +262,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -302,8 +314,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -371,9 +383,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -404,11 +416,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -418,9 +430,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -434,14 +445,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -458,9 +469,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -472,26 +483,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -510,11 +521,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -561,8 +572,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -585,6 +596,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -593,13 +607,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -714,7 +728,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -724,7 +738,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -734,7 +748,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -742,7 +756,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -751,7 +765,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/NoMoreRoomInHell/nmrihserver b/NoMoreRoomInHell/nmrihserver index e67e5f2a8..7ff43ff07 100644 --- a/NoMoreRoomInHell/nmrihserver +++ b/NoMoreRoomInHell/nmrihserver @@ -117,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -162,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,15 +610,15 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" -tmux new-session -d -s ${servicename} "${executable} ${parms} -insecure" +tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) @@ -716,7 +730,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Natural Selection 2" sleep 1 echo "Downloading files for Natural Selection 2 GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NaturalSelection2/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" @@ -726,7 +740,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected No More Room in Hell" sleep 1 echo "Downloading files for No More Room in Hell GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}/srcds" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/NoMoreRoomInHell/dependencies/libm.so.6 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/srcds/libstdc++.so.6" @@ -736,7 +750,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Blade Symphony" sleep 1 echo "Downloading files for Blade Symphony GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" @@ -744,7 +758,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected Fistful of Frags" sleep 1 echo "Downloading files for Fistful of Frags GLIBC Fix" - sleep 1 + sleep 1 cd "${filesdir}" wget -nv -N https://github.com/dgibbs64/linuxgameservers/raw/master/FistfulOfFrags/dependencies/libm.so.6 sleep 1 @@ -753,7 +767,7 @@ elif [ "$(ldd --version | sed -n '1 p' | tr -cd [:digit:] | tail -c 3)" -lt 215 echo "Detected ARMA 3" sleep 1 echo "Downloading files for ARMA 3 GLIBC Fix" - sleep 1 + sleep 1 cp -v "${rootdir}/steamcmd/linux32/libstdc++.so.6" "${filesdir}/libstdc++.so.6" sleep 1 echo "" diff --git a/RedOrchestra/roserver b/RedOrchestra/roserver index 63783c40a..f2170e3a5 100644 --- a/RedOrchestra/roserver +++ b/RedOrchestra/roserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -41,20 +41,23 @@ ip="0.0.0.0" # Logging logdays="7" +gamelogdir="${rootdir}/log/server" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" +gamelog="${gamelogdir}/${servicename}-game.log" scriptlog="${scriptlogdir}/${servicename}-script.log" consolelog="${consolelogdir}/${servicename}-console.log" emaillog="${scriptlogdir}/${servicename}-email.log" +gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').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" # Start Variables fn_parms(){ defaultmap="RO-Arad.rom" -parms="server ${defaultmap}?game=ROGame.ROTeamGame?VACSecured=true -nohomedir ini=${ini} log=${logfile}" +parms="server ${defaultmap}?game=ROGame.ROTeamGame?VACSecured=true -nohomedir ini=${ini} log=${gamelog}" } ##### Script ##### @@ -104,7 +107,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -127,8 +130,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -149,28 +152,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -240,8 +255,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -292,8 +307,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -361,9 +376,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -394,11 +409,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -408,9 +423,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -424,14 +438,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -448,9 +462,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -462,26 +476,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -500,11 +514,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -551,8 +565,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -575,6 +589,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -583,13 +600,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -721,7 +738,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -760,7 +777,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -789,7 +806,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/TeamFortress2/tf2server b/TeamFortress2/tf2server index 0657ca029..fd43403ec 100644 --- a/TeamFortress2/tf2server +++ b/TeamFortress2/tf2server @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -52,7 +52,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -118,7 +117,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -141,8 +140,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -163,28 +162,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -254,8 +265,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -306,8 +317,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -375,9 +386,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -408,11 +419,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -422,9 +433,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -438,14 +448,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -462,9 +472,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -476,26 +486,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -514,11 +524,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -565,8 +575,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -589,6 +599,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -597,13 +610,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -678,7 +691,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -717,7 +730,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -746,7 +759,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/TeamFortressClassic/tfcserver b/TeamFortressClassic/tfcserver index 2beb587fe..940f0162c 100644 --- a/TeamFortressClassic/tfcserver +++ b/TeamFortressClassic/tfcserver @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -51,7 +51,6 @@ servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" -steamclient="${rootdir}/steamcmd/linux32/steamclient.so" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') @@ -117,7 +116,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -140,8 +139,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -162,28 +161,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -253,8 +264,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -305,8 +316,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -374,9 +385,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -407,11 +418,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -421,9 +432,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -437,14 +447,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -461,9 +471,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -475,26 +485,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -513,11 +523,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -564,8 +574,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -588,6 +598,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -596,13 +609,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -677,7 +690,7 @@ mkdir -pv "steamcmd" sleep 1 cd "steamcmd" if [ ! -f steamcmd.sh ]; then - wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz tar --verbose -zxf steamcmd_linux.tar.gz rm -v steamcmd_linux.tar.gz chmod +x steamcmd.sh @@ -716,7 +729,7 @@ echo "=================================" sleep 1 mkdir -pv "${HOME}/.steam" mkdir -pv "${HOME}/.steam/sdk32" -cp -v "${steamclient}" "${HOME}/.steam/sdk32/steamclient.so" +cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so" sleep 1 echo "" } @@ -745,7 +758,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac diff --git a/UnrealTournament2004/ut2k4server b/UnrealTournament2004/ut2k4server index bb8676c97..6f7cef575 100644 --- a/UnrealTournament2004/ut2k4server +++ b/UnrealTournament2004/ut2k4server @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -123,8 +123,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -468,15 +468,16 @@ fn_monitorserver(){ fn_rootcheck fn_syscheck fn_autoip +fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" +sleep 1 if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" + echo "To enable monitor run ${selfname} start" exit fi -fn_printdots "Monitoring ${servicename}: ${servername}" -fn_scriptlog "Monitoring ${servername}" -sleep 1 updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" @@ -566,7 +567,7 @@ if [ ${tmuxwc} -eq 1 ]; then exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -820,7 +821,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac @@ -945,6 +946,4 @@ case "$1" in echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}" exit 1;; esac -exit -esac exit \ No newline at end of file diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server index 54719d3eb..2739e3aad 100644 --- a/UnrealTournament99/ut99server +++ b/UnrealTournament99/ut99server @@ -3,7 +3,7 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk -# Version: 170914 +# Version: 200914 #### Variables #### @@ -15,6 +15,7 @@ email="email@example.com" # Directories rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" +lockselfname=$(echo ".${servicename}.lock") filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" executabledir="${systemdir}" @@ -96,7 +97,7 @@ fn_printwarn(){ fn_printwarnnl(){ echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@" } - + # [ .... ] fn_printdots(){ echo -en "\r\033[K[ .... ] $@" @@ -119,8 +120,8 @@ fi fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually -getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) -getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) +getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0) +getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then fn_printwarn "Multiple active network interfaces.\n\n" @@ -141,28 +142,40 @@ fi # log manager will active if finds logs older than ${logdays} if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then fn_printdots "Starting log cleaner" - sleep 1 + sleep 1 fn_printok "Starting log cleaner" - sleep 1 fn_scriptlog "Starting log cleaner" sleep 1 echo -en "\n" fn_printinfo "Removing logs older than ${logdays} days" - sleep 1 - echo -en "\n" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 + echo -en "\n" + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + fi find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}" + if [ "${engine}" == "unreal2" ]; then + gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) + fi scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l) consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l) count=$((${scriptcount} + ${consolecount})) + if [ "${engine}" == "unreal2" ]; then + count=$((${scriptcount} + ${consolecount} + ${gamecount})) + else + count=$((${scriptcount} + ${consolecount})) + fi + if [ "${engine}" == "unreal2" ]; then + find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \; + fi find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \; find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \; fn_printok "Log cleaner removed ${count} log files" + fn_scriptlog "Log cleaner removed ${count} log files" sleep 1 echo -en "\n" - fn_scriptlog "Log cleaner removed ${count} log files" fi } @@ -232,8 +245,8 @@ sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printoknl "Starting ${servicename} console" - sleep 1 fn_scriptlog "Console accessed" + sleep 1 tmux attach-session -t ${servicename} else fn_printfailnl "Starting ${servicename} console: ${servername} not running" @@ -284,8 +297,8 @@ fi fn_printdots "Starting backup ${servicename}: ${servername}" sleep 1 fn_printok "Starting backup ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Backup started" +sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 @@ -353,9 +366,9 @@ if [ ! -z "${gamelogdir}" ]; then fi mail -s "${subject}" ${email} < "${emaillog}" fn_printinfo "Sent email notification to ${email}" +fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" -fn_scriptlog "Sent email notification to ${email}" } fn_emailtest(){ @@ -386,11 +399,11 @@ if [ -f gsquery.py ]; then port=$((${port} + 1)) fi fn_printinfo "Monitoring ${servicename}: Detected gsquery.py" - sleep 1 fn_scriptlog "Detected gsquery.py" + sleep 1 fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" + sleep 1 serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then @@ -400,9 +413,8 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" if [[ -z "${secondquery}" ]]; then fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query" - sleep 1 fn_scriptlog "Waiting 30 seconds to re-query" - sleep 29 + sleep 30 secondquery=1 fn_serverquery fi @@ -416,14 +428,14 @@ if [ -f gsquery.py ]; then exit elif [ "${exitcode}" == "0" ]; then fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: OK" + sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" - sleep 1 fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" + sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py @@ -440,9 +452,9 @@ if [ -f gsquery.py ]; then fi else fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" + fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" - fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi @@ -454,26 +466,26 @@ fn_rootcheck fn_syscheck fn_autoip fn_printdots "Monitoring ${servicename}: ${servername}" +fn_scriptlog "Monitoring ${servername}" sleep 1 -if [ ! -f ${lockselfname} ]; then +if [ ! -f ${lockselfname} ]; then fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" sleep 1 echo -en "\n" echo "To enable monitor run ${selfname} start" exit fi -fn_scriptlog "Monitoring ${servername}" updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then fn_printdots "Monitoring ${servicename}: Checking session: CHECKING" - sleep 1 fn_scriptlog "Checking session: CHECKING" + sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then fn_printok "Monitoring ${servicename}: Checking session: OK" - sleep 1 - echo -en "\n" fn_scriptlog "Checking session: OK" + sleep 1 + echo -en "\n" fn_serverquery exit else @@ -492,11 +504,11 @@ if [ "${updatecheck}" = "0" ]; then fi else fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates" - sleep 1 fn_scriptlog "Detected SteamCMD is checking for updates" + sleep 1 fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start" - sleep 1 fn_scriptlog "When updates complete ${servicename} will start" + sleep 1 fi } @@ -511,8 +523,8 @@ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) fn_printdots "Stopping ${servicename}: ${servername}" -sleep 1 fn_scriptlog "Stopping ${servername}" +sleep 1 if [ "${pid}" == "0" ]; then fn_printfail "Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" @@ -535,6 +547,9 @@ fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then + if [ "${engine}" == "unreal2" ]; then + mv "${gamelog}" "${gamelogdate}" + fi mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi @@ -543,13 +558,13 @@ sleep 1 fn_scriptlog "Starting ${servername}" if [ ${tmuxwc} -eq 1 ]; then fn_printinfo "Starting ${servicename}: ${servername} is already running" + fn_scriptlog "${servername} is already running" sleep 1 echo -en "\n" - fn_scriptlog "${servername} is already running" exit fi # Create lock file -date > ${lockselfname} +date > ${rootdir}/${lockselfname} cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}" tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'" @@ -783,7 +798,7 @@ fn_getquery(){ while true; do read -p "Do you want to install GameServerQuery? [y/N]" yn case $yn in - [Yy]* ) wget -nv "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; + [Yy]* ) wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py;break;; [Nn]* ) echo -e "Not installing GameServerQuery.";break;; * ) echo "Please answer yes or no.";; esac