Add a check against running the script as root

This commit is contained in:
2024-03-14 21:21:29 -05:00
parent 967b7f5446
commit 0605b68672

View File

@@ -1,6 +1,13 @@
#!/bin/bash #!/bin/bash
cd "$(dirname "$0")" 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 #Check if ~/.config/ArchUpdater exists and create it if not
if [ ! -d "$HOME/.config/ArchUpdater" ]; then if [ ! -d "$HOME/.config/ArchUpdater" ]; then
mkdir -p $HOME/.config/ArchUpdater mkdir -p $HOME/.config/ArchUpdater