@ -3,7 +3,7 @@
# Server Management Script
# Server Management Script
# Author: Daniel Gibbs
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Website: http://danielgibbs.co.uk
# Version: 24 0114
# Version: 0102 14
#### Variables ####
#### Variables ####
@ -37,7 +37,7 @@ ip="0.0.0.0"
# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
# https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
# https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
fn_parms(){
fn_parms(){
parms="-game csgo -usercon +map ${defaultmap} +mapgroup ${mapgroup} +game_mode ${gamemode} +game_type ${gametype} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -maxplayers ${maxplayers}"
parms="-game csgo -usercon +map ${defaultmap} +mapgroup ${mapgroup} +game_mode ${gamemode} +game_type ${gametype} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -maxplayers ${maxplayers} +servercfgfile ${servercfg} "
}
}
#### Advanced Variables ####
#### Advanced Variables ####
@ -57,14 +57,16 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/csgo"
systemdir="${filesdir}/csgo"
executabledir="${filesdir}"
executabledir="${filesdir}"
executable="./srcds_run"
executable="./srcds_run"
servercfg="${systemdir}/cfg/${servicename}.cfg"
servercfgdir="${systemdir}/cfg"
defaultcfg="${systemdir}/cfg/server.cfg"
servercfg="${servicename}.cfg"
servercfgfullpath="${servercfgdir}/${servercfg}"
defaultcfg="${servercfgdir}/server.cfg"
backupdir="backups"
backupdir="backups"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"
# Server Details
# Server Details
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath }"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath }"|sed 's/rcon_password //g'|sed 's/"//g')
# Logging
# Logging
logdays="7"
logdays="7"
@ -368,6 +370,13 @@ if [ -f gsquery.py ]; then
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
sleep 1
sleep 1
echo -en "\n"
echo -en "\n"
if [[ -z "${secondquery}" ]]; then
echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Waiting 30 seconds to re-query"
fn_scriptlog "Waiting 30 seconds to re-query"
sleep 30
secondquery=1
fn_serverquery
fi
if [ "${emailnotification}" = "on" ]; then
if [ "${emailnotification}" = "on" ]; then
subject="${servicename} Monitor - Starting ${servername}"
subject="${servicename} Monitor - Starting ${servername}"
failurereason="Failed to query ${servicename}: ${serverquery}"
failurereason="Failed to query ${servicename}: ${serverquery}"
@ -529,8 +538,8 @@ echo -en "\n"
fn_details(){
fn_details(){
fn_autoip
fn_autoip
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath }"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath }"|sed 's/rcon_password //g'|sed 's/"//g')
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
echo ""
echo ""
echo "${gamename} Server Details"
echo "${gamename} Server Details"
@ -538,7 +547,7 @@ echo "============================"
echo "Server name: ${servername}"
echo "Server name: ${servername}"
echo "Server IP: ${ip}:${port}"
echo "Server IP: ${ip}:${port}"
echo "RCON password: ${rcon}"
echo "RCON password: ${rcon}"
echo "Config file: ${servercfg}"
echo "Config file: ${servercfgfullpath }"
echo ""
echo ""
echo "${servername} Ports"
echo "${servername} Ports"
echo "============================"
echo "============================"
@ -701,7 +710,7 @@ echo "================================="
echo "exec ${servicename}.cfg" > "${defaultcfg}"
echo "exec ${servicename}.cfg" > "${defaultcfg}"
sleep 1
sleep 1
echo "Creating ${servicename}.cfg config file."
echo "Creating ${servicename}.cfg config file."
touch "${servercfg}"
touch "${servercfgfullpath }"
{
{
echo -e "// server name"
echo -e "// server name"
echo -e "hostname \"${servername}\""
echo -e "hostname \"${servername}\""
@ -718,7 +727,7 @@ echo "================================="
echo -e "sv_logecho 1"
echo -e "sv_logecho 1"
echo -e "sv_logfile 1"
echo -e "sv_logfile 1"
echo -e "sv_log_onefile 0"
echo -e "sv_log_onefile 0"
}|tee "${servercfg}" > /dev/null 2>&1
}|tee "${servercfgfullpath }" > /dev/null 2>&1
sleep 1
sleep 1
echo ""
echo ""
fn_header
fn_header