From 2d713d5f9ae7bb550ee51d6a553ed93e234909a9 Mon Sep 17 00:00:00 2001 From: wagesj45 Date: Fri, 25 Jul 2025 17:51:41 -0500 Subject: [PATCH] Update setup.sh --- setup.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index e679636..c69e64e 100644 --- a/setup.sh +++ b/setup.sh @@ -11,16 +11,15 @@ set -euo pipefail DEFAULT_SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoxUu/nC1C03LvxIhCMzyMu7CAfIp9+Rbt4vmx8q3ER1EPP2K53fnjUmOijC4YY2jgPHHXEoTgC6Rlcrl3eYFoqbhRc4nweN6Z3LXRghmfNXVmMRSouXEMWhxhPjk9r+w9+3E9+6p9X9YtQu+u76ArWcY9MgvD6Awvo66hSFgkzeXzgCcKkTdMkSOUwuHfm8Ja9TzSIUfnB6SAiKWLIejDntYJHSKoqsSzsovYRUc/W+al09MfIMWwN9vJwk7WM7O3E+YPL5Zcpmr4jaoFULf6hWtgn688nDU+4V0POIzRNnk4EPH5qo+AmSL7MwQ0Bh7z5EgiAJiAryrT/GnU41w7 rsa-key-20240415" ############################################################################### -# Early root escalation +# Ensure running as root # ############################################################################### if [[ $EUID -ne 0 ]]; then if command -v whiptail &>/dev/null; then - PW=$(whiptail --passwordbox "Root privileges required.\nEnter root password:" 10 60 3>&1 1>&2 2>&3) || exit 1 - exec su root -c "bash -s -- \"$@\"" <<<"$PW" + whiptail --title "Error" --msgbox "This script must be run as root." 10 60 else - echo "Root privileges required; re-running under su..." - exec su -c "bash -s -- \"$@\"" root + echo "Error: This script must be run as root." >&2 fi + exit 1 fi ############################################################################### @@ -164,7 +163,7 @@ for host in "${CIFS_HOSTS[@]}"; do grep -q "${host}.wageshouse" /etc/fstab || printf "# $TEMPLATE\n" "username" "password" >> /etc/fstab fi done -if ! mount -a 2>>"$LOGFILE"; then msg "⚠️ Some CIFS mounts failed. Re‑run the script to correct credentials."; fi +if ! mount -a 2>>"$LOGFILE"; then msg "⚠️ Some CIFS mounts failed. Re-run the script to correct credentials."; fi ############################################################################### # Summary #