From b020fbfeee508e27569dda624d82dce34461e0e3 Mon Sep 17 00:00:00 2001 From: Roland Date: Mon, 9 Oct 2023 13:25:13 -0600 Subject: [PATCH] Requiring sudo for help script, it will change to other users as needed. --- help.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/help.sh b/help.sh index 1d75a003..5ac934f5 100755 --- a/help.sh +++ b/help.sh @@ -5,7 +5,11 @@ MEDIA_DIRECTORY=/media/wrolpi # Source environment file after declaring globals. [ -f /opt/wrolpi/.env ] && source /opt/wrolpi/.env -echo "This script is running as $(whoami)" +# Re-execute this script if it wasn't called with sudo. +if [ $EUID != 0 ]; then + sudo "$0" "$@" + exit $? +fi function check_directory() { directory=$1