diff --git a/ARKSurvivalEvolved/arkserver b/ARKSurvivalEvolved/arkserver index 30f34b568..719cbe50a 100644 --- a/ARKSurvivalEvolved/arkserver +++ b/ARKSurvivalEvolved/arkserver @@ -22,7 +22,7 @@ email="email@example.com" # Pushbullet # https://www.pushbullet.com/#settings -pushbulletalert"off" +pushbulletalert="off" pushbullettoken="accesstoken" # Steam login diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 232bf9f1e..d7b9ddd33 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -155,9 +155,48 @@ fn_stop_graceful_select(){ fn_stop_graceful_goldsource else 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_print_dots "${servername}" fn_scriptlog "${servername}" @@ -169,7 +208,7 @@ fn_stop_teamspeak3(){ fn_scriptlog "Stopped ${servername}" } - fn_stop_tmux(){ +fn_stop_tmux(){ fn_print_dots "${servername}" fn_scriptlog "tmux kill-session: ${servername}" sleep 1 @@ -180,6 +219,12 @@ fn_stop_teamspeak3(){ if [ "${pid}" == "0" ]; then # Remove lock file 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_scriptlog "Stopped ${servername}" else @@ -197,7 +242,7 @@ fn_stop_pre_check(){ fn_scriptlog "${servername} is already stopped" else fn_stop_teamspeak3 - fi + fi else pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") if [ "${pid}" == "0" ]; then @@ -214,4 +259,4 @@ info_config.sh fn_print_dots "${servername}" fn_scriptlog "${servername}" sleep 1 -fn_stop_pre_check \ No newline at end of file +fn_stop_pre_check diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index 562bed461..f9bee5039 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -148,7 +148,7 @@ fn_fetch_function command_fastdl.sh(){ functionfile="${FUNCNAME}" -fn_runfunction +fn_fetch_function } command_ts3_server_pass.sh(){