From 32f835aa30ca13df697fbaf0af11760407849c72 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 13:30:10 -0600 Subject: [PATCH] Update install.sh to use portable `sudo_cmd` syntax --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 33d8948..3559ad4 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Not every platform has or needs sudo, gotta save them O(1)s... +sudo_cmd="" +((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" + set -e set -u @@ -54,9 +58,9 @@ detect_http_get install_walnut() { - sudo mkdir -p /srv/walnut/{var,etc,packages,node_modules} + $sudo_cmd mkdir -p /srv/walnut/{var,etc,packages,node_modules} # www-data exists on linux, _www exists on mac OS - sudo chown -R $(whoami):www-data /srv/walnut || sudo chown -R $(whoami):_www /srv/walnut + $sudo_cmd chown -R $(whoami):www-data /srv/walnut || $sudo_cmd chown -R $(whoami):_www /srv/walnut if [ ! -d "/srv/walnut/core/" ]; then git clone https://git.daplie.com/Daplie/walnut.js.git /srv/walnut/core fi @@ -72,7 +76,7 @@ install_walnut() /srv/walnut/core/install-helper.sh /srv/walnut # Now that the install is finished we need to set the owner to the user that will actually # be running the walnut server. - sudo chown -R www-data:www-data /srv/walnut || sudo chown -R _www:_www /srv/walnut + $sudo_cmd chown -R www-data:www-data /srv/walnut || $sudo_cmd chown -R _www:_www /srv/walnut } # Install node