Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell/install.sh: Add support for doas as an alternative to sudo #5820

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading