From 493a3a82fa8e5a9cf7796c0fb3a839ca2da49ca3 Mon Sep 17 00:00:00 2001 From: Thomas S Date: Sun, 16 Jun 2024 20:18:00 +0200 Subject: [PATCH] feat(newserver): soulmask (#4590) * feat: reference new smserver * feat: add default config * feat: add stop command using telnet * fix: remove duplicate unused telnetpassword var * feat: add soulmask to config & info functions * fix: remove ini config for now * fix: startparameter initialization fix * feat: remove pve fixed param in startparameters * fix: update default gamelogdir * fix: handle telnet response during stop process * add sm fix * add fix_sm.sh * add ss command * and * add memory requirements * adjust start parameters * remove telnetpassword * add backup interval a * comments * rename variables to telnetpassword * var name change --------- Co-authored-by: Daniel Gibbs --- .../config-lgsm/smserver/_default.cfg | 189 ++++++++++++++++++ .../config-lgsm/tfserver/_default.cfg | 2 +- .../config-lgsm/vhserver/_default.cfg | 5 +- lgsm/data/almalinux-8.csv | 1 + lgsm/data/almalinux-9.csv | 1 + lgsm/data/centos-7.csv | 1 + lgsm/data/centos-8.csv | 1 + lgsm/data/centos-9.csv | 1 + lgsm/data/debian-10.csv | 1 + lgsm/data/debian-11.csv | 1 + lgsm/data/debian-12.csv | 1 + lgsm/data/debian-9.csv | 1 + lgsm/data/rhel-7.csv | 1 + lgsm/data/rhel-8.csv | 1 + lgsm/data/rhel-9.csv | 1 + lgsm/data/rocky-8.csv | 1 + lgsm/data/rocky-9.csv | 1 + lgsm/data/serverlist.csv | 1 + lgsm/data/ubuntu-16.04.csv | 1 + lgsm/data/ubuntu-18.04.csv | 1 + lgsm/data/ubuntu-20.04.csv | 1 + lgsm/data/ubuntu-22.04.csv | 1 + lgsm/data/ubuntu-23.04.csv | 1 + lgsm/data/ubuntu-23.10.csv | 1 + lgsm/data/ubuntu-24.04.csv | 1 + lgsm/modules/check_system_requirements.sh | 4 +- .../modules/command_dev_parse_game_details.sh | 1 - lgsm/modules/command_dev_query_raw.sh | 2 +- lgsm/modules/command_stop.sh | 107 +++++++++- lgsm/modules/core_modules.sh | 5 + lgsm/modules/fix.sh | 2 +- lgsm/modules/fix_sm.sh | 10 + lgsm/modules/info_game.sh | 17 +- lgsm/modules/info_messages.sh | 32 ++- lgsm/modules/install_config.sh | 3 + 35 files changed, 381 insertions(+), 20 deletions(-) create mode 100644 lgsm/config-default/config-lgsm/smserver/_default.cfg create mode 100644 lgsm/modules/fix_sm.sh diff --git a/lgsm/config-default/config-lgsm/smserver/_default.cfg b/lgsm/config-default/config-lgsm/smserver/_default.cfg new file mode 100644 index 0000000000..306179b9ce --- /dev/null +++ b/lgsm/config-default/config-lgsm/smserver/_default.cfg @@ -0,0 +1,189 @@ +################################## +######## Default Settings ######## +################################## +# DO NOT EDIT, ANY CHANGES WILL BE OVERWRITTEN! +# Copy settings from here and use them in either: +# common.cfg - applies settings to every instance. +# [instance].cfg - applies settings to a specific instance. + +#### Game Server Settings #### + +## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters +servername="LinuxGSM" +serverpassword="" +adminpassword="" +port="8777" +queryport="27015" +telnetport="18888" +maxplayers="50" +backupinterval="15" # Backup interval in minutes. +defaultmap="Level01_Main" + +## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters +startparameters="WS ${defaultmap} -MultiHome=${ip} -Port=${port} -EchoPort=${telnetport} -QueryPort=${queryport} -SteamServerName='${servername}' -PSW='${serverpassword}' -adminpsw='${adminpassword}' -MaxPlayers=${maxplayers} -initbackup -backupinterval=${backupinterval} -UTF8Output -forcepassthrough -log" + +#### LinuxGSM Settings #### + +## LinuxGSM Stats +# Send useful stats to LinuxGSM developers. +# https://docs.linuxgsm.com/configuration/linuxgsm-stats +# (on|off) +stats="off" + +## Notification Alerts +# (on|off) + +# Display IP | https://docs.linuxgsm.com/alerts#display-ip +displayip="" + +# More info | https://docs.linuxgsm.com/alerts#more-info +postalert="off" + +# Alert on Start/Stop/Restart +statusalert="off" + +# Discord Alerts | https://docs.linuxgsm.com/alerts/discord +discordalert="off" +discordwebhook="webhook" + +# Email Alerts | https://docs.linuxgsm.com/alerts/email +emailalert="off" +email="email@example.com" +emailfrom="" + +# Gotify Alerts | https://docs.linuxgsm.com/alerts/gotify +gotifyalert="off" +gotifytoken="token" +gotifywebhook="webhook" + +# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt +iftttalert="off" +ifttttoken="accesstoken" +iftttevent="linuxgsm_alert" + +# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet +pushbulletalert="off" +pushbullettoken="accesstoken" +channeltag="" + +# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover +pushoveralert="off" +pushovertoken="accesstoken" +pushoveruserkey="userkey" + +# Rocket.Chat Alerts | https://docs.linuxgsm.com/alerts/rocket.chat +rocketchatalert="off" +rocketchatwebhook="webhook" + +# Slack Alerts | https://docs.linuxgsm.com/alerts/slack +slackalert="off" +slackwebhook="webhook" + +# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram +# You can add a custom cURL string eg proxy (useful in Russia) in "curlcustomstring". +# For example "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help all". +telegramapi="api.telegram.org" +telegramalert="off" +telegramtoken="accesstoken" +telegramchatid="" +telegramthreadid="" +telegramsilentnotification="false" +curlcustomstring="" + +## Updating | https://docs.linuxgsm.com/commands/update +updateonstart="off" + +## Backup | https://docs.linuxgsm.com/commands/backup +maxbackups="4" +maxbackupdays="30" +stoponbackup="on" + +## Logging | https://docs.linuxgsm.com/features/logging +consolelogging="on" +logdays="7" + +## Monitor | https://docs.linuxgsm.com/commands/monitor +# Query delay time +querydelay="5" + +## ANSI Colors | https://docs.linuxgsm.com/features/ansi-colors +ansi="on" + +#### Advanced Settings #### + +## Message Display Time | https://docs.linuxgsm.com/features/message-display-time +sleeptime="0.5" + +## SteamCMD Settings | https://docs.linuxgsm.com/steamcmd +# Server appid +appid="3017300" +steamcmdforcewindows="no" +# SteamCMD Branch | https://docs.linuxgsm.com/steamcmd/branch +branch="" +betapassword="" +# Master Server | https://docs.linuxgsm.com/steamcmd/steam-master-server +steammaster="true" + +## Stop Mode | https://docs.linuxgsm.com/features/stop-mode +# 1: tmux kill +# 2: CTRL+c +# 3: quit +# 4: quit 120s +# 5: stop +# 6: q +# 7: exit +# 8: 7 Days to Die +# 9: GoldSrc +# 10: Avorion +# 11: end +# 12: shutdown +# 13: soulmask +stopmode="13" + +## Query mode +# 1: session only +# 2: gamedig (gsquery fallback) +# 3: gamedig +# 4: gsquery +# 5: tcp +querymode="2" +querytype="protocol-valve" + +## Console type +consoleverbose="yes" +consoleinteract="no" + +## Game Server Details +# Do not edit +gamename="Soulmask" +engine="unreal4" +glibc="2.17" + +#### Directories #### +# Edit with care + +## Game Server Directories +systemdir="${serverfiles}/WS" +executabledir="${systemdir}/Binaries/Linux" +executable="./WSServer-Linux-Shipping" + +## Backup Directory +backupdir="${lgsmdir}/backup" + +## Logging Directories +[ -n "${LGSM_LOGDIR}" ] && logdir="${LGSM_LOGDIR}" || logdir="${rootdir}/log" +gamelogdir="${systemdir}/WS/Saved/Logs" +lgsmlogdir="${logdir}/script" +consolelogdir="${logdir}/console" +lgsmlog="${lgsmlogdir}/${selfname}-script.log" +consolelog="${consolelogdir}/${selfname}-console.log" +alertlog="${lgsmlogdir}/${selfname}-alert.log" +postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log" + +## Logs Naming +lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log" +consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log" + +## Log Parameters +logtimestamp="off" +logtimestampformat="%Y-%m-%d %H:%M:%S" diff --git a/lgsm/config-default/config-lgsm/tfserver/_default.cfg b/lgsm/config-default/config-lgsm/tfserver/_default.cfg index c6d9842b38..fbce96a44c 100644 --- a/lgsm/config-default/config-lgsm/tfserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/tfserver/_default.cfg @@ -25,7 +25,7 @@ greenhand="true" maxplayers="40" maxqueuesize="50" queuevalidtime="120" -saveinterval="300" +saveinterval="300" # Auto-save in seconds. serveradmins="" # Use 17-digit Steam IDs separated by commas to grant admin privileges to players. servername="LinuxGSM" serverpassword="" diff --git a/lgsm/config-default/config-lgsm/vhserver/_default.cfg b/lgsm/config-default/config-lgsm/vhserver/_default.cfg index 8950435e82..b027d0fca2 100644 --- a/lgsm/config-default/config-lgsm/vhserver/_default.cfg +++ b/lgsm/config-default/config-lgsm/vhserver/_default.cfg @@ -10,14 +10,13 @@ ## Predefined Parameters | https://docs.linuxgsm.com/configuration/start-parameters servername="LinuxGSM" -# Minimum password length is 5. -serverpassword="" +serverpassword="" # Minimum password length is 5. port="2456" worldname="${selfname}" public="1" savedir="$HOME/.config/unity3d/IronGate/Valheim" logFile="" -saveinterval="1800" +saveinterval="1800" # Auto-save in seconds. backups="4" backupshort="7200" backuplong="43200" diff --git a/lgsm/data/almalinux-8.csv b/lgsm/data/almalinux-8.csv index ab8d75b6a2..2042421448 100644 --- a/lgsm/data/almalinux-8.csv +++ b/lgsm/data/almalinux-8.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/almalinux-9.csv b/lgsm/data/almalinux-9.csv index e4fb83e3b4..02f21426ca 100644 --- a/lgsm/data/almalinux-9.csv +++ b/lgsm/data/almalinux-9.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/centos-7.csv b/lgsm/data/centos-7.csv index 0e04e3c743..a536c9c0f2 100644 --- a/lgsm/data/centos-7.csv +++ b/lgsm/data/centos-7.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/centos-8.csv b/lgsm/data/centos-8.csv index c07bf66d0d..d4d008fd46 100644 --- a/lgsm/data/centos-8.csv +++ b/lgsm/data/centos-8.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/centos-9.csv b/lgsm/data/centos-9.csv index c919a160be..574401733b 100644 --- a/lgsm/data/centos-9.csv +++ b/lgsm/data/centos-9.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/debian-10.csv b/lgsm/data/debian-10.csv index 1892d9f9fe..6b1a843bbe 100644 --- a/lgsm/data/debian-10.csv +++ b/lgsm/data/debian-10.csv @@ -104,6 +104,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/debian-11.csv b/lgsm/data/debian-11.csv index 9a37307c02..60a46f55db 100644 --- a/lgsm/data/debian-11.csv +++ b/lgsm/data/debian-11.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/debian-12.csv b/lgsm/data/debian-12.csv index 8835871ee5..0fd50f2d7e 100644 --- a/lgsm/data/debian-12.csv +++ b/lgsm/data/debian-12.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/debian-9.csv b/lgsm/data/debian-9.csv index c202924de2..174bd8e165 100644 --- a/lgsm/data/debian-9.csv +++ b/lgsm/data/debian-9.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/rhel-7.csv b/lgsm/data/rhel-7.csv index 0546d8eb1d..8854649adf 100644 --- a/lgsm/data/rhel-7.csv +++ b/lgsm/data/rhel-7.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/rhel-8.csv b/lgsm/data/rhel-8.csv index bbfb982f0b..7dd334f381 100644 --- a/lgsm/data/rhel-8.csv +++ b/lgsm/data/rhel-8.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/rhel-9.csv b/lgsm/data/rhel-9.csv index e4fb83e3b4..02f21426ca 100644 --- a/lgsm/data/rhel-9.csv +++ b/lgsm/data/rhel-9.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/rocky-8.csv b/lgsm/data/rocky-8.csv index bbfb982f0b..7dd334f381 100644 --- a/lgsm/data/rocky-8.csv +++ b/lgsm/data/rocky-8.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/rocky-9.csv b/lgsm/data/rocky-9.csv index e4fb83e3b4..02f21426ca 100644 --- a/lgsm/data/rocky-9.csv +++ b/lgsm/data/rocky-9.csv @@ -105,6 +105,7 @@ scpslsm sdtd,telnet,expect,libxml2 sf sfc,ncurses-libs.i686 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/serverlist.csv b/lgsm/data/serverlist.csv index 23e1266270..7d21733211 100644 --- a/lgsm/data/serverlist.csv +++ b/lgsm/data/serverlist.csv @@ -104,6 +104,7 @@ scpslsm,scpslsmserver,SCP: Secret Laboratory ServerMod,ubuntu-22.04 sdtd,sdtdserver,7 Days to Die,ubuntu-22.04 sf,sfserver,Satisfactory,ubuntu-22.04 sfc,sfcserver,SourceForts Classic,ubuntu-22.04 +sm,smserver,Soulmask,ubuntu-22.04 sof2,sof2server,Soldier Of Fortune 2: Gold Edition,ubuntu-22.04 sol,solserver,Soldat,ubuntu-22.04 squad,squadserver,Squad,ubuntu-22.04 diff --git a/lgsm/data/ubuntu-16.04.csv b/lgsm/data/ubuntu-16.04.csv index cf6a202205..1f359ab9d0 100644 --- a/lgsm/data/ubuntu-16.04.csv +++ b/lgsm/data/ubuntu-16.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-18.04.csv b/lgsm/data/ubuntu-18.04.csv index 6f7dcbe18d..cccd53dc71 100644 --- a/lgsm/data/ubuntu-18.04.csv +++ b/lgsm/data/ubuntu-18.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-20.04.csv b/lgsm/data/ubuntu-20.04.csv index 98ba275f9c..4c0cae0a86 100644 --- a/lgsm/data/ubuntu-20.04.csv +++ b/lgsm/data/ubuntu-20.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-22.04.csv b/lgsm/data/ubuntu-22.04.csv index 9bc8f7ad1c..b0f896fae8 100644 --- a/lgsm/data/ubuntu-22.04.csv +++ b/lgsm/data/ubuntu-22.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-23.04.csv b/lgsm/data/ubuntu-23.04.csv index e6d0c2962d..7ad90039b1 100644 --- a/lgsm/data/ubuntu-23.04.csv +++ b/lgsm/data/ubuntu-23.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-23.10.csv b/lgsm/data/ubuntu-23.10.csv index e6d0c2962d..7ad90039b1 100644 --- a/lgsm/data/ubuntu-23.10.csv +++ b/lgsm/data/ubuntu-23.10.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/data/ubuntu-24.04.csv b/lgsm/data/ubuntu-24.04.csv index e6d0c2962d..7ad90039b1 100644 --- a/lgsm/data/ubuntu-24.04.csv +++ b/lgsm/data/ubuntu-24.04.csv @@ -105,6 +105,7 @@ scpslsm,mono-complete sdtd,telnet,expect,libxml2-utils sf sfc,libtinfo5:i386 +sm,telnet,expect sof2 sol squad diff --git a/lgsm/modules/check_system_requirements.sh b/lgsm/modules/check_system_requirements.sh index 0214cdc1a9..d25954427d 100644 --- a/lgsm/modules/check_system_requirements.sh +++ b/lgsm/modules/check_system_requirements.sh @@ -9,7 +9,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" info_distro.sh -# RAM requirements in megabytes for each game or engine. +# RAM requirements in gigabytes for each game or engine. if [ "${shortname}" == "ark" ]; then ramrequirementgb="7" @@ -49,6 +49,8 @@ elif [ "${shortname}" == "sf" ]; then ramrequirementgb="12" elif [ "${shortname}" == "squad" ]; then ramrequirementgb="2" +elif [ "${shortname}" == "sm" ]; then + ramrequirementgb="10" elif [ "${shortname}" == "st" ]; then ramrequirementgb="1" elif [ "${shortname}" == "stn" ]; then diff --git a/lgsm/modules/command_dev_parse_game_details.sh b/lgsm/modules/command_dev_parse_game_details.sh index 2bb01e436b..2e22aa7ae0 100644 --- a/lgsm/modules/command_dev_parse_game_details.sh +++ b/lgsm/modules/command_dev_parse_game_details.sh @@ -112,7 +112,6 @@ declare -A server_details=( ['Steamworks Port']="${steamworksport}" ['Telnet Enabled']="${telnetenabled}" ['Telnet IP']="${telnetip}" - ['Telnet Password']="${telnetpass}" ['Telnet Password']="${telnetpassword}" ['Telnet Port']="${telnetport}" ['Tickrate']="${tickrate}" diff --git a/lgsm/modules/command_dev_query_raw.sh b/lgsm/modules/command_dev_query_raw.sh index ae49a1b85f..39f4787d30 100644 --- a/lgsm/modules/command_dev_query_raw.sh +++ b/lgsm/modules/command_dev_query_raw.sh @@ -207,7 +207,7 @@ echo -e "" echo -e "${lightgreen}Gamedig Raw Output${default}" fn_messages_separator echo -e "" -if [ ! "$(command -v gamedig 2> /dev/null)" ] || [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then +if [ ! "$(command -v gamedig 2> /dev/null)" ] && [ ! -f "${lgsmdir}/node_modules/gamedig/bin/gamedig.js" ]; then fn_print_failure_nl "gamedig not installed" fi if [ ! "$(command -v jq 2> /dev/null)" ]; then diff --git a/lgsm/modules/command_stop.sh b/lgsm/modules/command_stop.sh index 3d534317a4..7783cc94f7 100644 --- a/lgsm/modules/command_stop.sh +++ b/lgsm/modules/command_stop.sh @@ -96,8 +96,8 @@ fn_stop_graceful_goldsrc() { # telnet command for sdtd graceful shutdown. fn_stop_graceful_sdtd_telnet() { - if [ -z "${telnetpass}" ] || [ "${telnetpass}" == "NOT SET" ]; then - sdtd_telnet_shutdown=$(expect -c ' + if [ -z "${telnetpassword}" ] || [ "${telnetpassword}" == "NOT SET" ]; then + sdtdtelnetshutdown=$(expect -c ' proc abort {} { puts "Timeout or EOF\n" exit 1 @@ -111,14 +111,14 @@ fn_stop_graceful_sdtd_telnet() { puts "Completed.\n" ') else - sdtd_telnet_shutdown=$(expect -c ' + sdtdtelnetshutdown=$(expect -c ' proc abort {} { puts "Timeout or EOF\n" exit 1 } spawn telnet '"${telnetip}"' '"${telnetport}"' expect { - "password:" { send "'"${telnetpass}"'\r" } + "password:" { send "'"${telnetpassword}"'\r" } default abort } expect { @@ -143,8 +143,8 @@ fn_stop_graceful_sdtd() { fn_print_dots "Graceful: telnet: ${telnetip}:${telnetport}" fn_script_log_info "Graceful: telnet: ${telnetip}:${telnetport}" fn_stop_graceful_sdtd_telnet - completed=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Completed.") - refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") + completed=$(echo -en "\n ${sdtdtelnetshutdown}" | grep "Completed.") + refused=$(echo -en "\n ${sdtdtelnetshutdown}" | grep "Timeout or EOF") if [ "${refused}" ]; then fn_print_error "Graceful: telnet: ${telnetip}:${telnetport} : " fn_print_fail_eol_nl @@ -159,7 +159,7 @@ fn_stop_graceful_sdtd() { if [ "${completed}" ]; then for seconds in {1..30}; do fn_stop_graceful_sdtd_telnet - refused=$(echo -en "\n ${sdtd_telnet_shutdown}" | grep "Timeout or EOF") + refused=$(echo -en "\n ${sdtdtelnetshutdown}" | grep "Timeout or EOF") if [ "${refused}" ]; then fn_print_ok "Graceful: telnet: ${telnetip}:${telnetport} : " fn_print_ok_eol_nl @@ -185,7 +185,7 @@ fn_stop_graceful_sdtd() { fi echo -en "\n" | tee -a "${lgsmlog}" echo -en "Telnet output:" | tee -a "${lgsmlog}" - echo -en "\n ${sdtd_telnet_shutdown}" | tee -a "${lgsmlog}" + echo -en "\n ${sdtdtelnetshutdown}" | tee -a "${lgsmlog}" echo -en "\n\n" | tee -a "${lgsmlog}" fi else @@ -195,6 +195,95 @@ fn_stop_graceful_sdtd() { 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 ${smtelnetshutdown}" | grep "Completed.") + refused=$(echo -en "\n ${smtelnetshutdown}" | 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 ${smtelnetshutdown}" | 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 ${smtelnetshutdown}" | 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() { + smtelnetshutdown=$(expect -c ' + proc abort {} { + puts "Timeout or EOF\n" + exit 1 + } + spawn telnet '"${telnetip}"' '"${telnetport}"' + expect { + "Hello:" { send "saveworld 1\r" } + default abort + } + expect { + "the world is saved." { send "quit 1\r" } + default abort + } + expect { + "World is closing..." {} + default abort + } + expect { eof } + puts "Completed.\n" + ') +} + # Attempts graceful shutdown by sending /save /stop. fn_stop_graceful_avorion() { fn_print_dots "Graceful: /save /stop" @@ -253,6 +342,8 @@ fn_stop_graceful_select() { fn_stop_graceful_cmd "end" 30 elif [ "${stopmode}" == "12" ]; then fn_stop_graceful_cmd "shutdown" 30 + elif [ "${stopmode}" == "13" ]; then + fn_stop_graceful_sm fi } diff --git a/lgsm/modules/core_modules.sh b/lgsm/modules/core_modules.sh index f083a48936..6a5bcc6620 100644 --- a/lgsm/modules/core_modules.sh +++ b/lgsm/modules/core_modules.sh @@ -446,6 +446,11 @@ fix_sfc.sh() { fn_fetch_module } +fix_sm.sh() { + modulefile="${FUNCNAME[0]}" + fn_fetch_module +} + fix_st.sh() { modulefile="${FUNCNAME[0]}" fn_fetch_module diff --git a/lgsm/modules/fix.sh b/lgsm/modules/fix.sh index dbb8e3545c..e6e00465d8 100644 --- a/lgsm/modules/fix.sh +++ b/lgsm/modules/fix.sh @@ -52,7 +52,7 @@ fn_apply_fix() { fi } -apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins kf nmrih onset pvr ro rust rw samp sdtd sfc sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr) +apply_pre_start_fix=(arma3 armar ark av bt bo csgo cmw dst hw ins kf nmrih onset pvr ro rust rw samp sdtd sfc sm sof2 squad st tf2 terraria ts3 mcb mta unt vh wurm zmr) apply_post_install_fix=(av kf kf2 ro ut2k4 ut ut3) # validate registered fixes for safe development diff --git a/lgsm/modules/fix_sm.sh b/lgsm/modules/fix_sm.sh new file mode 100644 index 0000000000..1d72a48bfe --- /dev/null +++ b/lgsm/modules/fix_sm.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# LinuxGSM fix_sm.sh module +# Author: Daniel Gibbs +# Contributors: http://linuxgsm.com/contrib +# Website: https://linuxgsm.com +# Description: Resolves issues with Unturned. + +moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" + +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${serverfiles}:${serverfiles}/linux64" diff --git a/lgsm/modules/info_game.sh b/lgsm/modules/info_game.sh index f4caa5a7fa..0f38ea2500 100644 --- a/lgsm/modules/info_game.sh +++ b/lgsm/modules/info_game.sh @@ -1970,7 +1970,7 @@ fn_info_game_sdtd() { telnetenabled="${telnetenabled:-"NOT SET"}" # Telnet IP will be localhost if no password is set # check_ip will set the IP first. This will overwrite it. - if [ -z "${telnetpass}" ]; then + if [ -z "${telnetpassword}" ]; then telnetip="127.0.0.1" fi telnetpass="${telnetpass:-"NOT SET"}" @@ -1988,6 +1988,19 @@ fn_info_game_sf() { beaconport="${beaconport:-"0"}" } +# Config Type: Parameters (with an ini) +fn_info_game_sm() { + servername="${servername:-"NOT SET"}" + adminpassword="${adminpassword:-"NOT SET"}" + port="${port:-"0"}" + queryport="${queryport:-"0"}" + maxplayers="${maxplayers:-"0"}" + # telnet config + telnetenabled=true + telnetip="127.0.0.1" + telnetport="${telnetport:-"0"}" +} + # Config Type: QuakeC # Comment: // or /* */ # Example: set sv_hostname "SERVERNAME" @@ -2407,6 +2420,8 @@ elif [ "${shortname}" == "sdtd" ]; then fn_info_game_sdtd elif [ "${shortname}" == "sf" ]; then fn_info_game_sf +elif [ "${shortname}" == "sm" ]; then + fn_info_game_sm elif [ "${shortname}" == "sof2" ]; then fn_info_game_sof2 elif [ "${shortname}" == "sol" ]; then diff --git a/lgsm/modules/info_messages.sh b/lgsm/modules/info_messages.sh index a5f25bc742..9bab0cbb72 100644 --- a/lgsm/modules/info_messages.sh +++ b/lgsm/modules/info_messages.sh @@ -30,8 +30,8 @@ fn_info_messages_password_strip() { httppassword="********" fi - if [ "${telnetpass}" ]; then - telnetpass="********" + if [ "${telnetpassword}" ]; then + telnetpassword="********" fi if [ "${wsapikey}" ]; then @@ -483,6 +483,11 @@ fn_info_messages_gameserver() { echo -e "${lightblue}Version Count:\t${default}${versioncount}" fi + # backupinterval (Soulmask) + if [ -n "${backupinterval}" ]; then + echo -e "${lightblue}Backup Interval:\t${default}${backupinterval}" + fi + # Listed on Master server if [ -n "${displaymasterserver}" ]; then if [ "${displaymasterserver}" == "true" ]; then @@ -702,6 +707,8 @@ fn_info_messages_ports() { portcommand="ss -tuplwn | grep java" elif [ "${shortname}" == "terraria" ]; then portcommand="ss -tuplwn | grep Main" + elif [ "${shortname}" == "sm" ]; then + portcommand="ss -tuplwn | grep WSServer-Linux" elif [ "${engine}" == "source" ]; then portcommand="ss -tuplwn | grep srcds_linux" elif [ "${engine}" == "goldsrc" ]; then @@ -1435,7 +1442,7 @@ fn_info_messages_sdtd() { { echo -e "${lightblue}Telnet enabled:\t${default}${telnetenabled}" echo -e "${lightblue}Telnet address:\t${default}${telnetip} ${telnetport}" - echo -e "${lightblue}Telnet password:\t${default}${telnetpass}" + echo -e "${lightblue}Telnet password:\t${default}${telnetpassword}" } | column -s $'\t' -t } @@ -1448,6 +1455,23 @@ fn_info_messages_sf() { } | column -s $'\t' -t } +fn_info_messages_sm() { + fn_info_messages_password_strip + { + fn_port "header" + fn_port "Game" port udp + fn_port "Query" queryport udp + fn_port "Telnet" telnetport tcp + } | column -s $'\t' -t + echo -e "" + echo -e "${bold}${lightgreen}${gamename} Telnet${default}" + fn_messages_separator + { + echo -e "${lightblue}Telnet enabled:\t${default}${telnetenabled}" + echo -e "${lightblue}Telnet address:\t${default}${telnetip} ${telnetport}" + } | column -s $'\t' -t +} + fn_info_messages_sof2() { { fn_port "header" @@ -1842,6 +1866,8 @@ fn_info_messages_select_engine() { fn_info_messages_sdtd elif [ "${shortname}" == "sf" ]; then fn_info_messages_sf + elif [ "${shortname}" == "sm" ]; then + fn_info_messages_sm elif [ "${shortname}" == "sof2" ]; then fn_info_messages_sof2 elif [ "${shortname}" == "sol" ]; then diff --git a/lgsm/modules/install_config.sh b/lgsm/modules/install_config.sh index eea590f9e2..22843c7b02 100644 --- a/lgsm/modules/install_config.sh +++ b/lgsm/modules/install_config.sh @@ -695,6 +695,9 @@ elif [ "${shortname}" == "sf" ]; then fn_default_config_remote fn_set_config_vars fn_list_config_locations +elif [ "${shortname}" == "sm" ]; then + fn_default_config_local + fn_list_config_locations elif [ "${shortname}" == "sol" ]; then array_configs+=(soldat.ini) fn_fetch_default_config