|
@@ -156,9 +156,48 @@ 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(){
|
|
|
|
|
+ MAXPIDITER=15 # The maximum number of times to check if the ark pid has closed gracefully.
|
|
|
|
|
+ info_config.sh
|
|
|
|
|
+ if [ -z $queryport ] ; then
|
|
|
|
|
+ fn_print_warn "no queryport found using info_config.sh"
|
|
|
|
|
+ userconfigfile="${filesdir}"
|
|
|
|
|
+ userconfigfile+="/ShooterGame/Saved/Config/LinuxServer/GameUserSettings.ini"
|
|
|
|
|
+ queryport=$(grep ^QueryPort= ${userconfigfile} | cut -d= -f2 | sed "s/[^[:digit:].*].*//g")
|
|
|
|
|
+ fi
|
|
|
|
|
+ if [ -z $queryport ] ; then
|
|
|
|
|
+ fn_print_warn "no queryport found in the GameUsersettings.ini file"
|
|
|
|
|
+ return
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ if [[ ${#queryport} -gt 0 ]] ; then
|
|
|
|
|
+ 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
|
|
|
|
|
+ fi
|
|
|
|
|
+ fi # end if for port check
|
|
|
|
|
+} # 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}"
|
|
@@ -187,6 +226,12 @@ fn_stop_tmux(){
|
|
|
if [ "${status}" == "0" ]; then
|
|
if [ "${status}" == "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.
|
|
|
|
|
+ # 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
|
|
@@ -204,7 +249,7 @@ 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
|
|
check_status.sh
|
|
|
if [ "${status}" == "0" ]; then
|
|
if [ "${status}" == "0" ]; then
|
|
@@ -221,4 +266,4 @@ info_config.sh
|
|
|
fn_print_dots "${servername}"
|
|
fn_print_dots "${servername}"
|
|
|
fn_scriptlog "${servername}"
|
|
fn_scriptlog "${servername}"
|
|
|
sleep 1
|
|
sleep 1
|
|
|
-fn_stop_pre_check
|
|
|
|
|
|
|
+fn_stop_pre_check
|