aboutsummaryrefslogtreecommitdiff
path: root/lib/hydra/misc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hydra/misc')
-rw-r--r--lib/hydra/misc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/hydra/misc b/lib/hydra/misc
index 34abf1a..eb0a9aa 100644
--- a/lib/hydra/misc
+++ b/lib/hydra/misc
@@ -81,3 +81,17 @@ function hydra_check_group {
grep -qe "^$1:" /etc/group
}
+
+# Abort on error
+function hydra_exit_on_error {
+ if [ "$?" != "0" ]; then
+ echo "Error: $*"
+ exit 1
+ fi
+}
+
+# Run a command or abort
+function hydra_safe_run {
+ $*
+ hydra_exit_on_error $*
+}