Skip to content

Commit

Permalink
refactor: improve variable naming and remove unnecessary code duplica…
Browse files Browse the repository at this point in the history
…tion

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.
  • Loading branch information
dgibbs64 committed Sep 30, 2023
1 parent d9658ae commit 1150b49
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lgsm/modules/fix_dst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
fn_fix_msg_end
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
1 change: 0 additions & 1 deletion lgsm/modules/info_game.sh
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ fn_info_game_dodr() {
fn_info_game_dst() {
if [ -f "${servercfgfullpath}" ]; then
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 "steamport" "master_server_port" "${servercfgfullpath}"
fi
Expand Down
10 changes: 7 additions & 3 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn_default_config_remote() {
echo -e ""
echo -e "${bold}${lightyellow}Downloading ${gamename} Configs${default}"
echo -e "${bold}=================================${default}"
echo -e "Default configs are downloaded from:"
echo -e "Downloading default configs from:"
echo -e ""
echo -e "${italic}https://github.com/GameServerManagers/Game-Server-Configs${default}"
echo -e ""
Expand All @@ -48,8 +48,8 @@ fn_default_config_remote() {
if [ "${shortname}" == "arma3" ] && [ "${config}" == "${networkcfgdefault}" ]; then
echo -en "copying config file [ ${italic}${networkcfgfullpath}${default} ]"
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}")
else
echo -en "copying config file [ ${italic}${servercfgdir}/${config}${default} ]"
Expand All @@ -70,6 +70,10 @@ fn_default_config_remote() {

# Copys local default config to server config location.
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
echo -en "copying config file [ ${italic}${servercfgdefault}${default} ]"
cp -n "${servercfgdir}/${servercfgdefault}" "${servercfgfullpath}"
Expand Down

0 comments on commit 1150b49

Please sign in to comment.