Skip to content

Commit

Permalink
Verify that 'sudo' is present before assuming we can use it
Browse files Browse the repository at this point in the history
  • Loading branch information
JElchison committed Jul 26, 2017
1 parent 1ca76af commit 6690130
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion format-udf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@
# setup Bash environment
set -euf -o pipefail

# setup sudo

# handle following scenarios:
# * unprivileged user (i.e. not root, sudo not used)
# * privileged user (i.e. not root, sudo used)
# * root user (i.e. sudo not used)
SUDO=''
if [[ $(id -u) -ne 0 ]]; then
# verify that 'sudo' is present before assuming we can use it
if [[ ! -x $(which sudo 2>/dev/null) ]]; then
echo "[-] Dependencies unmet. Please verify that 'sudo' is installed, executable, and in the PATH." >&2
echo "Alternatively, you may also re-run this script as root." >&2
exit 1
fi

SUDO='sudo'
fi


###############################################################################
# constants
###############################################################################
Expand Down

0 comments on commit 6690130

Please sign in to comment.