Skip to content

Commit 1a302b7

Browse files
authored
Merge pull request #2 from buildplan/improve
added sudo/root check
2 parents 2a05564 + 9783db9 commit 1a302b7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ To run the backup automatically, edit the root crontab.
136136
set -Euo pipefail
137137
umask 077
138138
139+
# Check if the script is being run as root
140+
if (( EUID != 0 )); then
141+
echo "❌ This script must be run as root or with sudo." >&2
142+
exit 1
143+
fi
144+
139145
# --- Determine script's location to load local config files ---
140146
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
141147

backup_script.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
set -Euo pipefail
77
umask 077
88

9+
# Check if the script is being run as root
10+
if (( EUID != 0 )); then
11+
echo "❌ This script must be run as root or with sudo." >&2
12+
exit 1
13+
fi
14+
915
# --- Determine script's location to load local config files ---
1016
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
1117

0 commit comments

Comments
 (0)