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:
parent
205d9484cf
commit
5328c51211
1 changed files with 6 additions and 0 deletions
|
@ -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
|
||||
###
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue