fixed a few bugs, added in a few safety checks.

This commit is contained in:
Storm Dragon
2026-05-16 04:07:30 -04:00
parent 770df26b19
commit d015c0c0eb
4 changed files with 41 additions and 5 deletions
+26
View File
@@ -33,6 +33,16 @@ if ! [[ -s ~/.ssh/authorized_keys ]]; then
exit 1 exit 1
fi fi
chmod 600 ~/.ssh/authorized_keys 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" sshPort="22"
sshPortInput="$(dialog --backtitle "Configure Stormux" \ sshPortInput="$(dialog --backtitle "Configure Stormux" \
--inputbox "Enter a custom SSH port (1-65535) or leave blank to keep 22." -1 -1 --stdout || true)" --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 KbdInteractiveAuthentication no
EOF 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 \ for packageName in \
alsa-firmware \ alsa-firmware \
alsa-utils \ alsa-utils \
+10
View File
@@ -10,6 +10,16 @@ updateEeprom() {
local piModel local piModel
piModel=$(LC_ALL=C tr -d '\000' < /sys/firmware/devicetree/base/model 2>/dev/null) 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 # Determine which EEPROM package is needed
local eepromPackage="" local eepromPackage=""
if [[ "$piModel" == *"Raspberry Pi 5"* ]] || [[ "$piModel" == *"Raspberry Pi 500"* ]]; then if [[ "$piModel" == *"Raspberry Pi 5"* ]] || [[ "$piModel" == *"Raspberry Pi 500"* ]]; then
+2 -2
View File
@@ -9,7 +9,7 @@ mapfile -t regions < <(timedatectl --no-pager list-timezones | cut -d '/' -f1 |
region=$(dialog --backtitle "Please select your Region" \ region=$(dialog --backtitle "Please select your Region" \
--no-tags \ --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 \ --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) 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" \ city=$(dialog --backtitle "Please select a city near you" \
--no-tags \ --no-tags \
--menu "Use up and down arrow or page-up and page-down to navigate the list." 0 0 10 \ --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 # Set the timezone
if [[ -f /etc/localtime ]]; then if [[ -f /etc/localtime ]]; then
+3 -3
View File
@@ -55,9 +55,9 @@ infobox() {
# Shows the provided message on the screen with no buttons. # Shows the provided message on the screen with no buttons.
local timeout=3 local timeout=3
dialog --infobox "$*" 0 0 dialog --infobox "$*" 0 0
read -n1 -t $timeout continue read -n1 -t $timeout
# Clear any keypresses from the buffer # Clear any keypresses from the buffer
read -t 0.01 continue read -t 0.01
} }
yesno() { yesno() {
@@ -91,5 +91,5 @@ show_doc() {
# Displays file in w3m using pager mode # Displays file in w3m using pager mode
# Args: path to file. # Args: path to file.
# Returns: none. # Returns: none.
fold -sw $cols "$1" | w3m -o keymap_file=~/.w3m/pager fold -sw "$COLUMNS" "$1" | w3m -o keymap_file=~/.w3m/pager
} }