Browse Source

feat(solserver): migrate to steamcmd and improve monitor (#2829)

* convert to SteamCMD
* add soldat query
* Added display ports in query raw
Daniel Gibbs 6 years ago
parent
commit
f355275cdf

+ 9 - 5
lgsm/config-default/config-lgsm/solserver/_default.cfg

@@ -10,13 +10,11 @@
 
 ## Server Start Settings | https://docs.linuxgsm.com/configuration/start-parameters
 ip="0.0.0.0"
-port="23073"
-maxplayers="32"
 maplist="mapslist.txt"
 
 ## Server Start Command | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
 fn_parms(){
-parms="-b ${ip} -p ${port} -l ${maxplayers} -m ${maplist} -c ${servercfg}"
+parms="-b ${ip} -m ${maplist} -c ${servercfg}"
 }
 
 #### LinuxGSM Settings ####
@@ -102,6 +100,12 @@ ansi="on"
 ## Message Display Time | https://docs.linuxgsm.com/features/message-display-time
 sleeptime="0.5"
 
+## SteamCMD Settings | https://docs.linuxgsm.com/steamcmd
+# Server appid
+appid="638500"
+# SteamCMD Branch | https://docs.linuxgsm.com/steamcmd/branch
+branch=""
+
 ## Stop Mode | https://docs.linuxgsm.com/features/stop-mode
 # 1: tmux kill
 # 2: CTRL+c
@@ -121,8 +125,8 @@ stopmode="2"
 # 3: gamedig
 # 4: gsquery
 # 5: tcp
-querymode="5"
-querytype=""
+querymode="4"
+querytype="soldat"
 
 ## Game Server Details
 # Do not edit

+ 10 - 4
lgsm/functions/command_dev_query_raw.sh

@@ -8,10 +8,20 @@ local modulename="QUERY-RAW"
 local commandaction="Query Raw"
 local function_selfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
 
+check.sh
+info_config.sh
+info_parms.sh
+
 echo -e ""
 echo -e "Query Port - Raw Output"
 echo -e "=================================================================="
 echo -e ""
+echo -e "Ports"
+echo -e "================================="
+echo -e ""
+echo -e "PORT: ${port}"
+echo -e "QUERY PORT: ${queryport}"
+echo -e ""
 echo -e "Gamedig Raw Output"
 echo -e "================================="
 echo -e ""
@@ -22,10 +32,6 @@ if [ ! "$(command -v jq 2>/dev/null)" ]; then
 	fn_print_failure_nl "jq not installed"
 fi
 
-check.sh
-info_config.sh
-info_parms.sh
-
 query_gamedig.sh
 echo -e "${gamedigcmd}"
 echo""

+ 18 - 4
lgsm/functions/info_config.sh

@@ -1350,13 +1350,27 @@ fn_info_config_mordhau(){
 
 fn_info_config_soldat(){
 	if [ ! -f "${servercfgfullpath}" ]; then
+		adminpassword="${unavailable}"
+		maxplayers="${unavailable}"
+		port="${zero}"
+		queryport="${zero}"
 		servername="${unavailable}"
 		serverpassword="${unavailable}"
-		adminpassword="${unavailable}"
 	else
-		servername=$(grep "Server_Name" "${servercfgfullpath}" | awk -F '=' '{print $2}')
-		serverpassword=$(grep "Game_Password" "${servercfgfullpath}" | awk -F '=' '{print $2}')
-		adminpassword=$(grep "Admin_Password" "${servercfgfullpath}" | awk -F '=' '{print $2}')
+		adminpassword=$(grep "Admin_Password=" "${servercfgfullpath}" | awk -F '=' '{print $2}')
+		maxplayers=$(grep "Max_Players=" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		port=$(grep "Port=" "${servercfgfullpath}" | tr -cd '[:digit:]')
+		queryport="${port}"
+		servername=$(grep "Server_Name=" "${servercfgfullpath}" | awk -F '=' '{print $2}')
+		serverpassword=$(grep "Game_Password=" "${servercfgfullpath}" | awk -F '=' '{print $2}')
+
+		# Not set
+		adminpassword=${adminpassword:-"NOT SET"}
+		maxplayers=${maxplayers:-"0"}
+		port=${port:-"23073"}
+		queryport=${queryport:-"23083"}
+		servername=${servername:-"NOT SET"}
+		serverpassword=${serverpassword:-"NOT SET"}
 	fi
 }
 

+ 1 - 1
lgsm/functions/info_messages.sh

@@ -1341,7 +1341,7 @@ fn_info_message_soldat() {
 	{
 		echo -e "${lightblue}DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL${default}"
 		echo -e "> Game\tINBOUND\t${port}\tudp"
-		echo -e "> RCON\tINBOUND\t${port}\ttcp"
+		echo -e "> Query\tINBOUND\t${queryport}\tudp"
 		echo -e "> FILES\tINBOUND\t$((port+10))\ttcp"
 	} | column -s $'\t' -t
 }

+ 0 - 11
lgsm/functions/info_parms.sh

@@ -179,15 +179,6 @@ fn_info_parms_sof2(){
 	defaultmap=${defaultmap:-"NOT SET"}
 }
 
-fn_info_parms_soldat(){
-	port=${port:-"0"}
-	queryport=${port:-"0"}
-	servername=${servername:-"NOT SET"}
-	serverpassword=${serverpassword:-"NOT SET"}
-	adminpassword=${adminpassword:-"NOT SET"}
-	maxplayers=${maxplayers:-"0"}
-}
-
 fn_info_parms_ss3(){
 	port=${port:-"0"}
 	queryport=$((port + 1))
@@ -279,8 +270,6 @@ elif [ "${shortname}" == "sof2" ]; then
 # Sticky Bots
 elif [ "${shortname}" == "sbots" ]; then
 	fn_info_parms_stickybots
-elif [ "${shortname}" == "sol" ]; then
-	fn_info_parms_soldat
 # Serious Sam
 elif [ "${shortname}" == "ss3" ]; then
 	fn_info_parms_ss3

+ 0 - 2
lgsm/functions/install_server_files.sh

@@ -61,8 +61,6 @@ fn_install_server_files(){
 		remote_fileurl="http://linuxgsm.download/WolfensteinEnemyTerritory/enemy-territory.260b.tar.bz2"; local_filedir="${tmpdir}"; local_filename="enemy-territory.260b.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="f833f514bfcdd46b42c111f83350c5a7"
 	elif [ "${shortname}" == "samp" ]; then
 		remote_fileurl="https://files.sa-mp.com/samp037svr_R2-1.tar.gz"; local_filedir="${tmpdir}"; local_filename="samp037svr_R2-1.tar.gz"; chmodx="nochmodx" run="norun"; force="noforce"; md5="93705e165550c97484678236749198a4"
-	elif [ "${shortname}" == "sol" ]; then
-		remote_fileurl="https://static.soldat.pl/downloads/soldatserver2.8.1_1.7.1.zip"; local_filedir="${tmpdir}"; local_filename="soldatserver2.8.1_1.7.1.zip"; chmodx="nochmodx" run="norun"; force="noforce"; md5="994409c28520425965dec5c71ccb55e1"
 	elif [ "${shortname}" == "zmr" ]; then
 		remote_fileurl="http://linuxgsm.download/ZombieMasterReborn/zombie_master_reborn_b5_2.tar.bz2"; local_filedir="${tmpdir}"; local_filename="zombie_master_reborn_b5_2.tar.bz2"; chmodx="nochmodx" run="norun"; force="noforce"; md5="d52ef2db376f5d21e3a4ceca85ec8761"
 	fi

+ 8 - 5
lgsm/functions/query_gsquery.py

@@ -24,6 +24,7 @@ class gsquery:
         minecraftbequery=['minecraftbe']
         jc2mpquery=['jc2mp']
         mumblequery=['mumbleping']
+        soldatquery=['soldat']
         twquery=['teeworlds']
         unrealquery=['protocol-gamespy1','unreal']
         unreal2query=['protocol-unreal2','unreal2']
@@ -41,12 +42,14 @@ class gsquery:
             self.query_prompt_string = b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\xfe\xfe\xfe\xfe\xfd\xfd\xfd\xfd\x12\x34\x56\x78\x00\x00\x00\x00\x00\x00\x00\x00'
         elif self.option.engine in mumblequery:
             self.query_prompt_string = b'\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08'
+        elif self.option.engine in soldatquery:
+            self.query_prompt_string = b'\x69\x00'
+        elif self.option.engine in twquery:
+            self.query_prompt_string = b"\x04\x00\x00\xff\xff\xff\xff\x05" + bytearray(511)
         elif self.option.engine in unrealquery:
             self.query_prompt_string = b'\x5C\x69\x6E\x66\x6F\x5C'
         elif self.option.engine in unreal2query:
             self.query_prompt_string = b'\x79\x00\x00\x00\x00'
-        elif self.option.engine in twquery:
-            self.query_prompt_string = b"\x04\x00\x00\xff\xff\xff\xff\x05" + bytearray(511)
 
         self.connected = False
         self.response = None
@@ -81,8 +84,8 @@ class gsquery:
         # Response.
         if self.response is None:
             self.fatal_error('No response', 3)
-        if len(self.response) < 10:
-            sys.exit('Short response.', 3)
+        if len(self.response) < 2:
+            sys.exit('Short response.', 5)
         else:
             self.exit_success(str(self.response))
 
@@ -116,7 +119,7 @@ if __name__ == '__main__':
         action='store',
         dest='engine',
         default=False,
-        help='Engine type: protocol-valve protocol-quake3 protocol-quake3 protocol-gamespy1 protocol-unreal2 minecraft minecraftbe jc2mp mumbleping teeworlds'
+        help='Engine type: protocol-valve protocol-quake3 protocol-quake3 protocol-gamespy1 protocol-unreal2 minecraft minecraftbe jc2mp mumbleping soldat teeworlds'
     )
     parser.add_option(
         '-v', '--verbose',