diff --git a/lib.sh b/lib.sh index 6b6e75f..8eececf 100644 --- a/lib.sh +++ b/lib.sh @@ -14,6 +14,35 @@ WANIP4=$(curl -s -k -m 5 -4 https://api64.ipify.org) ############ Functions +is_root() { + if [[ "$EUID" -ne 0 ]] + then + return 1 + else + return 0 + fi +} + +root_check() { +if ! is_root +then + msg_box "Sorry, you are not root. You now have two options: + +1. Use SUDO directly: + a) :~$ sudo bash name-of-script.sh + +2. Become ROOT and then type your command: + a) :~$ sudo -i + b) :~# bash name-of-script.sh + +In both cases above you can leave out $SCRIPTS/ if the script +is directly in your PATH. + +More information can be found here: https://unix.stackexchange.com/a/3064" + exit 1 +fi +} + print_text_in_color() { printf "%b%s%b\n" "$1" "$2" "$Color_Off" }