lgsm local mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
1.8 KiB

#!/bin/bash
# LGSM fn_monitorserver function
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 011214
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}: Monitor disabled: No lock file found"
fn_scriptlog "Monitor 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 "Monitoring ${servicename}: 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 "Monitoring ${servicename}: Checking session: OK"
fn_scriptlog "Checking session: OK"
sleep 1
echo -en "\n"
fn_serverquery
exit
else
fn_printfail "Monitoring ${servicename}: 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 "Monitoring ${servicename}: Detected SteamCMD is checking for updates"
fn_scriptlog "Detected SteamCMD is checking for updates"
sleep 1
fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
fn_scriptlog "When updates complete ${servicename} will start"
sleep 1
fi