| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/bin/bash
- # LGSM fn_monitorserver function
- # Author: Daniel Gibbs
- # Website: http://danielgibbs.co.uk
- # Version: 010115
- # Description: Monitors server by checking for running proccesses
- # then passes to fn_serverquery.
- local modulename="Monitor"
- fn_rootcheck
- fn_syscheck
- fn_autoip
- fn_printdots "${servername}"
- fn_scriptlog "${servername}"
- sleep 1
- if [ ! -f "${lockselfname}" ]; then
- fn_printinfo "Disabled: No lock file found"
- fn_scriptlog "Disabled: No lock file found"
- sleep 1
- echo -en "\n"
- echo "To enable monitor run ${selfname} start"
- exit
- fi
- updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)
- if [ "${updatecheck}" = "0" ]; then
- fn_printdots "Checking session: CHECKING"
- 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 "Checking session: OK"
- fn_scriptlog "Checking session: OK"
- sleep 1
- echo -en "\n"
- fn_serverquery
- exit
- else
- fn_printfail "Checking session: FAIL"
- fn_scriptlog "Checking session: FAIL"
- sleep 1
- echo -en "\n"
- if [ "${emailnotification}" = "on" ]; then
- subject="${servicename} Monitor - Starting ${servername}"
- failurereason="${servicename} process not running"
- actiontaken="${servicename} has been restarted"
- fn_emailnotification
- fi
- fn_scriptlog "Monitor is starting ${servername}"
- fn_startserver
- fi
- else
- fn_printinfonl "SteamCMD is currently checking for updates"
- fn_scriptlog "SteamCMD is currently checking for updates"
- sleep 1
- fn_printinfonl "When update is complete ${servicename} will start"
- fn_scriptlog "When update is complete ${servicename} will start"
- sleep 1
- fi
|