X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=old%2Fscripts%2Ffunctions.sh;fp=old%2Fscripts%2Ffunctions.sh;h=76ba78a1108974b498f16cfbe59216335f09804b;hb=1a06f3f65adef0fdd432aad11f479020630778a5;hp=0000000000000000000000000000000000000000;hpb=3ce5c1d60539aa8d2a01a810aa92325f8c513696;p=grml-live.git diff --git a/old/scripts/functions.sh b/old/scripts/functions.sh new file mode 100644 index 0000000..76ba78a --- /dev/null +++ b/old/scripts/functions.sh @@ -0,0 +1,55 @@ +# Filename: functions.sh +# Purpose: helper functions for use within grml-live +# Authors: grml-team (grml.org), (c) Michael Prokop +# Bug-Reports: see http://grml.org/bugs/ +# License: This file is licensed under the GPL v2. +# Latest change: Thu Feb 08 22:35:46 CET 2007 +################################################################################ + +bailout(){ + [ -n "$1" ] && EXIT="$1" || EXIT="1" + [ -n "$2" ] && echo "$2">&2 + exit "$EXIT" +} + +usage() { + print " + $0 .... +" +} + +debug() { + if [[ -n "$DEBUG" ]] ; then + einfo "grml-live: $*" + [[ -n "$DEBUG_SYSLOG" ]] && [ -x /usr/bin/logger ] && logger -t grml-live-info "$*" + else + return 0 # do nothing + fi +} + +debug_warn() { + if [[ -n "$DEBUG" ]] ; then + ewarn "grml-live: $*" + [[ -n "$DEBUG_SYSLOG" ]] && [ -x /usr/bin/logger ] && logger -t grml-live-warn "$*" + else + return 0 # do nothing + fi +} + +debug_error() { + if [[ -n "$DEBUG" ]] ; then + eerror "grml-live: $*" + [[ -n "$DEBUG_SYSLOG" ]] && [ -x /usr/bin/logger ] && logger -t grml-live-error "$*" + else + return 0 # do nothing + fi +} + +chroot_exec() +{ + [ -n "$TARGET" ] || bailout 1 "\$TARGET unset, can not chroot_exec" + [ -n "$1" ] || bailout 1 "Error executing chroot_exec. Usage: chroot_exec " + chroot "$TARGET" "$1" +} + +## END OF FILE #################################################################