Skip to content

Commit

Permalink
refactor: improve readability and consistency in code
Browse files Browse the repository at this point in the history
- Refactored the log messages to use consistent capitalization and wording.
- Updated log messages in check_glibc.sh, check_permissions.sh, command_backup.sh, command_update_linuxgsm.sh, command_wipe.sh, fix_samp.sh, install_config.sh, and set_dst_config_vars() functions.

feat: add more descriptive log messages

- Added more descriptive log messages to provide clearer information about the actions being performed.
- Updated log messages in check_glibc.sh, check_permissions.sh, command_backup.sh, command_update_linuxgsm.sh, command_wipe.sh, fix_samp.sh, install_config.sh.

fix: correct spelling errors in log messages

- Corrected spelling errors in some of the log messages for better clarity.
- Updated log messages in check_glibc.sh and fix_samp.sh.
  • Loading branch information
dgibbs64 committed Oct 10, 2023
1 parent efee3e3 commit 3d0409f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lgsm/modules/check_glibc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ elif [ "$(printf '%s\n'${glibc}'\n' "${glibcversion}" | sort -V | head -n 1)" !=
echo -e " * glibc installed: ${red}${glibcversion}${default}"
echo -en "\n"
fn_print_information_nl "distro upgrade is required"
fn_script_log_info "distro upgrade is required"
fn_script_log_info "Distro upgrade is required"
fn_sleep_time_5
fi
6 changes: 3 additions & 3 deletions lgsm/modules/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ fn_sys_perm_fix_manually_msg() {
# Attempt to fix /sys related permission errors if sudo is available, exits otherwise.
fn_sys_perm_errors_fix() {
if sudo -n true > /dev/null 2>&1; then
fn_print_dots "Automatically fixing /sys permissions"
fn_script_log_info "Automatically fixing /sys permissions."
fn_print_dots "Fixing /sys permissions"
fn_script_log_info "Fixing /sys permissions."
if [ "${sysdirpermerror}" == "1" ]; then
sudo chmod a+rx "/sys"
fi
Expand All @@ -202,7 +202,7 @@ fn_sys_perm_errors_fix() {
# Show the user how to fix.
fn_sys_perm_fix_manually_msg
else
fn_print_ok_nl "Automatically fixing /sys permissions"
fn_print_ok_nl "Fixing /sys permissions"
fn_script_log_pass "Permissions in /sys fixed"
fi
else
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ fn_backup_compression() {
fn_print_info "A total of ${rootdirduexbackup} will be compressed."
fn_script_log_info "A total of ${rootdirduexbackup} will be compressed: ${backupdir}/${backupname}.tar.gz"
fn_print_dots "Backup (${rootdirduexbackup}) ${backupname}.tar.gz, in progress..."
fn_script_log_info "backup ${rootdirduexbackup} ${backupname}.tar.gz, in progress"
fn_script_log_info "Backup ${rootdirduexbackup} ${backupname}.tar.gz, in progress"
excludedir=$(fn_backup_relpath)

# Check that excludedir is a valid path.
Expand Down
2 changes: 1 addition & 1 deletion lgsm/modules/command_update_linuxgsm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if [ "${script_diff}" != "" ]; then
fi

echo -en "copying ${selfname}...\c"
fn_script_log_info "copying ${selfname}"
fn_script_log_info "Copying ${selfname}"
cp "${tmpdir}/linuxgsm.sh" "${rootdir}/${selfname}"
sed -i "s+shortname=\"core\"+shortname=\"${shortname}\"+g" "${rootdir}/${selfname}"
sed -i "s+gameservername=\"core\"+gameservername=\"${gameservername}\"+g" "${rootdir}/${selfname}"
Expand Down
6 changes: 3 additions & 3 deletions lgsm/modules/command_wipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn_wipe_files() {
if [ -n "${serverwipe}" ] || [ -n "${mapwipe}" ]; then
if [ -n "$(find "${serveridentitydir}" -type f -name "*.map")" ]; then
echo -en "removing .map file(s)..."
fn_script_log_info "removing *.map file(s)"
fn_script_log_info "Removing *.map file(s)"
fn_sleep_time
find "${serveridentitydir:?}" -type f -name "*.map" -printf "%f\n" >> "${lgsmlog}"
find "${serveridentitydir:?}" -type f -name "*.map" -delete | tee -a "${lgsmlog}"
Expand All @@ -45,7 +45,7 @@ fn_wipe_files() {
if [ -n "${serverwipe}" ] || [ -n "${mapwipe}" ]; then
if [ -n "$(find "${serveridentitydir}" -type f -name "*.sav*")" ]; then
echo -en "removing .sav file(s)..."
fn_script_log_info "removing .sav file(s)"
fn_script_log_info "Removing .sav file(s)"
fn_sleep_time
find "${serveridentitydir:?}" -type f -name "*.sav*" -printf "%f\n" >> "${lgsmlog}"
find "${serveridentitydir:?}" -type f -name "*.sav*" -delete
Expand All @@ -61,7 +61,7 @@ fn_wipe_files() {
if [ -n "${serverwipe}" ]; then
if [ -n "$(find "${serveridentitydir}" -type f ! -name 'player.tokens.db' -name "*.db")" ]; then
echo -en "removing .db file(s)..."
fn_script_log_info "removing .db file(s)"
fn_script_log_info "Removing .db file(s)"
fn_sleep_time
find "${serveridentitydir:?}" -type f ! -name 'player.tokens.db' -name "*.db" -printf "%f\n" >> "${lgsmlog}"
find "${serveridentitydir:?}" -type f ! -name 'player.tokens.db' -name "*.db" -delete
Expand Down
4 changes: 2 additions & 2 deletions lgsm/modules/fix_samp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ -f "${servercfgfullpath}" ]; then
if [ "${currentpass}" == "${defaultpass}" ]; then
fixname="change default rcon password"
fn_fix_msg_start
fn_script_log_info "changing rcon/admin password."
fn_script_log_info "Changing rcon/admin password."
randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
rconpass="admin${randomstring}"
sed -i "s/rcon_password changeme/rcon_password ${rconpass}/g" "${servercfgfullpath}"
Expand All @@ -27,7 +27,7 @@ if [ -f "${servercfgfullpath}" ]; then
if [ "${currenthostname}" == "${defaulthostname}" ]; then
fixname="change default hostname"
fn_fix_msg_start
fn_script_log_info "changing default hostname to LinuxGSM"
fn_script_log_info "Changing default hostname to LinuxGSM"
sed -i "s/hostname ${defaulthostname}/hostname LinuxGSM/g" "${servercfgfullpath}"
fn_fix_msg_end
fi
Expand Down
20 changes: 10 additions & 10 deletions lgsm/modules/install_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
fn_check_cfgdir() {
if [ ! -d "${servercfgdir}" ]; then
echo -e "creating ${servercfgdir} config directory."
fn_script_log_info "creating ${servercfgdir} config directory."
fn_script_log_info "Creating ${servercfgdir} config directory."
mkdir -pv "${servercfgdir}"
fi
}
Expand All @@ -38,7 +38,7 @@ fn_default_config_remote() {
for config in "${array_configs[@]}"; do
# every config is copied
echo -e "copying ${config} config file."
fn_script_log_info "copying ${servercfg} config file."
fn_script_log_info "Copying ${servercfg} config file."
if [ "${config}" == "${servercfgdefault}" ]; then
mkdir -p "${servercfgdir}"
cp -nv "${lgsmdir}/config-default/config-game/${config}" "${servercfgfullpath}"
Expand Down Expand Up @@ -82,7 +82,7 @@ fn_set_config_vars() {
servername="LinuxGSM"
rconpass="admin${randomstring}"
echo -e "changing hostname."
fn_script_log_info "changing hostname."
fn_script_log_info "Changing hostname."
fn_sleep_time
# prevents var from being overwritten with the servername.
if grep -q "SERVERNAME=SERVERNAME" "${lgsmdir}/config-default/config-game/${config}" 2> /dev/null; then
Expand All @@ -93,7 +93,7 @@ fn_set_config_vars() {
sed -i "s/SERVERNAME/${servername}/g" "${servercfgfullpath}"
fi
echo -e "changing rcon/admin password."
fn_script_log_info "changing rcon/admin password."
fn_script_log_info "Changing rcon/admin password."
if [ "${shortname}" == "squad" ]; then
sed -i "s/ADMINPASSWORD/${rconpass}/g" "${servercfgdir}/Rcon.cfg"
else
Expand All @@ -112,15 +112,15 @@ fn_set_dst_config_vars() {
## cluster.ini
if grep -Fq "SERVERNAME" "${clustercfgfullpath}"; then
echo -e "changing server name."
fn_script_log_info "changing server name."
fn_script_log_info "Changing server name."
sed -i "s/SERVERNAME/LinuxGSM/g" "${clustercfgfullpath}"
fn_sleep_time
echo -e "changing shard mode."
fn_script_log_info "changing shard mode."
fn_script_log_info "Changing shard mode."
sed -i "s/USESHARDING/${sharding}/g" "${clustercfgfullpath}"
fn_sleep_time
echo -e "randomizing cluster key."
fn_script_log_info "randomizing cluster key."
fn_script_log_info "Randomizing cluster key."
randomstring=$(tr -dc 'A-Za-z0-9_' < /dev/urandom 2> /dev/null | head -c 8 | xargs)
sed -i "s/CLUSTERKEY/${randomstring}/g" "${clustercfgfullpath}"
fn_sleep_time
Expand All @@ -139,18 +139,18 @@ fn_set_dst_config_vars() {
fi

echo -e "changing shard name."
fn_script_log_info "changing shard name."
fn_script_log_info "Changing shard name."
sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
fn_sleep_time
echo -e "changing master setting."
fn_script_log_info "changing master setting."
fn_script_log_info "Changing master setting."
sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
fn_sleep_time

## worldgenoverride.lua
if [ "${cave}" == "true" ]; then
echo -e "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
fn_script_log_info "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
fn_script_log_info "Defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
echo 'return { override_enabled = true, preset = "DST_CAVE", }' > "${servercfgdir}/worldgenoverride.lua"
fi
fn_sleep_time
Expand Down

0 comments on commit 3d0409f

Please sign in to comment.