Browse Source

Fixes glibc check and mod selection logic

Corrects glibc version comparison to properly handle version strings.

Improves mod installation and removal by validating user input
against available options, providing a more robust selection process.
This prevents errors caused by invalid mod names and enhances the
user experience.

Updates arithmetic expression syntax for better compatibility.
pull/4854/head
Daniel Gibbs 5 months ago
parent
commit
b3d2700bdd
Failed to extract signature
  1. 2
      lgsm/modules/check_glibc.sh
  2. 2
      lgsm/modules/command_debug.sh
  3. 8
      lgsm/modules/command_dev_query_raw.sh
  4. 23
      lgsm/modules/command_mods_install.sh
  5. 21
      lgsm/modules/command_mods_remove.sh

2
lgsm/modules/check_glibc.sh

@ -17,7 +17,7 @@ elif [ -z "${glibc}" ]; then
fn_print_error_nl "Checking glibc: requirement unknown" fn_print_error_nl "Checking glibc: requirement unknown"
fn_script_log_error "Checking glibc: requirement unknown" fn_script_log_error "Checking glibc: requirement unknown"
fn_sleep_time_5 fn_sleep_time_5
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
fn_print_dots "Checking glibc" fn_print_dots "Checking glibc"
fn_print_error_nl "Checking glibc: requirements not met" fn_print_error_nl "Checking glibc: requirements not met"
fn_script_log_error "Checking glibc: requirements not met" fn_script_log_error "Checking glibc: requirements not met"

2
lgsm/modules/command_debug.sh

@ -49,7 +49,7 @@ if [ -n "${glibc}" ]; then
: :
elif [ -z "${glibc}" ]; then elif [ -z "${glibc}" ]; then
echo -e "${lightblue}glibc required:\t${red}UNKNOWN${default}" 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})" echo -e "${lightblue}glibc required:\t${red}${glibc} ${default}(${red}distro glibc ${glibcversion} too old${default})"
else else
echo -e "${lightblue}glibc required:\t${green}${glibc}${default}" echo -e "${lightblue}glibc required:\t${green}${glibc}${default}"

8
lgsm/modules/command_dev_query_raw.sh

@ -249,9 +249,9 @@ echo -e "${bold}${lightyellow}Query Port (${queryport}) - TCP Output${default}"
fn_messages_separator fn_messages_separator
echo -e "" echo -e ""
for queryip in "${queryips[@]}"; do for queryip in "${queryips[@]}"; do
echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}''${default}" echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'\"${queryip}\"'/'\"${queryport}\"''${default}"
echo -e "" echo -e ""
timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${queryport}'' timeout 3 bash -c 'exec 3<> /dev/tcp/'"${queryip}"'/'"${queryport}"''
querystatus="$?" querystatus="$?"
echo -e "" echo -e ""
if [ "${querystatus}" == "0" ]; then if [ "${querystatus}" == "0" ]; then
@ -268,9 +268,9 @@ echo -e "${lightgreen}TCP Raw Output${default}"
fn_messages_separator fn_messages_separator
echo -e "" echo -e ""
for queryip in "${queryips[@]}"; do for queryip in "${queryips[@]}"; do
echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}''${default}" echo -e "${italic}bash -c 'exec 3<> /dev/tcp/'\"${queryip}\"'/'\"${port}\"''${default}"
echo -e "" echo -e ""
timeout 3 bash -c 'exec 3<> /dev/tcp/'${queryip}'/'${port}'' timeout 3 bash -c 'exec 3<> /dev/tcp/'"${queryip}"'/'"${port}"''
querystatus="$?" querystatus="$?"
echo -e "" echo -e ""
if [ "${querystatus}" == "0" ]; then if [ "${querystatus}" == "0" ]; then

23
lgsm/modules/command_mods_install.sh

@ -47,7 +47,7 @@ while [ "${compatiblemodslistindex}" -lt "${#compatiblemodslist[@]}" ]; do
echo -e "${displayedmodname} - ${displayedmoddescription} - ${displayedmodsite}" echo -e "${displayedmodname} - ${displayedmoddescription} - ${displayedmodsite}"
echo -e " * ${cyan}${displayedmodcommand}${default}" echo -e " * ${cyan}${displayedmodcommand}${default}"
# Increment index from the amount of values we just displayed. # Increment index from the amount of values we just displayed.
let "compatiblemodslistindex+=4" ((compatiblemodslistindex += 4))
((totalmodsavailable++)) ((totalmodsavailable++))
done done
@ -61,16 +61,29 @@ fn_script_log_info "${totalmodsavailable} addons/mods are available for install"
## User selects a mod. ## User selects a mod.
echo -e "" echo -e ""
while [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; do
while :; do
echo -en "Enter an ${cyan}addon/mod${default} to ${green}install${default} (or exit to abort): " echo -en "Enter an ${cyan}addon/mod${default} to ${green}install${default} (or exit to abort): "
read -r usermodselect read -r usermodselect
# Exit if user says exit or abort. # Exit if user says exit or abort.
if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then
core_exit.sh core_exit.sh
# Supplementary output upon invalid user input.
elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
fi fi
validselection=0
for availablemodcommand in "${availablemodscommands[@]}"; do
if [ "${availablemodcommand}" == "${usermodselect}" ]; then
validselection=1
break
fi
done
if [ "${validselection}" -eq 1 ]; then
break
fi
# Supplementary output upon invalid user input.
fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
done done
# Get mod info. # Get mod info.
currentmod="${usermodselect}" currentmod="${usermodselect}"

21
lgsm/modules/command_mods_remove.sh

@ -32,16 +32,29 @@ done
echo -e "" echo -e ""
# Keep prompting as long as the user input doesn't correspond to an available mod. # Keep prompting as long as the user input doesn't correspond to an available mod.
while [[ ! " ${installedmodslist[@]} " =~ " ${usermodselect} " ]]; do
while :; do
echo -en "Enter an ${cyan}addon/mod${default} to ${red}remove${default} (or exit to abort): " echo -en "Enter an ${cyan}addon/mod${default} to ${red}remove${default} (or exit to abort): "
read -r usermodselect read -r usermodselect
# Exit if user says exit or abort. # Exit if user says exit or abort.
if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then if [ "${usermodselect}" == "exit" ] || [ "${usermodselect}" == "abort" ]; then
core_exit.sh core_exit.sh
# Supplementary output upon invalid user input.
elif [[ ! " ${availablemodscommands[@]} " =~ " ${usermodselect} " ]]; then
fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
fi fi
validselection=0
for installedmodcommand in "${installedmodslist[@]}"; do
if [ "${installedmodcommand}" == "${usermodselect}" ]; then
validselection=1
break
fi
done
if [ "${validselection}" -eq 1 ]; then
break
fi
# Supplementary output upon invalid user input.
fn_print_error2_nl "${usermodselect} is not a valid addon/mod."
done done
fn_print_warning_nl "You are about to remove ${cyan}${usermodselect}${default}." fn_print_warning_nl "You are about to remove ${cyan}${usermodselect}${default}."

Loading…
Cancel
Save