From cf1678292b695d2e2fd5ed194cee4e6135660fd3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Thu, 15 Aug 2013 17:53:52 +0200 Subject: merge --- remote/rootfs/rootfs-stage31/data/etc/functions | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 remote/rootfs/rootfs-stage31/data/etc/functions (limited to 'remote/rootfs') diff --git a/remote/rootfs/rootfs-stage31/data/etc/functions b/remote/rootfs/rootfs-stage31/data/etc/functions new file mode 100644 index 00000000..ff1276a5 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/etc/functions @@ -0,0 +1,44 @@ +######################################################################### +# +# COMMON HELPER FUNCTIONS +# + +######################################################################### +# +# Function to drop a debug shell with an error message. +# +# Usage: +# drop_shell "This is your error message." +# +drop_shell() { + [ $# -gt 0 ] && echo $@ + echo "CTRL + D will continue booting." + setsid sh -c 'exec sh /dev/tty1 2>&1' +} + +######################################################################### +# +# Helper function to download given FILE_URL under TARGET_PATH +# +# Usage: +# download $FILE_URL $TARGET_PATH +# +download() { + [ $# -ne 2 ] && echo "Error - 'download' requires 2 arguements, $# given." \ + && exit 1 + + local FILE_URL="$1" + local TARGET_PATH="$2" + + wget -T 5 -q -O "$TARGET_PATH" "$FILE_URL" + RET=$? + if [ "x$RET" != "x0" ]; then + echo "Error - downloading '$FILE_URL' via wget failed. Exit Code: $RET" + exit 1 + else + echo "Successfully downloaded '$FILE_URL'." + fi + + return 0 +} + -- cgit v1.2.3-55-g7522