summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remote/rootfs/rootfs-stage31/data/etc/functions44
1 files changed, 44 insertions, 0 deletions
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 >/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
+}
+