From 6252737cc1915a2a100aafaef06448d1aaabb3a0 Mon Sep 17 00:00:00 2001 From: richdex14 Date: Mon, 4 Sep 2017 13:35:16 -0600 Subject: [PATCH] Update setup-deps-ubuntu.bash to use portable `sudo_cmd` syntax --- setup-deps-ubuntu.bash | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup-deps-ubuntu.bash b/setup-deps-ubuntu.bash index 1185389..16ef7c2 100644 --- a/setup-deps-ubuntu.bash +++ b/setup-deps-ubuntu.bash @@ -2,6 +2,10 @@ # curl -fsSL https://ldsconnect.org/setup-linux.bash | bash -c +# Not every platform has or needs sudo, gotta save them O(1)s... +sudo_cmd="" +((EUID)) && [[ -z "$ANDROID_ROOT" ]] && sudo_cmd="sudo" + NO_FAIL2BAN=${1} echo "" @@ -18,7 +22,7 @@ echo " * jshint" echo "" echo "updating apt-get..." -sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null +$sudo_cmd bash -c "apt-get update -qq -y < /dev/null" > /dev/null # fail2ban #if [ -z "$(which fail2ban-server | grep fail2ban)" ]; then @@ -32,5 +36,5 @@ sudo bash -c "apt-get update -qq -y < /dev/null" > /dev/null if [ -z "$(type -p pkg-config)" ] || [ -z "$(type -p git)" ] || [ -z "$(type -p wget)" ] || [ -z "$(type -p curl)" ] || [ -z "$(type -p gcc)" ] || [ -z "$(type -p rsync)" ] || [ -z "$(type -p python)" ] then echo "installing git, wget, curl, build-essential, rsync, pkg-config, python..." - sudo bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config python < /dev/null" > /dev/null 2>/dev/null + $sudo_cmd bash -c "apt-get install -qq -y git wget curl build-essential rsync pkg-config python < /dev/null" > /dev/null 2>/dev/null fi