Skip to content

Commit

Permalink
shell/install.sh: Add support for doas as an alternative to sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate committed Feb 2, 2024
1 parent 976455a commit bde6cd0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions shell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,21 @@ xsudo() {

local DSTDIR=$(dirname "$DST")
if [ ! -w "$DSTDIR" ]; then
echo "Write access to $DSTDIR required, using 'sudo'."
if command -v sudo > /dev/null ; then
SUDO=sudo
elif command -v doas > /dev/null ; then
SUDO=doas
else
echo "Write access to '$DSTDIR' required, but neither sudo or doas is installed."
echo "Aborting..."
exit 1
fi
echo "Write access to '$DSTDIR' required, using '$SUDO'."
echo "Command: $CMD $@"
if [ "$CMD" = "install" ]; then
sudo "$CMD" -g 0 -o root "$@"
"$SUDO" "$CMD" -g 0 -o root "$@"
else
sudo "$CMD" "$@"
"$SUDO" "$CMD" "$@"
fi
else
"$CMD" "$@"
Expand Down

0 comments on commit bde6cd0

Please sign in to comment.