diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2015-09-24 13:16:22 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2015-09-24 13:16:22 -0300 |
commit | b0a45299b1d025dd0a7d17a877bca00d6b5e4598 (patch) | |
tree | c7c2a8344c2771e20fb426cb97c4bf8060b2021e /lib | |
parent | c7a05881240c850c6550e02faf9d8c0f8ff32f40 (diff) | |
download | hydra-b0a45299b1d025dd0a7d17a877bca00d6b5e4598.tar.gz hydra-b0a45299b1d025dd0a7d17a877bca00d6b5e4598.tar.bz2 |
Provision: sudo support
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hydra/misc | 10 |
1 files changed, 10 insertions, 0 deletions
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" |