Meta: Add exit_if_running_as_root() to shell_include.sh

This adds the method exit_if_running_as_root() which checks if the
script is executed under root, and if that's the case exits the script.
This commit is contained in:
Kenneth Myhra 2023-04-24 21:09:23 +02:00 committed by Andrew Kaster
parent f2f14ad9bd
commit b4a0fee03d
Notes: sideshowbarker 2024-07-17 03:18:29 +09:00

View file

@ -17,6 +17,12 @@ die() {
exit 1
}
exit_if_running_as_root() {
if [ "$(id -u)" -eq 0 ]; then
die "$*"
fi
}
find_executable() {
paths=("/usr/sbin" "/sbin")