2024-10-28 06:32:24 +00:00
|
|
|
require_root()
|
|
|
|
{
|
2024-10-31 07:50:05 +00:00
|
|
|
local exe preserve_env
|
2024-10-28 06:32:24 +00:00
|
|
|
echo \* checking privileges
|
|
|
|
[ $(id -u) -ne "0" ] && {
|
|
|
|
echo root is required
|
|
|
|
exe="$EXEDIR/$(basename "$0")"
|
2024-10-31 07:50:05 +00:00
|
|
|
exists sudo && {
|
|
|
|
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\""
|
|
|
|
}
|
2024-10-28 06:32:24 +00:00
|
|
|
echo su or sudo not found
|
|
|
|
exitp 2
|
|
|
|
}
|
2024-10-31 07:50:05 +00:00
|
|
|
HAVE_ROOT=1
|
2024-10-28 06:32:24 +00:00
|
|
|
}
|