Bläddra i källkod

refactor: improve variable naming and remove unnecessary code duplication

The commit refactors the code in `install_config.sh` to improve variable naming and remove unnecessary code duplication. Specifically, it renames the variables for better clarity and removes redundant lines of code.

refactor: improve installation and configuration process

- Refactored the fix_dst.sh script to keep the shard name in server.ini consistent with the LinuxGSM config.
- Updated install_config.sh to provide clearer messages during the default config download and copy processes.

refactor: update shard name in server.ini

The code has been refactored to update the shard name in the server.ini file. This change ensures that the shard name in the LinuxGSM config matches the one in server.ini.
Daniel Gibbs 2 år sedan
förälder
incheckning
1150b497a0
3 ändrade filer med 19 tillägg och 4 borttagningar
  1. 12 0
      lgsm/modules/fix_dst.sh
  2. 0 1
      lgsm/modules/info_game.sh
  3. 7 3
      lgsm/modules/install_config.sh

+ 12 - 0
lgsm/modules/fix_dst.sh

@@ -15,3 +15,15 @@ if [ -f "/etc/redhat-release" ] && [ ! -f "${serverfiles}/bin/lib32/libcurl-gnut
 	ln -s "/usr/lib/libcurl.so.4" "${serverfiles}/bin/lib32/libcurl-gnutls.so.4"
 	ln -s "/usr/lib/libcurl.so.4" "${serverfiles}/bin/lib32/libcurl-gnutls.so.4"
 	fn_fix_msg_end
 	fn_fix_msg_end
 fi
 fi
+
+# Keeps shard name in server.ini the same as in the LinuxGSM config.
+if [ -f "${servercfgfullpath}" ]; then
+	if [ "$(grep -Ec '^name[[:space:]]*=' "${servercfgfullpath}")" -eq 1 ]; then
+		if [ "$(grep -E '^name[[:space:]]*=' "${servercfgfullpath}" | cut -d '=' -f2 | tr -d '"' | tr -d ' ')" != "${shard}" ]; then
+			fixname="update server.ini shard name"
+			fn_fix_msg_start
+			sed -i -e "s/name[[:space:]]*=.*/name = \"${shard}\"/g" "${servercfgfullpath}"
+			fn_fix_msg_end
+		fi
+	fi
+fi

+ 0 - 1
lgsm/modules/info_game.sh

@@ -435,7 +435,6 @@ fn_info_game_dodr() {
 fn_info_game_dst() {
 fn_info_game_dst() {
 	if [ -f "${servercfgfullpath}" ]; then
 	if [ -f "${servercfgfullpath}" ]; then
 		fn_info_game_ini "port" "server_port" "${servercfgfullpath}"
 		fn_info_game_ini "port" "server_port" "${servercfgfullpath}"
-		fn_info_game_ini "shard" "name" "${servercfgfullpath}"
 		fn_info_game_ini "steamauthport" "authentication_port" "${servercfgfullpath}"
 		fn_info_game_ini "steamauthport" "authentication_port" "${servercfgfullpath}"
 		fn_info_game_ini "steamport" "master_server_port" "${servercfgfullpath}"
 		fn_info_game_ini "steamport" "master_server_port" "${servercfgfullpath}"
 	fi
 	fi

+ 7 - 3
lgsm/modules/install_config.sh

@@ -33,7 +33,7 @@ fn_default_config_remote() {
 	echo -e ""
 	echo -e ""
 	echo -e "${bold}${lightyellow}Downloading ${gamename} Configs${default}"
 	echo -e "${bold}${lightyellow}Downloading ${gamename} Configs${default}"
 	echo -e "${bold}=================================${default}"
 	echo -e "${bold}=================================${default}"
-	echo -e "Default configs are downloaded from:"
+	echo -e "Downloading default configs from:"
 	echo -e ""
 	echo -e ""
 	echo -e "${italic}https://github.com/GameServerManagers/Game-Server-Configs${default}"
 	echo -e "${italic}https://github.com/GameServerManagers/Game-Server-Configs${default}"
 	echo -e ""
 	echo -e ""
@@ -48,8 +48,8 @@ fn_default_config_remote() {
 		if [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then
 		if [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then
 			echo -en "copying config file [ ${italic}${networkcfgfullpath}${default} ]"
 			echo -en "copying config file [ ${italic}${networkcfgfullpath}${default} ]"
 			changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}")
 			changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${config}" "${networkcfgfullpath}")
-		elif [ "${shortname}" == "dst" ] && [ "${config}" == "${clustercfgdefault}" ]; then
-			echo -en "copying config file [ ${italic}${clustercfgdefault}${default} ]"
+		elif [ "${shortname}" == "dst" ] && [ "${config}" == "${clustercfgfullpath}" ]; then
+			echo -en "copying config file [ ${italic}${clustercfgfullpath}${default} ]"
 			changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}")
 			changes+=$(cp -nv "${lgsmdir}/config-default/config-game/${clustercfgdefault}" "${clustercfgfullpath}")
 		else
 		else
 			echo -en "copying config file [ ${italic}${servercfgdir}/${config}${default} ]"
 			echo -en "copying config file [ ${italic}${servercfgdir}/${config}${default} ]"
@@ -70,6 +70,10 @@ fn_default_config_remote() {
 
 
 # Copys local default config to server config location.
 # Copys local default config to server config location.
 fn_default_config_local() {
 fn_default_config_local() {
+	echo -e ""
+	echo -e "${bold}${lightyellow}Copying ${gamename} Configs${default}"
+	echo -e "${bold}=================================${default}"
+	echo -e "Copying default configs."
 	fn_check_cfgdir
 	fn_check_cfgdir
 	echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]"
 	echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]"
 	cp -n "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
 	cp -n "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"