File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
2- # ===================== v0.35 - 2025.08.21 ========================
2+ # ===================== v0.36 - 2025.08.29 ========================
33#
44# Example backup.conf:
55# BACKUP_DIRS="/home/user/test/./ /var/www/./"
5959 C_CYAN=' '
6060fi
6161
62- # Check if the script is being run as root
63- if (( EUID != 0 )) ; then
64- echo " ❌ This script must be run as root or with sudo." >&2
65- exit 1
62+ # Re-run the script with sudo if not already root
63+ if [[ $EUID -ne 0 ]]; then
64+ echo -e " ${C_BOLD}${C_YELLOW} This script requires root privileges to function correctly.${C_RESET} "
65+ echo -e " ${C_YELLOW} Attempting to re-run with sudo. You may be prompted for your password.${C_RESET} "
66+ echo " ----------------------------------------------------------------"
67+ exec sudo " $0 " " $@ "
6668fi
6769
6870# --- Determine script's location to load the config file ---
Original file line number Diff line number Diff line change 1- 4175a7e1000fc6ecf3d94f11758b9d5b5ed86e3a88c0e0b973212a79780d6a8d backup_script.sh
1+ 2ce03d52c44801851ab0d17e5f6bea8c21ab59511e54c1131fda0ddcdfa2af1d backup_script.sh
You can’t perform that action at this time.
0 commit comments