Browse Source

Addresses various script improvements

Addresses multiple improvements across various scripts:

- Fixes Valheim unstripped_corlib override by commenting out the lines in the config files.
- Improves process identification for source and goldsrc engines using `pgrep`.
- Enhances backup file identification using `find` with `-maxdepth 1` and `-type f`.
- Fixes glibc version comparison logic in multiple files.
- Improves UT2K4 key installation script by using printf for writing the key to the file.
- Corrects the mod info extraction logic to correctly identify mod entries.
- Improves amxmodx file installation/removal logic to prevent duplicate entries.
- Fixes server info retrieval to handle spaces in the server list.

Relates to #4696
pull/4854/head
Daniel Gibbs 4 months ago
parent
commit
cb3a09211b
Failed to extract signature
  1. 4
      lgsm/modules/fix_vh.sh
  2. 12
      lgsm/modules/info_distro.sh
  3. 2
      lgsm/modules/info_messages.sh
  4. 2
      lgsm/modules/install_ut2k4_key.sh
  5. 29
      lgsm/modules/mods_core.sh
  6. 3
      linuxgsm.sh

4
lgsm/modules/fix_vh.sh

@ -21,8 +21,8 @@ if [ -f "${modsinstalledlistfullpath}" ]; then
rm -rf "${serverfiles}/unstripped_corlib"
fi
sed -i "s/^dllSearchPathOverride=unstripped_corlib/# &/" "${serverfiles}/doorstop_config.ini"
sed -i "s/^export DOORSTOP_CORLIB_OVERRIDE_PATH="$BASEDIR\/unstripped_corlib"/# &/" "${serverfiles}/start_game_bepinex.sh"
sed -i "s/^export DOORSTOP_CORLIB_OVERRIDE_PATH="${VALHEIM_PLUS_PATH}\/unstripped_corlib"/# &/" "${serverfiles}/start_server_bepinex.sh"
sed -i "s|^export DOORSTOP_CORLIB_OVERRIDE_PATH=\"\\\$BASEDIR/unstripped_corlib\"|# &|" "${serverfiles}/start_game_bepinex.sh"
sed -i "s|^export DOORSTOP_CORLIB_OVERRIDE_PATH=\"\\\${VALHEIM_PLUS_PATH}/unstripped_corlib\"|# &|" "${serverfiles}/start_server_bepinex.sh"
fi
# special exports for BepInEx if installed
if grep -qE "^bepinexvh" "${modsinstalledlistfullpath}"; then

12
lgsm/modules/info_distro.sh

@ -13,9 +13,9 @@ moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ "${status}" == "1" ]; then
gameserverpid="$(tmux -L "${socketname}" list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $NF}')"
if [ "${engine}" == "source" ]; then
srcdslinuxpid="$(ps -ef | grep -v grep | grep "${gameserverpid}" | grep srcds_linux | awk '{print $2}')"
srcdslinuxpid="$(pgrep -P "${gameserverpid}" -x srcds_linux 2> /dev/null | head -n 1)"
elif [ "${engine}" == "goldsrc" ]; then
hldslinuxpid="$(ps -ef | grep -v grep | grep "${gameserverpid}" | grep hlds_linux | awk '{print $2}')"
hldslinuxpid="$(pgrep -P "${gameserverpid}" -x hlds_linux 2> /dev/null | head -n 1)"
fi
fi
### Distro information
@ -252,11 +252,11 @@ if [ -d "${backupdir}" ]; then
backupcount=0
# If there are backups in backup dir.
if [ "$(find "${backupdir}" -name "*.tar.*" | wc -l)" -ne "0" ]; then
if [ "$(find "${backupdir}" -maxdepth 1 -type f -name "*.tar.*" | wc -l)" -ne "0" ]; then
# number of backups.
backupcount="$(find "${backupdir}"/*.tar.* | wc -l)" # integer
backupcount="$(find "${backupdir}" -maxdepth 1 -type f -name "*.tar.*" | wc -l)" # integer
# most recent backup.
lastbackup="$(ls -1t "${backupdir}"/*.tar.* | head -1)" # string
lastbackup="$(find "${backupdir}" -maxdepth 1 -type f -name "*.tar.*" -printf '%T@ %p\n' 2> /dev/null | sort -nr | head -n 1 | cut -d' ' -f2-)" # string
# date of most recent backup.
lastbackupdate="$(date -r "${lastbackup}")" # string
# no of days since last backup.
@ -272,7 +272,7 @@ netlink=$(${ethtoolcommand} "${netint}" 2> /dev/null | grep Speed | awk '{print
# Sets the SteamCMD glibc requirement if the game server requirement is less or not required.
if [ "${appid}" ]; then
if [ "${glibc}" = "null" ] || [ -z "${glibc}" ] || [ "$(printf '%s\n'${glibc}'\n' "2.14" | sort -V | head -n 1)" != "2.14" ]; then
if [ "${glibc}" = "null" ] || [ -z "${glibc}" ] || [ "$(printf '%s\n' "${glibc}" "2.14" | sort -V | head -n 1)" != "2.14" ]; then
glibc="2.14"
fi
fi

2
lgsm/modules/info_messages.sh

@ -578,7 +578,7 @@ fn_info_messages_script() {
:
elif [ -z "${glibc}" ]; then
echo -e "${lightblue}glibc required:\t${red}UNKNOWN${default}"
elif [ "$(printf '%s\n'${glibc}'\n' ${glibcversion} | sort -V | head -n 1)" != "${glibc}" ]; then
elif [ "$(printf '%s\n' "${glibc}" "${glibcversion}" | sort -V | head -n 1)" != "${glibc}" ]; then
echo -e "${lightblue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
else
echo -e "${lightblue}glibc required:\t${green}${glibc}${default}"

2
lgsm/modules/install_ut2k4_key.sh

@ -18,7 +18,7 @@ if [ -z "${autoinstall}" ]; then
echo -e "Once you have the key enter it below"
echo -n "KEY: "
read -r CODE
echo -e ""\""CDKey"\""="\""${CODE}"\""" > "${systemdir}/cdkey"
printf '"CDKey"="%s"\n' "${CODE}" > "${systemdir}/cdkey"
if [ -f "${systemdir}/cdkey" ]; then
fn_script_log_info "UT2K4 Server CD Key created"
fi

29
lgsm/modules/mods_core.sh

@ -197,14 +197,15 @@ fn_mod_get_info() {
# Variable to know when job is done.
modinfocommand="0"
# Find entry in global array.
for ((index = 0; index <= ${#mods_global_array[@]}; index++)); do
for ((index = 0; index < ${#mods_global_array[@]}; index++)); do
# When entry is found.
if [ "${mods_global_array[index]}" == "${currentmod}" ]; then
# Go back to the previous "MOD" separator.
for ((index = index; index <= ${#mods_global_array[@]}; index--)); do
for ((index_search = index; index_search >= 0; index_search--)); do
# When "MOD" is found.
if [ "${mods_global_array[index]}" == "MOD" ]; then
if [ "${mods_global_array[index_search]}" == "MOD" ]; then
# Get info.
index=${index_search}
fn_mods_define
modinfocommand="1"
break
@ -331,7 +332,7 @@ fn_compatible_mod_engines() {
# How many engines we need to test.
enginesamount=$(echo -e "${modengines}" | awk -F ';' '{ print NF }')
# Test all subvalue of "modengines" using the ";" separator.
for ((gamevarindex = 1; gamevarindex < ${enginesamount}; gamevarindex++)); do
for ((gamevarindex = 1; gamevarindex < enginesamount; gamevarindex++)); do
# Put current engine name into modtest variable.
enginemodtest=$(echo -e "${modengines}" | awk -F ';' -v x=${gamevarindex} '{ print $x }')
# If engine name matches.
@ -472,7 +473,7 @@ fn_mods_check_installed() {
# Count installed mods.
fn_mods_count_installed
# If no mods are found.
if [ ${installedmodscount} -eq 0 ]; then
if [ "${installedmodscount}" -eq 0 ]; then
echo -e ""
fn_print_failure_nl "No installed mods or addons were found"
echo -e " * Install mods using LinuxGSM first with: ./${selfname} mods-install"
@ -689,13 +690,9 @@ fn_mod_install_amxmodx_file() {
# since it does exist, is the entry already in plugins.ini
logentry="line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) inserted into ${modinstalldir}/addons/metamod/plugins.ini"
echo -en "adding amxmodx_mm_i386.so in plugins.ini..."
grep -q "amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
if ! grep -q "amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"; then
# file exists but the entry does not, let's add it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
if ! echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" >> "${modinstalldir}/addons/metamod/plugins.ini"; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
else
@ -705,9 +702,7 @@ fn_mod_install_amxmodx_file() {
fi
else
# create new file and add the mod to it
echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > "${modinstalldir}/addons/metamod/plugins.ini"
exitcode=$?
if [ "${exitcode}" -ne 0 ]; then
if ! echo "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" > "${modinstalldir}/addons/metamod/plugins.ini"; then
fn_script_log_fail "${logentry}"
fn_print_fail_eol_nl
core_exit.sh
@ -723,10 +718,8 @@ fn_mod_remove_amxmodx_file() {
# since it does exist, is the entry already in plugins.ini
logentry="line (linux addons/amxmodx/dlls/amxmodx_mm_i386.so) removed from ${modinstalldir}/addons/metamod/plugins.ini"
echo -en "removing amxmodx_mm_i386.so in plugins.ini..."
grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"
# iIs it found? If so remove it and clean up
exitcode=$?
if [ "${exitcode}" -eq 0 ]; then
# is it found? If so remove it and clean up
if grep -q "linux addons/amxmodx/dlls/amxmodx_mm_i386.so" "${modinstalldir}/addons/metamod/plugins.ini"; then
# delete the line we inserted
sed -i '/linux addons\/amxmodx\/dlls\/amxmodx_mm_i386.so/d' "${modinstalldir}/addons/metamod/plugins.ini"
# remove empty lines

3
linuxgsm.sh

@ -330,7 +330,8 @@ fn_install_menu() {
# Gets server info from serverlist.csv and puts in to array.
fn_server_info() {
IFS=","
server_info_array=($(grep -aw "${userinput}" "${serverlist}"))
server_info_line="$(grep -aw "${userinput}" "${serverlist}" | head -n 1)"
read -r -a server_info_array <<< "${server_info_line}"
shortname="${server_info_array[0]}" # csgo
gameservername="${server_info_array[1]}" # csgoserver
gamename="${server_info_array[2]}" # Counter Strike: Global Offensive

Loading…
Cancel
Save