Browse Source
If the administrator stops the server using the stop command the monitor will disable itself preventing the server from starting back up on its ownpull/103/head
19 changed files with 249 additions and 47 deletions
@ -3,7 +3,7 @@ |
|||||
# Server Management Script |
# Server Management Script |
||||
# Author: Daniel Gibbs |
# Author: Daniel Gibbs |
||||
# Website: http://danielgibbs.co.uk |
# Website: http://danielgibbs.co.uk |
||||
# Version: 050214 |
# Version: 220614 |
||||
|
|
||||
#### Variables #### |
#### Variables #### |
||||
|
|
||||
@ -15,6 +15,7 @@ email="[email protected]" |
|||||
# Directorys |
# Directorys |
||||
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" |
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" |
||||
selfname="$0" |
selfname="$0" |
||||
|
lockselfname=$(echo "${selfname}.lock"|sed 's/^\(.\{1\}\).\(.*\)/\1\2/') |
||||
filesdir="${rootdir}/serverfiles" |
filesdir="${rootdir}/serverfiles" |
||||
systemdir="${filesdir}/System" |
systemdir="${filesdir}/System" |
||||
executabledir="${systemdir}" |
executabledir="${systemdir}" |
||||
@ -445,6 +446,12 @@ fn_monitorserver(){ |
|||||
fn_rootcheck |
fn_rootcheck |
||||
fn_syscheck |
fn_syscheck |
||||
fn_autoip |
fn_autoip |
||||
|
if [ ! -f ${lockselfname} ]; then |
||||
|
fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled" |
||||
|
sleep 1 |
||||
|
echo -en "\n" |
||||
|
exit |
||||
|
fi |
||||
fn_printdots "Monitoring ${servicename}: ${servername}" |
fn_printdots "Monitoring ${servicename}: ${servername}" |
||||
sleep 1 |
sleep 1 |
||||
fn_scriptlog "Monitoring ${servername}" |
fn_scriptlog "Monitoring ${servername}" |
||||
@ -506,6 +513,8 @@ else |
|||||
fn_printok "Stopping ${servicename}: ${servername}" |
fn_printok "Stopping ${servicename}: ${servername}" |
||||
fn_scriptlog "Stopped ${servername}" |
fn_scriptlog "Stopped ${servername}" |
||||
fi |
fi |
||||
|
# Remove lock file |
||||
|
rm -f ${lockselfname} |
||||
sleep 1 |
sleep 1 |
||||
echo -en "\n" |
echo -en "\n" |
||||
} |
} |
||||
@ -531,6 +540,8 @@ if [ ${tmuxwc} -eq 1 ]; then |
|||||
fn_scriptlog "${servername} is already running" |
fn_scriptlog "${servername} is already running" |
||||
exit |
exit |
||||
fi |
fi |
||||
|
# Create lock file |
||||
|
lockfile -r 0 ${lockselfname} |
||||
cd "${executabledir}" |
cd "${executabledir}" |
||||
tmux new-session -d -s ${servicename} "${executable} ${parms}|tee -a '${consolelog}'" |
tmux new-session -d -s ${servicename} "${executable} ${parms}|tee -a '${consolelog}'" |
||||
sleep 1 |
sleep 1 |
||||
|
Loading…
Reference in new issue