forked from kiss-community/kiss
kiss: as_root: Move to func
This commit is contained in:
parent
a7580cc8ee
commit
3e86270338
28
kiss
28
kiss
@ -49,13 +49,17 @@ prompt() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
as_root() {
|
as_root() {
|
||||||
if command -v sudo >/dev/null; then
|
[ "$(id -u)" = 0 ] || {
|
||||||
sudo -E KISS_FORCE="$KISS_FORCE" "$@"
|
if command -v sudo >/dev/null; then
|
||||||
elif command -v doas >/dev/null; then
|
sudo -E KISS_FORCE="$KISS_FORCE" "$@"
|
||||||
KISS_FORCE="$KISS_FORCE" doas "$@"
|
elif command -v doas >/dev/null; then
|
||||||
else
|
KISS_FORCE="$KISS_FORCE" doas "$@"
|
||||||
su -pc "KISS_FORCE=$KISS_FORCE $*"
|
else
|
||||||
fi
|
su -pc "KISS_FORCE=$KISS_FORCE $*"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
regex_escape() {
|
regex_escape() {
|
||||||
@ -1153,10 +1157,7 @@ args() {
|
|||||||
a|alternatives)
|
a|alternatives)
|
||||||
# Rerun the script with 'su' if the user isn't root.
|
# Rerun the script with 'su' if the user isn't root.
|
||||||
# Cheeky but 'su' can't be used on shell functions themselves.
|
# Cheeky but 'su' can't be used on shell functions themselves.
|
||||||
[ -z "$1" ] || [ "$(id -u)" = 0 ] || {
|
[ -z "$1" ] || as_root kiss "$action" "$@"
|
||||||
as_root kiss "$action" "$@"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
i|install|r|remove)
|
i|install|r|remove)
|
||||||
@ -1164,10 +1165,7 @@ args() {
|
|||||||
|
|
||||||
# Rerun the script with 'su' if the user isn't root.
|
# Rerun the script with 'su' if the user isn't root.
|
||||||
# Cheeky but 'su' can't be used on shell functions themselves.
|
# Cheeky but 'su' can't be used on shell functions themselves.
|
||||||
[ "$(id -u)" = 0 ] || {
|
as_root kiss "$action" "$@"
|
||||||
as_root kiss "$action" "$@"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user