5
0
Fork 0
mirror of https://codeberg.org/Computertruhe/Setup-Skripte.git synced 2025-06-28 11:26:18 +02:00

Adds check if the script was run as root or with sudo

adds a simple check at the beginning of the script to determine if the script was run with root priviliges or not. If the script was run as root (or using sudo) the script will continue as normal. If not run as root the script will abort with an error.
This commit is contained in:
stefan230 2020-01-10 18:53:17 +01:00
parent 205d9484cf
commit 5328c51211

View file

@ -1,5 +1,11 @@
#!/usr/bin/env bash
# Check if ran with root permissions
if [ `id -u` -ne 0 ]; then
printf "Das Script muss als root ausgeführt werden! (Du kannst auch sudo verwenden)\n"
exit 1
fi
###
# Set variables
###