Skip to content

Commit a3b5ef0

Browse files
committed
shell/install.sh: Add support for doas as an alternative to sudo
1 parent 976455a commit a3b5ef0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

master_changes.md

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ users)
7676

7777
## Release scripts
7878

79+
## Install script
80+
* Add support for doas as an alternative to sudo [#5820 @kit-ty-kate - fix #5792]
81+
7982
## Admin
8083

8184
## Opam installer

shell/install.sh

+12-3
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,21 @@ xsudo() {
390390

391391
local DSTDIR=$(dirname "$DST")
392392
if [ ! -w "$DSTDIR" ]; then
393-
echo "Write access to $DSTDIR required, using 'sudo'."
393+
if command -v sudo > /dev/null ; then
394+
SUDO=sudo
395+
elif command -v doas > /dev/null ; then
396+
SUDO=doas
397+
else
398+
echo "Write access to '$DSTDIR' required, but neither sudo or doas is installed."
399+
echo "Aborting..."
400+
exit 1
401+
fi
402+
echo "Write access to '$DSTDIR' required, using '$SUDO'."
394403
echo "Command: $CMD $@"
395404
if [ "$CMD" = "install" ]; then
396-
sudo "$CMD" -g 0 -o root "$@"
405+
"$SUDO" "$CMD" -g 0 -o root "$@"
397406
else
398-
sudo "$CMD" "$@"
407+
"$SUDO" "$CMD" "$@"
399408
fi
400409
else
401410
"$CMD" "$@"

0 commit comments

Comments
 (0)