Browse Source

feat: add stop command using telnet

pull/4590/head
Intel44 1 year ago
parent
commit
c944f92cb4
  1. 2
      lgsm/data/almalinux-8.csv
  2. 2
      lgsm/data/almalinux-9.csv
  3. 2
      lgsm/data/centos-7.csv
  4. 2
      lgsm/data/centos-8.csv
  5. 2
      lgsm/data/centos-9.csv
  6. 2
      lgsm/data/debian-10.csv
  7. 2
      lgsm/data/debian-11.csv
  8. 2
      lgsm/data/debian-12.csv
  9. 2
      lgsm/data/debian-9.csv
  10. 2
      lgsm/data/rhel-7.csv
  11. 2
      lgsm/data/rhel-8.csv
  12. 2
      lgsm/data/rhel-9.csv
  13. 2
      lgsm/data/rocky-8.csv
  14. 2
      lgsm/data/rocky-9.csv
  15. 2
      lgsm/data/ubuntu-16.04.csv
  16. 2
      lgsm/data/ubuntu-18.04.csv
  17. 2
      lgsm/data/ubuntu-20.04.csv
  18. 2
      lgsm/data/ubuntu-22.04.csv
  19. 2
      lgsm/data/ubuntu-23.04.csv
  20. 2
      lgsm/data/ubuntu-23.10.csv
  21. 2
      lgsm/data/ubuntu-24.04.csv
  22. 87
      lgsm/modules/command_stop.sh

2
lgsm/data/almalinux-8.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/almalinux-9.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/centos-7.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/centos-8.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/centos-9.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/debian-10.csv

@ -105,7 +105,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 4.

2
lgsm/data/debian-11.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/debian-12.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/debian-9.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/rhel-7.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/rhel-8.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/rhel-9.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/rocky-8.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/rocky-9.csv

@ -106,7 +106,7 @@ scpslsm
sdtd,telnet,expect,libxml2 sdtd,telnet,expect,libxml2
sf sf
sfc,ncurses-libs.i686 sfc,ncurses-libs.i686
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-16.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-18.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-20.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-22.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-23.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-23.10.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

2
lgsm/data/ubuntu-24.04.csv

@ -106,7 +106,7 @@ scpslsm,mono-complete
sdtd,telnet,expect,libxml2-utils sdtd,telnet,expect,libxml2-utils
sf sf
sfc,libtinfo5:i386 sfc,libtinfo5:i386
sm sm,telnet,expect
sof2 sof2
sol sol
squad squad

Can't render this file because it has a wrong number of fields in line 2.

87
lgsm/modules/command_stop.sh

@ -195,6 +195,91 @@ fn_stop_graceful_sdtd() {
fi fi
} }
# Attempts graceful shutdown of Soulmask using telnet.
fn_stop_graceful_sm() {
fn_print_dots "Graceful: telnet"
fn_script_log_info "Graceful: telnet"
if [ "${telnetenabled}" == "false" ]; then
fn_print_info_nl "Graceful: telnet: DISABLED: Enable in ${servercfg}"
elif [ "$(command -v expect 2> /dev/null)" ]; then
# Tries to shutdown with both localhost and server IP.
for telnetip in 127.0.0.1 ${ip}; do
fn_print_dots "Graceful: telnet: ${telnetip}:${telnetport}"
fn_script_log_info "Graceful: telnet: ${telnetip}:${telnetport}"
fn_stop_graceful_sm_telnet
completed=$(echo -en "\n ${sm_telnet_shutdown}" | grep "Completed.")
refused=$(echo -en "\n ${sm_telnet_shutdown}" | grep "Timeout or EOF")
if [ "${refused}" ]; then
fn_print_error "Graceful: telnet: ${telnetip}:${telnetport} : "
fn_print_fail_eol_nl
fn_script_log_error "Graceful: telnet: ${telnetip}:${telnetport} : FAIL"
elif [ "${completed}" ]; then
break
fi
done
# If telnet shutdown was successful will use telnet again to check
# the connection has closed, confirming that the tmux session can now be killed.
if [ "${completed}" ]; then
for seconds in {1..30}; do
fn_stop_graceful_sm_telnet
refused=$(echo -en "\n ${sm_telnet_shutdown}" | grep "Timeout or EOF")
if [ "${refused}" ]; then
fn_print_ok "Graceful: telnet: ${telnetip}:${telnetport} : "
fn_print_ok_eol_nl
fn_script_log_pass "Graceful: telnet: ${telnetip}:${telnetport} : ${seconds} seconds"
if [ "${statusalert}" == "on" ] && [ "${firstcommandname}" == "STOP" ]; then
alert="stopped"
alert.sh
fi
break
fi
fn_sleep_time_1
fn_print_dots "Graceful: telnet: ${seconds}"
done
# If telnet shutdown fails, show it and stop
else
if [ "${refused}" ]; then
fn_print_error "Graceful: telnet: "
fn_print_fail_eol_nl
fn_script_log_error "Graceful: telnet: ${telnetip}:${telnetport} : FAIL"
else
fn_print_error_nl "Graceful: telnet: Unknown error"
fn_script_log_error "Graceful: telnet: Unknown error"
fi
echo -en "\n" | tee -a "${lgsmlog}"
echo -en "Telnet output:" | tee -a "${lgsmlog}"
echo -en "\n ${sm_telnet_shutdown}" | tee -a "${lgsmlog}"
echo -en "\n\n" | tee -a "${lgsmlog}"
fi
else
fn_print_warn "Graceful: telnet: expect not installed: "
fn_print_fail_eol_nl
fn_script_log_warn "Graceful: telnet: expect not installed: FAIL"
fi
}
# telnet command for soulmask graceful shutdown.
fn_stop_graceful_sm_telnet() {
sm_telnet_shutdown=$(expect -c '
proc abort {} {
puts "Timeout or EOF\n"
exit 1
}
spawn telnet '"${telnetip}"' '"${telnetport}"'
expect {
"session." { send "saveworld 1\r" }
default abort
}
expect {
"session." { send "quit 1\r" }
default abort
}
expect { eof }
puts "Completed.\n"
')
}
# Attempts graceful shutdown by sending /save /stop. # Attempts graceful shutdown by sending /save /stop.
fn_stop_graceful_avorion() { fn_stop_graceful_avorion() {
fn_print_dots "Graceful: /save /stop" fn_print_dots "Graceful: /save /stop"
@ -253,6 +338,8 @@ fn_stop_graceful_select() {
fn_stop_graceful_cmd "end" 30 fn_stop_graceful_cmd "end" 30
elif [ "${stopmode}" == "12" ]; then elif [ "${stopmode}" == "12" ]; then
fn_stop_graceful_cmd "shutdown" 30 fn_stop_graceful_cmd "shutdown" 30
elif [ "${stopmode}" == "13" ]; then
fn_stop_graceful_sm
fi fi
} }

Loading…
Cancel
Save