Просмотр исходного кода

fix(samp): fix config change after installation (#3119)

Christian 5 лет назад
Родитель
Сommit
b1d866d023

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -430,6 +430,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 }
 
+fix_samp.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 fix_sdtd.sh(){
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function

+ 3 - 1
lgsm/functions/fix.sh

@@ -91,7 +91,7 @@ fi
 
 # Fixes that are run on install only.
 if [ "${commandname}" == "INSTALL" ]; then
-		if [ "${shortname}" == "av" ]||[ "${shortname}" == "cmw" ]||[ "${shortname}" == "kf" ]||[ "${shortname}" == "kf2" ]||[ "${shortname}" == "onset" ]||[ "${shortname}" == "ro" ]||[ "${shortname}" == "ut2k4" ]||[ "${shortname}" == "ut" ]||[ "${shortname}" == "ut3" ]; then
+		if [ "${shortname}" == "av" ]||[ "${shortname}" == "cmw" ]||[ "${shortname}" == "kf" ]||[ "${shortname}" == "kf2" ]||[ "${shortname}" == "onset" ]||[ "${shortname}" == "ro" ]||[ "${shortname}" == "samp" ]||[ "${shortname}" == "ut2k4" ]||[ "${shortname}" == "ut" ]||[ "${shortname}" == "ut3" ]; then
 			echo -e ""
 			echo -e "Applying Post-Install Fixes"
 			echo -e "================================="
@@ -105,6 +105,8 @@ if [ "${commandname}" == "INSTALL" ]; then
 				fix_kf2.sh
 			elif [ "${shortname}" == "ro" ]; then
 				fix_ro.sh
+			elif [ "${shortname}" == "samp" ]; then
+				fix_samp.sh
 			elif [ "${shortname}" == "ut2k4" ]; then
 				fix_ut2k4.sh
 			elif [ "${shortname}" == "ut" ]; then

+ 33 - 0
lgsm/functions/fix_samp.sh

@@ -0,0 +1,33 @@
+#!/bin/bash
+# LinuxGSM fix_sfc.sh function
+# Author: Christian Birk
+# Website: https://linuxgsm.com
+# Description: Resolves issue that the default rcon password is not changed
+
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+if [ -f "${servercfgfullpath}" ]; then
+	# check if default password is set "changeme"
+	currentpass=$(grep -E "^rcon_password" "${servercfgfullpath}" | sed 's/^rcon_password //' )
+	defaultpass="changeme"
+	# check if default password is set
+	if [ "${currentpass}" == "${defaultpass}" ]; then
+		fixname="change default rcon password"
+		fn_fix_msg_start
+		fn_script_log_info "changing rcon/admin password."
+	       	random=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs)
+		rconpass="admin${random}"
+		sed -i "s/rcon_password changeme/rcon_password ${rconpass}/g" "${servercfgfullpath}"
+		fn_fix_msg_end
+	fi
+	# check if the hostname is the default name
+	currenthostname=$(grep -E "^hostname" "${servercfgfullpath}" | sed 's/^hostname //')
+	defaulthostname="SA-MP 0.3 Server"
+	if [ "${currenthostname}" == "${defaulthostname}" ]; then
+		fixname="change default hostname"
+		fn_fix_msg_start
+		fn_script_log_info "changing default hostname to LinuxGSM"
+		sed -i "s/hostname ${defaulthostname}/hostname LinuxGSM/g" "${servercfgfullpath}"
+		fn_fix_msg_end
+	fi
+fi

+ 0 - 7
lgsm/functions/install_config.sh

@@ -660,13 +660,6 @@ elif [ "${shortname}" == "rust" ]; then
 	fn_fetch_default_config
 	fn_default_config_remote
 	fn_list_config_locations
-elif [ "${shortname}" == "samp" ]; then
-	gamedirname="SanAndreasMultiplayer"
-	array_configs+=( server.cfg )
-	fn_fetch_default_config
-	fn_default_config_remote
-	fn_set_config_vars
-	fn_list_config_locations
 elif [ "${shortname}" == "sol" ]; then
 	gamedirname="Soldat"
 	array_configs+=( soldat.ini )