From 43a69debd54a9a66aee183164855fd12e7502a68 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 5 Jan 2019 23:39:47 +0000 Subject: [PATCH] fix(stop): sdtd telnet stop will now work with no password set --- lgsm/functions/command_stop.sh | 53 +++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 34c9bf6e5..562a9e12a 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -87,26 +87,39 @@ fn_stop_graceful_goldsource(){ # Attempts graceful of 7 Days To Die using telnet. fn_stop_telnet_sdtd(){ - if [ -z "${telnetpass}" ]; then - telnetpass="NOTSET" - fi - sdtd_telnet_shutdown=$( expect -c ' - proc abort {} { - puts "Timeout or EOF\n" - exit 1 - } - spawn telnet '"${telnetip}"' '"${telnetport}"' - expect { - "password:" { send "'"${telnetpass}"'\r" } - default abort - } - expect { - "session." { send "shutdown\r" } - default abort - } - expect { eof } - puts "Completed.\n" - ') + if [ -z "${telnetpass}" ]||[ "${telnetpass}" == "NOT SET" ]; then + sdtd_telnet_shutdown=$( expect -c ' + proc abort {} { + puts "Timeout or EOF\n" + exit 1 + } + spawn telnet '"${telnetip}"' '"${telnetport}"' + expect { + "session." { send "shutdown\r" } + default abort + } + expect { eof } + puts "Completed.\n" + ') + else + sdtd_telnet_shutdown=$( expect -c ' + proc abort {} { + puts "Timeout or EOF\n" + exit 1 + } + spawn telnet '"${telnetip}"' '"${telnetport}"' + expect { + "password:" { send "'"${telnetpass}"'\r" } + default abort + } + expect { + "session." { send "shutdown\r" } + default abort + } + expect { eof } + puts "Completed.\n" + ') + fi } fn_stop_graceful_sdtd(){