|
@@ -17,8 +17,8 @@ fn_stop_graceful_source(){
|
|
|
tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
|
|
tmux send -t "${servicename}" quit ENTER > /dev/null 2>&1
|
|
|
# waits up to 30 seconds giving the server time to shutdown gracefuly
|
|
# waits up to 30 seconds giving the server time to shutdown gracefuly
|
|
|
for seconds in {1..30}; do
|
|
for seconds in {1..30}; do
|
|
|
- check_status.sh
|
|
|
|
|
- if [ "${status}" == "0" ]; then
|
|
|
|
|
|
|
+ pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
|
|
|
|
|
+ if [ "${pid}" == "0" ]; then
|
|
|
fn_print_ok "Graceful: rcon quit: ${seconds}: "
|
|
fn_print_ok "Graceful: rcon quit: ${seconds}: "
|
|
|
fn_print_ok_eol_nl
|
|
fn_print_ok_eol_nl
|
|
|
fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds"
|
|
fn_scriptlog "Graceful: rcon quit: OK: ${seconds} seconds"
|
|
@@ -27,8 +27,7 @@ fn_stop_graceful_source(){
|
|
|
sleep 1
|
|
sleep 1
|
|
|
fn_print_dots "Graceful: rcon quit: ${seconds}"
|
|
fn_print_dots "Graceful: rcon quit: ${seconds}"
|
|
|
done
|
|
done
|
|
|
- check_status.sh
|
|
|
|
|
- if [ "${status}" != "0" ]; then
|
|
|
|
|
|
|
+ if [ "${pid}" != "0" ]; then
|
|
|
fn_print_fail "Graceful: rcon quit: "
|
|
fn_print_fail "Graceful: rcon quit: "
|
|
|
fn_print_fail_eol_nl
|
|
fn_print_fail_eol_nl
|
|
|
fn_scriptlog "Graceful: rcon quit: FAIL"
|
|
fn_scriptlog "Graceful: rcon quit: FAIL"
|
|
@@ -156,10 +155,11 @@ fn_stop_graceful_select(){
|
|
|
fn_stop_graceful_goldsource
|
|
fn_stop_graceful_goldsource
|
|
|
else
|
|
else
|
|
|
fn_stop_tmux
|
|
fn_stop_tmux
|
|
|
- fi
|
|
|
|
|
|
|
+ fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fn_stop_ark(){
|
|
fn_stop_ark(){
|
|
|
|
|
+ MAXPIDITER=15 # The maximum number of times to check if the ark pid has closed gracefully.
|
|
|
info_config.sh
|
|
info_config.sh
|
|
|
if [ -z $queryport ] ; then
|
|
if [ -z $queryport ] ; then
|
|
|
fn_print_warn "no queryport found using info_config.sh"
|
|
fn_print_warn "no queryport found using info_config.sh"
|
|
@@ -173,47 +173,40 @@ fn_stop_ark(){
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${#queryport} -gt 0 ]] ; then
|
|
if [[ ${#queryport} -gt 0 ]] ; then
|
|
|
- for ((pidcheck=0;pidcheck<20;pidcheck++)) ; do
|
|
|
|
|
- pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
|
|
|
|
|
- grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
|
|
|
|
|
- rev | cut -d\/ -f1)
|
|
|
|
|
- #
|
|
|
|
|
- # check for a valid pid
|
|
|
|
|
- let pid+=0 # turns an empty string into a valid number, '0',
|
|
|
|
|
- # and a valid numeric pid remains unchanged.
|
|
|
|
|
- if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then
|
|
|
|
|
- fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck"
|
|
|
|
|
- sleep 1
|
|
|
|
|
- else
|
|
|
|
|
- break // Our job is done here
|
|
|
|
|
- fi # end if for pid range check
|
|
|
|
|
- done
|
|
|
|
|
- if [[ ${pidcheck} -eq 20 ]] ; then
|
|
|
|
|
- # The process doesn't want to close after 20 seconds.
|
|
|
|
|
- # kill it hard.
|
|
|
|
|
- fn_print_warn "Terminating reluctant Ark process: $pid"
|
|
|
|
|
|
|
+ for (( pidcheck=0 ; pidcheck < ${MADPIDITER} ; pidcheck++ )) ; do
|
|
|
|
|
+ pid=$(netstat -nap 2>/dev/null | grep ^udp[[:space:]] |\
|
|
|
|
|
+ grep :${queryport}[[:space:]] | rev | awk '{print $1}' |\
|
|
|
|
|
+ rev | cut -d\/ -f1)
|
|
|
|
|
+ #
|
|
|
|
|
+ # check for a valid pid
|
|
|
|
|
+ let pid+=0 # turns an empty string into a valid number, '0',
|
|
|
|
|
+ # and a valid numeric pid remains unchanged.
|
|
|
|
|
+ if [[ $pid -gt 1 && $pid -le $(cat /proc/sys/kernel/pid_max) ]] ; then
|
|
|
|
|
+ fn_print_dots "Process still bound. Awaiting graceful exit: $pidcheck"
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+ else
|
|
|
|
|
+ break # Our job is done here
|
|
|
|
|
+ fi # end if for pid range check
|
|
|
|
|
+ done
|
|
|
|
|
+ if [[ ${pidcheck} -eq ${MAXPIDITER} ]] ; then
|
|
|
|
|
+ # The process doesn't want to close after 20 seconds.
|
|
|
|
|
+ # kill it hard.
|
|
|
|
|
+ fn_print_warn "Terminating reluctant Ark process: $pid"
|
|
|
kill -9 $pid
|
|
kill -9 $pid
|
|
|
- fi
|
|
|
|
|
- fi # end if for port check
|
|
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi # end if for port check
|
|
|
} # end of fn_stop_ark
|
|
} # end of fn_stop_ark
|
|
|
|
|
|
|
|
-
|
|
|
|
|
fn_stop_teamspeak3(){
|
|
fn_stop_teamspeak3(){
|
|
|
fn_print_dots "${servername}"
|
|
fn_print_dots "${servername}"
|
|
|
fn_scriptlog "${servername}"
|
|
fn_scriptlog "${servername}"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1
|
|
${filesdir}/ts3server_startscript.sh stop > /dev/null 2>&1
|
|
|
- check_status.sh
|
|
|
|
|
- if [ "${status}" == "0" ]; then
|
|
|
|
|
- # Remove lock file
|
|
|
|
|
- rm -f "${rootdir}/${lockselfname}"
|
|
|
|
|
- fn_print_ok_nl "${servername}"
|
|
|
|
|
- fn_scriptlog "Stopped ${servername}"
|
|
|
|
|
- else
|
|
|
|
|
- fn_print_fail_nl "Unable to stop${servername}"
|
|
|
|
|
- fn_scriptlog "Unable to stop${servername}"
|
|
|
|
|
- fi
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ # Remove lock file
|
|
|
|
|
+ rm -f "${rootdir}/${lockselfname}"
|
|
|
|
|
+ fn_print_ok_nl "${servername}"
|
|
|
|
|
+ fn_scriptlog "Stopped ${servername}"
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
fn_stop_tmux(){
|
|
fn_stop_tmux(){
|
|
|
fn_print_dots "${servername}"
|
|
fn_print_dots "${servername}"
|
|
@@ -222,16 +215,16 @@ fn_stop_tmux(){
|
|
|
# Kill tmux session
|
|
# Kill tmux session
|
|
|
tmux kill-session -t "${servicename}" > /dev/null 2>&1
|
|
tmux kill-session -t "${servicename}" > /dev/null 2>&1
|
|
|
sleep 0.5
|
|
sleep 0.5
|
|
|
- check_status.sh
|
|
|
|
|
- if [ "${status}" == "0" ]; then
|
|
|
|
|
|
|
+ pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
|
|
|
|
|
+ if [ "${pid}" == "0" ]; then
|
|
|
# Remove lock file
|
|
# Remove lock file
|
|
|
rm -f "${rootdir}/${lockselfname}"
|
|
rm -f "${rootdir}/${lockselfname}"
|
|
|
# ARK doesn't clean up immediately after tmux is killed.
|
|
# ARK doesn't clean up immediately after tmux is killed.
|
|
|
- # Make certain the ports are cleared before continuing.
|
|
|
|
|
- if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
|
|
|
|
|
- fn_stop_ark
|
|
|
|
|
- echo -en "\n"
|
|
|
|
|
- fi
|
|
|
|
|
|
|
+ # Make certain the ports are cleared before continuing.
|
|
|
|
|
+ if [ "${gamename}" == "ARK: Survivial Evolved" ]; then
|
|
|
|
|
+ fn_stop_ark
|
|
|
|
|
+ echo -en "\n"
|
|
|
|
|
+ fi
|
|
|
fn_print_ok_nl "${servername}"
|
|
fn_print_ok_nl "${servername}"
|
|
|
fn_scriptlog "Stopped ${servername}"
|
|
fn_scriptlog "Stopped ${servername}"
|
|
|
else
|
|
else
|
|
@@ -249,10 +242,10 @@ fn_stop_pre_check(){
|
|
|
fn_scriptlog "${servername} is already stopped"
|
|
fn_scriptlog "${servername} is already stopped"
|
|
|
else
|
|
else
|
|
|
fn_stop_teamspeak3
|
|
fn_stop_teamspeak3
|
|
|
- fi
|
|
|
|
|
|
|
+ fi
|
|
|
else
|
|
else
|
|
|
- check_status.sh
|
|
|
|
|
- if [ "${status}" == "0" ]; then
|
|
|
|
|
|
|
+ pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
|
|
|
|
|
+ if [ "${pid}" == "0" ]; then
|
|
|
fn_print_ok_nl "${servername} is already stopped"
|
|
fn_print_ok_nl "${servername} is already stopped"
|
|
|
fn_scriptlog "${servername} is already stopped"
|
|
fn_scriptlog "${servername} is already stopped"
|
|
|
else
|
|
else
|