Browse Source

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
pull/175/head
Daniel Gibbs 11 years ago
parent
commit
3e8b7b9982
  1. 61
      Arma3/arma3server
  2. 58
      BladeSymphony/bsserver
  3. 71
      CounterStrike/csserver
  4. 71
      CounterStrikeConditionZero/csczserver
  5. 71
      CounterStrikeGlobalOffensive/csgoserver
  6. 71
      CounterStrikeSource/cssserver
  7. 71
      DayOfDefeat/dodserver
  8. 71
      DayOfDefeatSource/dodsserver
  9. 58
      FistfulOfFrags/fofserver
  10. 72
      GarrysMod/gmodserver
  11. 71
      HalfLife2Deathmatch/hl2dmserver
  12. 71
      HalfLifeDeathmatchClassic/hldmcserver
  13. 58
      Insurgency/insserver
  14. 21
      KillingFloor/kfserver
  15. 75
      Left4Dead/l4dserver
  16. 70
      Left4Dead2/l4d2server
  17. 58
      NaturalSelection2/ns2server
  18. 60
      NoMoreRoomInHell/nmrihserver
  19. 75
      RedOrchestra/roserver
  20. 71
      TeamFortress2/tf2server
  21. 71
      TeamFortressClassic/tfcserver
  22. 19
      UnrealTournament2004/ut2k4server
  23. 67
      UnrealTournament99/ut99server

61
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/\<hostname\>//g'| tr -d '=\"; ')
@ -162,26 +161,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +483,7 @@ 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"
@ -481,18 +492,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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}'"

58
BladeSymphony/bsserver

@ -164,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -483,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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}'"

71
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')
@ -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"
@ -164,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -483,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -164,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -483,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -182,26 +181,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +503,7 @@ 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"
@ -501,18 +512,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -165,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -484,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -164,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -483,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -165,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -484,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

58
FistfulOfFrags/fofserver

@ -164,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -483,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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}'"

72
GarrysMod/gmodserver

@ -169,26 +169,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +491,7 @@ 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"
@ -488,18 +500,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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,7 +729,7 @@ 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"
@ -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

71
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')
@ -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"
@ -165,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -484,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -164,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -483,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

58
Insurgency/insserver

@ -164,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -483,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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}'"

21
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

75
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')
@ -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"
@ -166,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -485,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

70
Left4Dead2/l4d2server

@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 170914
# Version: 200914
#### Variables ####
@ -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"
@ -164,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -483,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

58
NaturalSelection2/ns2server

@ -161,26 +161,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +483,7 @@ 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"
@ -480,18 +492,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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}'"

60
NoMoreRoomInHell/nmrihserver

@ -164,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -483,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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)

75
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 #####
@ -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"
@ -151,26 +154,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +476,7 @@ 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"
@ -470,18 +485,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -165,26 +164,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +486,7 @@ 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"
@ -484,18 +495,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

71
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')
@ -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"
@ -164,26 +163,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +485,7 @@ 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"
@ -483,18 +494,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

19
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
@ -946,5 +947,3 @@ case "$1" in
exit 1;;
esac
exit
esac
exit

67
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 protected]"
# Directories
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
selfname="$0"
lockselfname=$(echo ".${servicename}.lock")
filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/System"
executabledir="${systemdir}"
@ -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"
@ -143,26 +144,38 @@ if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
fn_printdots "Starting log cleaner"
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"
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
sleep 1
fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
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,6 +466,7 @@ 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"
@ -462,18 +475,17 @@ if [ ! -f ${lockselfname} ]; then
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"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_scriptlog "Checking session: OK"
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"
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
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

Loading…
Cancel
Save