mirror of https://github.com/bol-van/zapret/
5 changed files with 81 additions and 56 deletions
@ -1,13 +1,28 @@ |
|||||
require_root() |
require_root() |
||||
{ |
{ |
||||
local exe |
local exe preserve_env |
||||
echo \* checking privileges |
echo \* checking privileges |
||||
[ $(id -u) -ne "0" ] && { |
[ $(id -u) -ne "0" ] && { |
||||
echo root is required |
echo root is required |
||||
exe="$EXEDIR/$(basename "$0")" |
exe="$EXEDIR/$(basename "$0")" |
||||
exists sudo && exec sudo sh "$exe" |
exists sudo && { |
||||
exists su && exec su root -c "sh \"$exe\"" |
echo elevating with sudo |
||||
|
exec sudo -E sh "$exe" |
||||
|
} |
||||
|
exists su && { |
||||
|
echo elevating with su |
||||
|
case "$UNAME" in |
||||
|
Linux) |
||||
|
preserve_env="--preserve-environment" |
||||
|
;; |
||||
|
FreeBSD|OpenBSD|Darwin) |
||||
|
preserve_env="-m" |
||||
|
;; |
||||
|
esac |
||||
|
exec su $preserve_env root -c "sh \"$exe\"" |
||||
|
} |
||||
echo su or sudo not found |
echo su or sudo not found |
||||
exitp 2 |
exitp 2 |
||||
} |
} |
||||
|
HAVE_ROOT=1 |
||||
} |
} |
||||
|
Loading…
Reference in new issue