From 0605b68672b7a5ea4a47d7a551d6373a9a7711c9 Mon Sep 17 00:00:00 2001 From: Radical Date: Thu, 14 Mar 2024 21:21:29 -0500 Subject: [PATCH] Add a check against running the script as root --- ArchUpdater.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ArchUpdater.sh b/ArchUpdater.sh index 37523fe..ea4fae3 100755 --- a/ArchUpdater.sh +++ b/ArchUpdater.sh @@ -1,6 +1,13 @@ #!/bin/bash cd "$(dirname "$0")" +#Check if script has been run as root and exit if so, prompting the user to run as normal user +if [ $(id -u) -eq 0 ]; then + echo "Please do not run this script as root or with sudo, it will prompt for your password and elevate as necessary" + exit +fi + + #Check if ~/.config/ArchUpdater exists and create it if not if [ ! -d "$HOME/.config/ArchUpdater" ]; then mkdir -p $HOME/.config/ArchUpdater