From cb90ff94adf5958640a3dcdf224b0ce249020703 Mon Sep 17 00:00:00 2001 From: buildplan Date: Fri, 29 Aug 2025 13:48:34 +0100 Subject: [PATCH 1/2] Re-run the script with sudo if not already root --- backup_script.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backup_script.sh b/backup_script.sh index ac91700..d069ef5 100644 --- a/backup_script.sh +++ b/backup_script.sh @@ -1,5 +1,5 @@ #!/bin/bash -# ===================== v0.35 - 2025.08.21 ======================== +# ===================== v0.36 - 2025.08.29 ======================== # # Example backup.conf: # BACKUP_DIRS="/home/user/test/./ /var/www/./" @@ -59,10 +59,12 @@ else C_CYAN='' fi -# Check if the script is being run as root -if (( EUID != 0 )); then - echo "❌ This script must be run as root or with sudo." >&2 - exit 1 +# Re-run the script with sudo if not already root +if [[ $EUID -ne 0 ]]; then + echo -e "${C_BOLD}${C_YELLOW}This script requires root privileges to function correctly.${C_RESET}" + echo -e "${C_YELLOW}Attempting to re-run with sudo. You may be prompted for your password.${C_RESET}" + echo "----------------------------------------------------------------" + exec sudo "$0" "$@" fi # --- Determine script's location to load the config file --- From 76b9c48f32761b6cba49fd19c252f04ea8211c3f Mon Sep 17 00:00:00 2001 From: buildplan Date: Fri, 29 Aug 2025 13:49:46 +0100 Subject: [PATCH 2/2] sha256 for v0.36 --- backup_script.sh.sha256 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup_script.sh.sha256 b/backup_script.sh.sha256 index bc40865..6aeefe4 100644 --- a/backup_script.sh.sha256 +++ b/backup_script.sh.sha256 @@ -1 +1 @@ -4175a7e1000fc6ecf3d94f11758b9d5b5ed86e3a88c0e0b973212a79780d6a8d backup_script.sh +2ce03d52c44801851ab0d17e5f6bea8c21ab59511e54c1131fda0ddcdfa2af1d backup_script.sh