From b0a45299b1d025dd0a7d17a877bca00d6b5e4598 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 24 Sep 2015 13:16:22 -0300 Subject: Provision: sudo support --- lib/hydra/misc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib') diff --git a/lib/hydra/misc b/lib/hydra/misc index 4275021..2c44503 100644 --- a/lib/hydra/misc +++ b/lib/hydra/misc @@ -6,6 +6,10 @@ function hydra_set_env { export CONFIG="$HOME/.hydra/config" export ACTION="$1" + if [ "`whoami`" != 'root' ]; then + SUDO="sudo" + fi + if [ ! -z "$HYDRA" ]; then export HYDRA_FOLDER="`hydra_eval_parameter $HYDRA`" export PREFERENCES="$HOME/.hydra/$HYDRA" @@ -108,6 +112,12 @@ function hydra_safe_run { hydra_exit_on_error $* } +# Run a command using sudo and abort on error +function hydra_sudo_run { + $SUDO $* + hydra_exit_on_error $* +} + # Determine the next debian release function hydra_next_debian_release { local release="$1" -- cgit v1.2.3