add root function to lib
This commit is contained in:
parent
077e892e6d
commit
7366541dce
29
lib.sh
29
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"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user