check_root.sh 493 B

1234567891011121314151617
  1. #!/bin/bash
  2. # LinuxGSM check_root.sh function
  3. # Author: Daniel Gibbs
  4. # Website: https://linuxgsm.com
  5. # Description: Checks if the user tried to run the script as root.
  6. functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
  7. if [ "$(whoami)" = "root" ]; then
  8. if [ "${commandname}" != "INSTALL" ]; then
  9. fn_print_fail_nl "Do NOT run this script as root!"
  10. if [ -d "${lgsmlogdir}" ]; then
  11. fn_script_log_fatal "${selfname} attempted to run as root."
  12. fi
  13. core_exit.sh
  14. fi
  15. fi