26 lines
470 B
Bash
Executable File
26 lines
470 B
Bash
Executable File
#!/bin/sh
|
|
# xp PKGS... - like xbps-pkgdb, but take sudo/su into account
|
|
|
|
which_sudo() {
|
|
if command -v sudo >/dev/null && sudo -l | grep -q -e ' ALL$' -e xbps-pkgdb; then
|
|
echo sudo
|
|
elif command -v doas >/dev/null && [ -f /etc/doas.conf ]; then
|
|
echo doas
|
|
elif [ "$(id -u)" != 0 ]; then
|
|
echo su
|
|
fi
|
|
}
|
|
|
|
do_pkgdb() {
|
|
if [ "$SUDO" = su ]; then
|
|
su root -c 'xbps-pkgdb "$@"' -- sh "$@"
|
|
else
|
|
$SUDO xbps-pkgdb "$@"
|
|
fi
|
|
}
|
|
|
|
SUDO=$(which_sudo)
|
|
do_remove "$@"
|
|
|
|
exit $?
|