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 1
1
#! /bin/bash
2
- # ===================== v0.35 - 2025.08.21 ========================
2
+ # ===================== v0.36 - 2025.08.29 ========================
3
3
#
4
4
# Example backup.conf:
5
5
# BACKUP_DIRS="/home/user/test/./ /var/www/./"
59
59
C_CYAN=' '
60
60
fi
61
61
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 " " $@ "
66
68
fi
67
69
68
70
# --- 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