Auto-sudo setup and better messages

This commit is contained in:
southerntofu 2020-04-27 17:08:33 +02:00
parent de16f9ab47
commit 2024563034
1 changed files with 11 additions and 5 deletions

View File

@ -52,11 +52,17 @@ sudo cp webhook-run-backend $DEST
sudo chown "$owner:$owner" $DEST/webhook-run-backend
sudo chmod 755 $DEST/webhook-run-backend
echo "Successfully installed webhook as user $owner to $DEST"
echo "[setup.sh] Installed webhook to $DEST for $owner"
# Auto setup sudo rules
SUDO_SETUP=0
if ! sudo grep "webhook-backend" /etc/sudoers > /dev/null; then
# TODO: auto setup sudo rules
echo "Please place the following in your /etc/sudoers (by running visudo):"
echo "ALL ALL=($owner) NOPASSWD: /usr/local/bin/webhook-backend
$owner ALL=NOPASSWD: /usr/local/bin/webhook-run"
SUDO_SETUP=1
sudo echo "ALL ALL=($owner) NOPASSWD: /usr/local/bin/webhook-backend" >> /etc/sudoers
fi
if ! sudo grep "webhook-run" /etc/sudoers > /dev/null; then
SUDO_SETUP=1
sudo echo "$owner ALL=NOPASSWD: /usr/local/bin/webhook-run" >> /etc/sudoers
fi
[[ $SUDO_SETUP = 1 ]] && echo "[setup.sh] sudo rules have been installed for webhook"