Browse Source

Added adjustments to script messages

* tmux will be killed just after sdtd telnet finishes
pull/351/head
Daniel Gibbs 10 years ago
parent
commit
9e29fa5a9f
  1. 71
      functions/fn_stop

71
functions/fn_stop

@ -39,40 +39,47 @@ sleep 1
fn_check_tmux fn_check_tmux
if [ "${gamename}" == "7 Days To Die" ] ; then if [ "${gamename}" == "7 Days To Die" ] ; then
# if game is 7 Days To Die, we need special, graceful shutdown via telnet connection. # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection.
# Set below variable to be called for expect to operate correctly.. # Set below variable to be called for expect to operate correctly..
fn_printdots "Attempting graceful shutdown via telnet"
sdtdshutdown=$( expect -c ' fn_scriptlog "Attempting graceful shutdown via telnet"
proc abort {} { sleep 1
puts "Timeout or EOF\n" telnetip=127.0.0.1
exit 1 sdtdshutdown=$( expect -c '
} proc abort {} {
spawn telnet '"${telnetip}"' '"${telnetport}"' puts "Timeout or EOF\n"
expect { exit 1
"password:" { send "'"${telnetpass}"'\r" } }
default abort spawn telnet '"${telnetip}"' '"${telnetport}"'
} expect {
expect { "password:" { send "'"${telnetpass}"'\r" }
"session." { send "shutdown\r" } default abort
default abort }
} expect {
expect { eof } "session." { send "shutdown\r" }
puts "Completed.\n" default abort
') }
echo -en "\n ${sdtdshutdown}" expect { eof }
fn_printok "${servername}" puts "Completed.\n"
fn_scriptlog "Performmed graceful shutdown of ${servername}" ')
echo -en "\n ${sdtdshutdown}"
fn_printok "Attempting graceful shutdown via telnet"
fn_scriptlog "Attempting graceful shutdown succeeded"
sleep 1
fn_printdots "${servername}"
fn_scriptlog "${servername}"
sleep 1
fi
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
if [ "${pid}" == "0" ]; then
fn_printfail "${servername} is already stopped"
fn_scriptlog "${servername} is already stopped"
else else
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:") tmux kill-session -t ${servicename}
if [ "${pid}" == "0" ]; then fn_printok "${servername}"
fn_printfail "${servername} is already stopped" fn_scriptlog "Stopped ${servername}"
fn_scriptlog "${servername} is already stopped"
else
tmux kill-session -t ${servicename}
fn_printok "${servername}"
fn_scriptlog "Stopped ${servername}"
fi
fi fi
}
if [ "${gamename}" == "Teamspeak 3" ]; then if [ "${gamename}" == "Teamspeak 3" ]; then
fn_stop_teamspeak3 fn_stop_teamspeak3

Loading…
Cancel
Save