aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-09-24 13:16:22 -0300
committerSilvio Rhatto <rhatto@riseup.net>2015-09-24 13:16:22 -0300
commitb0a45299b1d025dd0a7d17a877bca00d6b5e4598 (patch)
treec7c2a8344c2771e20fb426cb97c4bf8060b2021e /lib
parentc7a05881240c850c6550e02faf9d8c0f8ff32f40 (diff)
downloadhydra-b0a45299b1d025dd0a7d17a877bca00d6b5e4598.tar.gz
hydra-b0a45299b1d025dd0a7d17a877bca00d6b5e4598.tar.bz2
Provision: sudo support
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/misc10
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"