Skip to content

Commit

Permalink
added 2nd query on gsquery to prevent restart
Browse files Browse the repository at this point in the history
* added 2nd query after delay on gsquery to prevent the script from
restarting during map change
* added +servercfgfile to start parameters to make multiple servers
easier. I will add more documentation on this soon.
  • Loading branch information
dgibbs64 committed Jan 31, 2014
1 parent c32d345 commit f3dd4ef
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 151 deletions.
31 changes: 20 additions & 11 deletions CounterStrike/csserver
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 240114
# Version: 010214

#### Variables ####

Expand All @@ -24,7 +24,7 @@ maxplayers="16"
ip="0.0.0.0"
# https://developer.valvesoftware.com/wiki/Command_Line_Options#Command-line_parameters_2
fn_parms(){
parms="-game cstrike +map ${defaultmap} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} -maxplayers ${maxplayers}"
parms="-game cstrike +map ${defaultmap} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} -maxplayers ${maxplayers} +servercfgfile ${servercfg}"
}

#### Advanced Variables ####
Expand All @@ -44,14 +44,16 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/cstrike"
executabledir="${filesdir}"
executable="./hlds_run"
servercfg="${systemdir}/${servicename}.cfg"
defaultcfg="${systemdir}/server.cfg"
servercfgdir="${systemdir}"
servercfg="${servicename}.cfg"
servercfgfullpath="${servercfgdir}/${servercfg}"
defaultcfg="${servercfgdir}/server.cfg"
backupdir="backups"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"

# Server Details
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')

# Logging
logdays="7"
Expand Down Expand Up @@ -355,6 +357,13 @@ if [ -f gsquery.py ]; then
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
sleep 1
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
subject="${servicename} Monitor - Starting ${servername}"
failurereason="Failed to query ${servicename}: ${serverquery}"
Expand Down Expand Up @@ -516,16 +525,16 @@ echo -en "\n"

fn_details(){
fn_autoip
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //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)
echo ""
echo "${gamename} Server Details"
echo "============================"
echo "Server name: ${servername}"
echo "Server IP: ${ip}:${port}"
echo "RCON password: ${rcon}"
echo "Config file: ${servercfg}"
echo "Config file: ${servercfgfullpath}"
echo ""
echo "${servername} Ports"
echo "============================"
Expand Down Expand Up @@ -719,7 +728,7 @@ echo "================================="
echo "exec ${servicename}.cfg" > "${defaultcfg}"
sleep 1
echo "Creating ${servicename}.cfg config file."
touch "${servercfg}"
touch "${servercfgfullpath}"
touch "${systemdir}/listip.cfg"
touch "${systemdir}/banned.cfg"
{
Expand Down Expand Up @@ -760,7 +769,7 @@ echo "================================="
echo -e "sv_logecho 1"
echo -e "sv_logfile 1"
echo -e "sv_log_onefile 0"
}|tee "${servercfg}" > /dev/null 2>&1
}|tee "${servercfgfullpath}" > /dev/null 2>&1
sleep 1
echo ""
fn_header
Expand Down
29 changes: 19 additions & 10 deletions CounterStrikeConditionZero/csczserver
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 240114
# Version: 010214

#### Variables ####

Expand Down Expand Up @@ -44,14 +44,16 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/czero"
executabledir="${filesdir}"
executable="./hlds_run"
servercfg="${systemdir}/${servicename}.cfg"
defaultcfg="${systemdir}/server.cfg"
servercfgdir="${systemdir}"
servercfg="${servicename}.cfg"
servercfgfullpath="${servercfgdir}/${servercfg}"
defaultcfg="${servercfgdir}/server.cfg"
backupdir="backups"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"

# Server Details
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')

# Logging
logdays="7"
Expand Down Expand Up @@ -355,6 +357,13 @@ if [ -f gsquery.py ]; then
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
sleep 1
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
subject="${servicename} Monitor - Starting ${servername}"
failurereason="Failed to query ${servicename}: ${serverquery}"
Expand Down Expand Up @@ -516,16 +525,16 @@ echo -en "\n"

fn_details(){
fn_autoip
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //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)
echo ""
echo "${gamename} Server Details"
echo "============================"
echo "Server name: ${servername}"
echo "Server IP: ${ip}:${port}"
echo "RCON password: ${rcon}"
echo "Config file: ${servercfg}"
echo "Config file: ${servercfgfullpath}"
echo ""
echo "${servername} Ports"
echo "============================"
Expand Down Expand Up @@ -729,7 +738,7 @@ echo "================================="
echo "exec ${servicename}.cfg" > "${defaultcfg}"
sleep 1
echo "Creating ${servicename}.cfg config file."
touch "${servercfg}"
touch "${servercfgfullpath}"
touch "${systemdir}/listip.cfg"
touch "${systemdir}/banned.cfg"
{
Expand Down Expand Up @@ -770,7 +779,7 @@ echo "================================="
echo -e "sv_logecho 1"
echo -e "sv_logfile 1"
echo -e "sv_log_onefile 0"
}|tee "${servercfg}" > /dev/null 2>&1
}|tee "${servercfgfullpath}" > /dev/null 2>&1
sleep 1
echo ""
fn_header
Expand Down
31 changes: 20 additions & 11 deletions CounterStrikeGlobalOffensive/csgoserver
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 240114
# Version: 010214

#### Variables ####

Expand Down Expand Up @@ -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/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server
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 ####
Expand All @@ -57,14 +57,16 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/csgo"
executabledir="${filesdir}"
executable="./srcds_run"
servercfg="${systemdir}/cfg/${servicename}.cfg"
defaultcfg="${systemdir}/cfg/server.cfg"
servercfgdir="${systemdir}/cfg"
servercfg="${servicename}.cfg"
servercfgfullpath="${servercfgdir}/${servercfg}"
defaultcfg="${servercfgdir}/server.cfg"
backupdir="backups"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"

# Server Details
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')

# Logging
logdays="7"
Expand Down Expand Up @@ -368,6 +370,13 @@ if [ -f gsquery.py ]; then
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
sleep 1
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
subject="${servicename} Monitor - Starting ${servername}"
failurereason="Failed to query ${servicename}: ${serverquery}"
Expand Down Expand Up @@ -529,16 +538,16 @@ echo -en "\n"

fn_details(){
fn_autoip
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //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)
echo ""
echo "${gamename} Server Details"
echo "============================"
echo "Server name: ${servername}"
echo "Server IP: ${ip}:${port}"
echo "RCON password: ${rcon}"
echo "Config file: ${servercfg}"
echo "Config file: ${servercfgfullpath}"
echo ""
echo "${servername} Ports"
echo "============================"
Expand Down Expand Up @@ -701,7 +710,7 @@ echo "================================="
echo "exec ${servicename}.cfg" > "${defaultcfg}"
sleep 1
echo "Creating ${servicename}.cfg config file."
touch "${servercfg}"
touch "${servercfgfullpath}"
{
echo -e "// server name"
echo -e "hostname \"${servername}\""
Expand All @@ -718,7 +727,7 @@ echo "================================="
echo -e "sv_logecho 1"
echo -e "sv_logfile 1"
echo -e "sv_log_onefile 0"
}|tee "${servercfg}" > /dev/null 2>&1
}|tee "${servercfgfullpath}" > /dev/null 2>&1
sleep 1
echo ""
fn_header
Expand Down
29 changes: 19 additions & 10 deletions CounterStrikeSource/cssserver
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 240114
# Version: 010214

#### Variables ####

Expand Down Expand Up @@ -45,14 +45,16 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/cstrike"
executabledir="${filesdir}"
executable="./srcds_run"
servercfg="${systemdir}/cfg/${servicename}.cfg"
defaultcfg="${systemdir}/cfg/server.cfg"
servercfgdir="${systemdir}/cfg"
servercfg="${servicename}.cfg"
servercfgfullpath="${servercfgdir}/${servercfg}"
defaultcfg="${servercfgdir}/server.cfg"
backupdir="backups"
steamclient="${rootdir}/steamcmd/linux32/steamclient.so"

# Server Details
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')

# Logging
logdays="7"
Expand Down Expand Up @@ -356,6 +358,13 @@ if [ -f gsquery.py ]; then
fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
sleep 1
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
subject="${servicename} Monitor - Starting ${servername}"
failurereason="Failed to query ${servicename}: ${serverquery}"
Expand Down Expand Up @@ -517,16 +526,16 @@ echo -en "\n"

fn_details(){
fn_autoip
servername=$(grep -s hostname "${servercfg}"|sed 's/hostname //g'|sed 's/"//g')
rcon=$(grep -s rcon_password "${servercfg}"|sed 's/rcon_password //g'|sed 's/"//g')
servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //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)
echo ""
echo "${gamename} Server Details"
echo "============================"
echo "Server name: ${servername}"
echo "Server IP: ${ip}:${port}"
echo "RCON password: ${rcon}"
echo "Config file: ${servercfg}"
echo "Config file: ${servercfgfullpath}"
echo ""
echo "${servername} Ports"
echo "============================"
Expand Down Expand Up @@ -689,7 +698,7 @@ echo "================================="
echo "exec ${servicename}.cfg" > "${defaultcfg}"
sleep 1
echo "Creating ${servicename}.cfg config file."
touch "${servercfg}"
touch "${servercfgfullpath}"
{
echo -e "// server name"
echo -e "hostname \"${servername}\""
Expand All @@ -706,7 +715,7 @@ echo "================================="
echo -e "sv_logecho 1"
echo -e "sv_logfile 1"
echo -e "sv_log_onefile 0"
}|tee "${servercfg}" > /dev/null 2>&1
}|tee "${servercfgfullpath}" > /dev/null 2>&1
sleep 1
echo ""
fn_header
Expand Down
Loading

0 comments on commit f3dd4ef

Please sign in to comment.