From 6bb595cc33d053e5f25966a91d57c68b10d384fb Mon Sep 17 00:00:00 2001 From: xFaNaTiix Date: Sat, 23 May 2015 17:06:48 +0200 Subject: [PATCH 1/2] Fixed monitoring for cron job --- functions/fn_monitor | 4 ++-- functions/fn_monitor_query | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/fn_monitor b/functions/fn_monitor index 9798a6225..19c094481 100644 --- a/functions/fn_monitor +++ b/functions/fn_monitor @@ -16,7 +16,7 @@ fn_logs fn_printdots "${servername}" fn_scriptlog "${servername}" sleep 1 -if [ ! -f "${lockselfname}" ]; then +if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_printinfo "Disabled: No lock file found" fn_scriptlog "Disabled: No lock file found" sleep 1 @@ -61,7 +61,7 @@ fn_details_config fn_printdots "${servername}" fn_scriptlog "${servername}" sleep 1 -if [ ! -f "${lockselfname}" ]; then +if [ ! -f "${rootdir}/${lockselfname}" ]; then fn_printinfo "Disabled: No lock file found" fn_scriptlog "Disabled: No lock file found" sleep 1 diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index f9a888bff..6c03dad44 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -8,7 +8,7 @@ # Detects if the server has frozen. local modulename="Monitor" -if [ -f gsquery.py ]; then +if [ -f "${rootdir}/gsquery.py" ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then gameport=$(grep Port= "${servercfgfullpath}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|tr -d '\r'|tr -cd [:digit:]) port=$((${gameport} + 1)) @@ -27,7 +27,7 @@ if [ -f gsquery.py ]; then fn_printdots "Querying port: ${ip}:${port} : QUERYING" fn_scriptlog "Querying port: ${ip}:${port} : QUERYING" sleep 1 - serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) + serverquery=$(${rootdir}/gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then fn_printfail "Querying port: ${ip}:${port} : ${serverquery}" @@ -64,21 +64,21 @@ if [ -f gsquery.py ]; then echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then - fn_printfail "Querying port: ${ip}:${port} : ERROR: ./gsquery.py: Permission denied" - fn_scriptlog "Querying port: ${ip}:${port} : ERROR: ./gsquery.py: Permission denied" + fn_printfail "Querying port: ${ip}:${port} : ERROR: ${rootdir}/gsquery.py: Permission denied" + fn_scriptlog "Querying port: ${ip}:${port} : ERROR: ${rootdir}/gsquery.py: Permission denied" sleep 1 echo -en "\n" echo "Attempting to resolve automatically" - chmod +x -v gsquery.py + chmod +x -v "${rootdir}/gsquery.py" exitcode=$? if [ "${exitcode}" == "0" ]; then fn_monitor_query else fn_printfailure "Unable to resolve automatically. Please manually fix permissions.\n" - owner=$(ls -al gsquery.py|awk '{ print $3 }') + owner=$(ls -al ${rootdir}/gsquery.py|awk '{ print $3 }') echo "As user ${owner} or root run the following command." whoami=$(whoami) - echo -en "\nchown ${whoami}:${whoami} gsquery.py\n\n" + echo -en "\nchown ${whoami}:${whoami} ${rootdir}/gsquery.py\n\n" exit fi else @@ -86,7 +86,7 @@ if [ -f gsquery.py ]; then fn_scriptlog "Querying port: ${ip}:${port} : UNKNOWN ERROR" sleep 1 echo -en "\n" - ./gsquery.py -a ${ip} -p ${port} -e ${engine} + ${rootdir}/gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi fi \ No newline at end of file From 91aa91bed6040c35de492c42b3eb1c841c37a81f Mon Sep 17 00:00:00 2001 From: Marvin Date: Sat, 23 May 2015 17:36:32 +0200 Subject: [PATCH 2/2] Added error message if gsquery.py doesn't exists --- functions/fn_monitor_query | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index 6c03dad44..329d49765 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -89,4 +89,7 @@ if [ -f "${rootdir}/gsquery.py" ]; then ${rootdir}/gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi -fi \ No newline at end of file +else + fn_printfail "Could not find ${rootdir}/gsquery.py" + fn_scriptlog "Could not find ${rootdir}/gsquery.py" +fi