From 3bbdd1c1d826dbdea580474bbb60cfd440fb07c4 Mon Sep 17 00:00:00 2001 From: dak180 Date: Sun, 15 Dec 2024 15:35:20 -0500 Subject: [PATCH] Check for root permissions. Fixes #4. --- disk-burnin.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/disk-burnin.sh b/disk-burnin.sh index 0a20242..e72dab9 100755 --- a/disk-burnin.sh +++ b/disk-burnin.sh @@ -212,6 +212,13 @@ for command in "${commands[@]}"; do done +# Must be run as root for effect +if [ ! "$(whoami)" = "root" ] && [ ! "${Dry_Run}" = "0" ]; then + echo "Must be run as root." >&2 + exit 1 +fi + + if [ ! -z "${driveIDs}" ]; then IFS=' ' read -ra devIDs <<< "${driveIDs}" for devID in "${devIDs[@]}"; do