From b07df720d94178bb9de309004658e284a7151673 Mon Sep 17 00:00:00 2001 From: deajan Date: Tue, 7 Feb 2017 21:28:50 +0100 Subject: [PATCH] path fixes for rsync and bash --- dev/tests/sudo_prep.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/dev/tests/sudo_prep.sh b/dev/tests/sudo_prep.sh index e2df877..b80227c 100755 --- a/dev/tests/sudo_prep.sh +++ b/dev/tests/sudo_prep.sh @@ -50,16 +50,35 @@ function SetupSSH { function PrepareSudoers { local remoteUser="${1}" + local bashPath + local rsyncPath + + if ! type bash > /dev/null 2>&1; then + echo "No bash available" + exit 1 + else + bashPath=$(type -p bash) + fi + + if ! type rsync > /dev/null 2>&1; then + echo "No rsync available" + exit 1 + else + rsyncPath=$(type -p rsync) + fi + + RemoveSudoers $remoteUser + if [ -f "/etc/sudoers" ]; then - echo "$remoteUser ALL=NOPASSWD:SETENV:/usr/bin/rsync,/usr/bin/bash" >> "/etc/sudoers" + echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath" >> "/etc/sudoers" echo "Defaults:$remoteUser !requiretty" >> "/etc/sudoers" elif [ -f "/usr/local/etc/sudoers" ]; then - echo "$remoteUser ALL=NOPASSWD:SETENV:/usr/local/bin/rsync,/usr/local/bin/bash" >> "/usr/local/etc/sudoers" + echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath" >> "/usr/local/etc/sudoers" echo "Defaults:$remoteUser !requiretty" >> "usr/local/etc/sudoers" else echo "No sudoers file found." echo "copy the following lines to /etc/sudoers (or /usr/local/etc/sudoers) and adjust /usr/bin path to the target system" - echo "$remoteUser ALL=NOPASSWD:SETENV:/usr/bin/rsync,/usr/bin/bash" + echo "$remoteUser ALL=NOPASSWD:SETENV:$rsyncPath,$bashPath" echo "Defaults:$remoteUser !requiretty" fi }