Skip to content

Commit

Permalink
Merge pull request #5820 from kit-ty-kate/install-script-doas
Browse files Browse the repository at this point in the history
shell/install.sh: Add support for doas as an alternative to sudo
  • Loading branch information
kit-ty-kate authored Feb 5, 2024
2 parents 976455a + a3b5ef0 commit da38263
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ users)

## Release scripts

## Install script
* Add support for doas as an alternative to sudo [#5820 @kit-ty-kate - fix #5792]

## Admin

## Opam installer
Expand Down
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 da38263

Please sign in to comment.