|
@ -87,26 +87,39 @@ fn_stop_graceful_goldsource(){ |
|
|
|
|
|
|
|
|
# Attempts graceful of 7 Days To Die using telnet. |
|
|
# Attempts graceful of 7 Days To Die using telnet. |
|
|
fn_stop_telnet_sdtd(){ |
|
|
fn_stop_telnet_sdtd(){ |
|
|
if [ -z "${telnetpass}" ]; then |
|
|
if [ -z "${telnetpass}" ]||[ "${telnetpass}" == "NOT SET" ]; then |
|
|
telnetpass="NOTSET" |
|
|
sdtd_telnet_shutdown=$( expect -c ' |
|
|
fi |
|
|
proc abort {} { |
|
|
sdtd_telnet_shutdown=$( expect -c ' |
|
|
puts "Timeout or EOF\n" |
|
|
proc abort {} { |
|
|
exit 1 |
|
|
puts "Timeout or EOF\n" |
|
|
} |
|
|
exit 1 |
|
|
spawn telnet '"${telnetip}"' '"${telnetport}"' |
|
|
} |
|
|
expect { |
|
|
spawn telnet '"${telnetip}"' '"${telnetport}"' |
|
|
"session." { send "shutdown\r" } |
|
|
expect { |
|
|
default abort |
|
|
"password:" { send "'"${telnetpass}"'\r" } |
|
|
} |
|
|
default abort |
|
|
expect { eof } |
|
|
} |
|
|
puts "Completed.\n" |
|
|
expect { |
|
|
') |
|
|
"session." { send "shutdown\r" } |
|
|
else |
|
|
default abort |
|
|
sdtd_telnet_shutdown=$( expect -c ' |
|
|
} |
|
|
proc abort {} { |
|
|
expect { eof } |
|
|
puts "Timeout or EOF\n" |
|
|
puts "Completed.\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(){ |
|
|
fn_stop_graceful_sdtd(){ |
|
@ -118,16 +131,16 @@ fn_stop_graceful_sdtd(){ |
|
|
elif [ "$(command -v expect 2>/dev/null)" ]; then |
|
|
elif [ "$(command -v expect 2>/dev/null)" ]; then |
|
|
# Tries to shutdown with both localhost and server IP. |
|
|
# Tries to shutdown with both localhost and server IP. |
|
|
for telnetip in 127.0.0.1 ${ip}; do |
|
|
for telnetip in 127.0.0.1 ${ip}; do |
|
|
fn_print_dots "Graceful: telnet: ${telnetip}" |
|
|
fn_print_dots "Graceful: telnet: ${telnetip}:${telnetport}" |
|
|
fn_script_log_info "Graceful: telnet: ${telnetip}" |
|
|
fn_script_log_info "Graceful: telnet: ${telnetip}:${telnetport}" |
|
|
sleep 0.5 |
|
|
sleep 0.5 |
|
|
fn_stop_telnet_sdtd |
|
|
fn_stop_telnet_sdtd |
|
|
completed=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Completed.") |
|
|
completed=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Completed.") |
|
|
refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") |
|
|
refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") |
|
|
if [ -n "${refused}" ]; then |
|
|
if [ -n "${refused}" ]; then |
|
|
fn_print_error "Graceful: telnet: ${telnetip}: " |
|
|
fn_print_error "Graceful: telnet: ${telnetip}:${telnetport} : " |
|
|
fn_print_fail_eol_nl |
|
|
fn_print_fail_eol_nl |
|
|
fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL" |
|
|
fn_script_log_error "Graceful: telnet: ${telnetip}:${telnetport} : FAIL" |
|
|
sleep 1 |
|
|
sleep 1 |
|
|
elif [ -n "${completed}" ]; then |
|
|
elif [ -n "${completed}" ]; then |
|
|
break |
|
|
break |
|
@ -141,9 +154,9 @@ fn_stop_graceful_sdtd(){ |
|
|
fn_stop_telnet_sdtd |
|
|
fn_stop_telnet_sdtd |
|
|
refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") |
|
|
refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") |
|
|
if [ -n "${refused}" ]; then |
|
|
if [ -n "${refused}" ]; then |
|
|
fn_print_ok "Graceful: telnet: ${telnetip}: " |
|
|
fn_print_ok "Graceful: telnet: ${telnetip}:${telnetport}: " |
|
|
fn_print_ok_eol_nl |
|
|
fn_print_ok_eol_nl |
|
|
fn_script_log_pass "Graceful: telnet: ${telnetip}: ${seconds} seconds" |
|
|
fn_script_log_pass "Graceful: telnet: ${telnetip}:${telnetport}: ${seconds} seconds" |
|
|
break |
|
|
break |
|
|
fi |
|
|
fi |
|
|
sleep 1 |
|
|
sleep 1 |
|
@ -155,7 +168,7 @@ fn_stop_graceful_sdtd(){ |
|
|
if [ -n "${refused}" ]; then |
|
|
if [ -n "${refused}" ]; then |
|
|
fn_print_error "Graceful: telnet: " |
|
|
fn_print_error "Graceful: telnet: " |
|
|
fn_print_fail_eol_nl |
|
|
fn_print_fail_eol_nl |
|
|
fn_script_log_error "Graceful: telnet: ${telnetip}: FAIL" |
|
|
fn_script_log_error "Graceful: telnet: ${telnetip}:${telnetport}: FAIL" |
|
|
else |
|
|
else |
|
|
fn_print_error_nl "Graceful: telnet: Unknown error" |
|
|
fn_print_error_nl "Graceful: telnet: Unknown error" |
|
|
fn_script_log_error "Graceful: telnet: Unknown error" |
|
|
fn_script_log_error "Graceful: telnet: Unknown error" |
|
|