Browse Source

check root

pull/4200/head
Daniel Gibbs 3 years ago
parent
commit
ad16c04a75
No known key found for this signature in database GPG Key ID: 7CA38B43F78F12FE
  1. 21
      lgsm/functions/check_root.sh

21
lgsm/functions/check_root.sh

@ -0,0 +1,21 @@
#!/bin/bash
# LinuxGSM check_root.sh module
# Author: Daniel Gibbs
# Contributors: http://linuxgsm.com/contrib
# Website: https://linuxgsm.com
# Description: Checks if the user tried to run the script as root.
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
if [ "$(whoami)" == "root" ] && [ ! -f /.dockerenv ]; then
if [ "${commandname}" != "INSTALL" ]; then
fn_print_fail_nl "Do NOT run this script as root!"
if [ -d "${lgsmlogdir}" ]; then
fn_script_log_fatal "${selfname} attempted to run as root."
else
# Forces exit code is log does not yet exist.
exitcode=1
fi
core_exit.sh
fi
fi
Loading…
Cancel
Save