| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #!/bin/bash
- # LGSM command_monitor.sh function
- # Author: Daniel Gibbs
- # Website: https://gameservermanagers.com
- # Description: Monitors server by checking for running processes.
- # then passes to monitor_gsquery.sh.
- local commandname="MONITOR"
- local commandaction="Monitor"
- local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
- fn_monitor_check_lockfile(){
- # Monitor does not run it lockfile is not found
- if [ ! -f "${rootdir}/${lockselfname}" ]; then
- fn_print_error_nl "Disabled: No lock file found"
- fn_script_log_error "Disabled: No lock file found"
- echo " * To enable monitor run ./${selfname} start"
- core_exit.sh
- fi
- }
- fn_monitor_check_update(){
- # Monitor will not check if update is running.
- if [ "$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)" != "0" ]; then
- fn_print_error_nl "SteamCMD is currently checking for updates"
- fn_script_log_error "SteamCMD is currently checking for updates"
- sleep 1
- core_exit.sh
- fi
- }
- fn_monitor_msg_checking(){
- fn_print_dots "Checking session: "
- fn_print_checking_eol
- fn_script_log_info "Checking session: CHECKING"
- sleep 1
- }
- fn_monitor_teamspeak3(){
- if [ "${status}" != "0" ]; then
- fn_print_ok "Checking session: "
- fn_print_ok_eol_nl
- fn_script_log_pass "Checking session: OK"
- else
- fn_print_error "Checking session: ${ts3error}: "
- fn_print_fail_eol_nl
- fn_script_log_error "Checking session: ${ts3error}: FAIL"
- failurereason="${ts3error}"
- alert="restart"
- alert.sh
- fn_script_log_info "Monitor is starting ${servername}"
- sleep 1
- command_restart.sh
- fi
- }
- fn_monitor_tmux(){
- # checks that tmux session is running
- if [ "${status}" != "0" ]; then
- fn_print_ok "Checking session: "
- fn_print_ok_eol_nl
- fn_script_log_pass "Checking session: OK"
- # runs gsquery check on game with specific engines.
- local allowed_engines_array=( avalanche goldsource realvirtuality source spark unity3d unreal unreal2 )
- for allowed_engine in "${allowed_engines_array[@]}"
- do
- if [ "${allowed_engine}" == "${engine}" ]; then
- monitor_gsquery.sh
- fi
- done
- else
- fn_print_error "Checking session: "
- fn_print_fail_eol_nl
- fn_script_log_error "Checking session: FAIL"
- alert="restart"
- alert.sh
- fn_script_log_info "Monitor is starting ${servername}"
- sleep 1
- command_restart.sh
- fi
- }
- fn_print_dots "${servername}"
- sleep 1
- check.sh
- logs.sh
- info_config.sh
- fn_monitor_check_lockfile
- fn_monitor_check_update
- fn_monitor_msg_checking
- if [ "${gamename}" == "Teamspeak 3" ]; then
- fn_monitor_teamspeak3
- else
- fn_monitor_tmux
- fi
- core_exit.sh
|