From d015c0c0eb64edb425508e53beeb87172d5359c3 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sat, 16 May 2026 04:07:30 -0400 Subject: [PATCH] fixed a few bugs, added in a few safety checks. --- .includes/convert-to-server.sh | 26 ++++++++++++++++++++++++++ .includes/eeprom.sh | 10 ++++++++++ .includes/timezone.sh | 4 ++-- .includes/ui.sh | 6 +++--- 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.includes/convert-to-server.sh b/.includes/convert-to-server.sh index fe246a7..5128f8a 100755 --- a/.includes/convert-to-server.sh +++ b/.includes/convert-to-server.sh @@ -33,6 +33,16 @@ if ! [[ -s ~/.ssh/authorized_keys ]]; then exit 1 fi chmod 600 ~/.ssh/authorized_keys +# Validate the authorized_keys file actually contains a valid SSH public key +if ! grep -qE "^(ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp(256|384|521)|sk-(ssh-ed25519|ecdsa-sha2-nistp256))" ~/.ssh/authorized_keys; then + dialog --backtitle "Configure Stormux" \ + --msgbox "The file ~/.ssh/authorized_keys does not appear to contain a valid SSH public key. + +Please make sure you uploaded your public key (not your private key). A public key typically starts with something like ssh-ed25519 or ssh-rsa. + +Upload the correct key and try again." -1 -1 --stdout + exit 1 +fi sshPort="22" sshPortInput="$(dialog --backtitle "Configure Stormux" \ --inputbox "Enter a custom SSH port (1-65535) or leave blank to keep 22." -1 -1 --stdout || true)" @@ -49,6 +59,22 @@ PasswordAuthentication no KbdInteractiveAuthentication no EOF +# Check for stale pacman database lock before removal +if [[ -f /var/lib/pacman/db.lck ]]; then + if dialog --backtitle "Configure Stormux" \ + --yesno "A pacman database lock was found at /var/lib/pacman/db.lck. + +This usually means a previous package operation did not finish cleanly. Removing it is generally safe if no other package manager is currently running. + +Would you like to remove the lock and continue?" -1 -1 --stdout; then + sudo "${sudoFlags[@]}" rm -f /var/lib/pacman/db.lck + else + dialog --backtitle "Configure Stormux" \ + --msgbox "Cannot safely remove packages while the pacman database is locked. Exiting." -1 -1 --stdout + exit 1 + fi +fi + for packageName in \ alsa-firmware \ alsa-utils \ diff --git a/.includes/eeprom.sh b/.includes/eeprom.sh index ade9fd3..3c1db38 100644 --- a/.includes/eeprom.sh +++ b/.includes/eeprom.sh @@ -10,6 +10,16 @@ updateEeprom() { local piModel piModel=$(LC_ALL=C tr -d '\000' < /sys/firmware/devicetree/base/model 2>/dev/null) + + # Guard against non-Pi hardware + if [[ -z "$piModel" ]] || [[ "$piModel" != *"Raspberry Pi"* ]]; then + msgbox "This option is intended for Raspberry Pi hardware only. + +Detected model: ${piModel:-unknown} + +If you are not running on a Raspberry Pi, this option will not work correctly." + return 1 + fi # Determine which EEPROM package is needed local eepromPackage="" if [[ "$piModel" == *"Raspberry Pi 5"* ]] || [[ "$piModel" == *"Raspberry Pi 500"* ]]; then diff --git a/.includes/timezone.sh b/.includes/timezone.sh index f48e529..c055cfe 100755 --- a/.includes/timezone.sh +++ b/.includes/timezone.sh @@ -9,7 +9,7 @@ mapfile -t regions < <(timedatectl --no-pager list-timezones | cut -d '/' -f1 | region=$(dialog --backtitle "Please select your Region" \ --no-tags \ --menu "Use up and down arrows or page-up and page-down to navigate the list, and press 'Enter' to make your selection." 0 0 0 \ - $(for i in ${regions[@]} ; do echo "$i";echo "$i";done) --stdout) + "$(for i in "${regions[@]}" ; do echo "$i";echo "$i";done)" --stdout) mapfile -t cities < <(timedatectl --no-pager list-timezones | grep "$region" | cut -d '/' -f2 | sort -u) @@ -18,7 +18,7 @@ mapfile -t cities < <(timedatectl --no-pager list-timezones | grep "$region" | c city=$(dialog --backtitle "Please select a city near you" \ --no-tags \ --menu "Use up and down arrow or page-up and page-down to navigate the list." 0 0 10 \ - $(for i in ${cities[@]} ; do echo "$i";echo "$i";done) --stdout) + "$(for i in "${cities[@]}" ; do echo "$i";echo "$i";done)" --stdout) # Set the timezone if [[ -f /etc/localtime ]]; then diff --git a/.includes/ui.sh b/.includes/ui.sh index 34e5494..32b5f1d 100755 --- a/.includes/ui.sh +++ b/.includes/ui.sh @@ -55,9 +55,9 @@ infobox() { # Shows the provided message on the screen with no buttons. local timeout=3 dialog --infobox "$*" 0 0 - read -n1 -t $timeout continue + read -n1 -t $timeout # Clear any keypresses from the buffer - read -t 0.01 continue + read -t 0.01 } yesno() { @@ -91,5 +91,5 @@ show_doc() { # Displays file in w3m using pager mode # Args: path to file. # Returns: none. - fold -sw $cols "$1" | w3m -o keymap_file=~/.w3m/pager + fold -sw "$COLUMNS" "$1" | w3m -o keymap_file=~/.w3m/pager }