summaryrefslogtreecommitdiff
path: root/install-header.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install-header.sh')
-rwxr-xr-xinstall-header.sh67
1 files changed, 67 insertions, 0 deletions
diff --git a/install-header.sh b/install-header.sh
new file mode 100755
index 0000000..210691d
--- /dev/null
+++ b/install-header.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+# This is a pre-allocated string of 30 chars of whitespace
+# DO NOT CHANGE THIS without great care - it will break header length
+# calculations
+LENS=( )
+export SELF
+export TMP
+
+# Header: 0
+# runscript: 1
+# payload: 2
+extract_chunk_index() {
+ local script="${1}"
+ local dest="${2}"
+ local index="${3}"
+ local skip=0
+
+ for (( i = 0; i < index; i++ )); do
+ skip=$(( skip + LENS[$i] ))
+ done
+
+ # Extract the requested chunk index
+ dd bs=1 count=${LENS[$index]} iflag=skip_bytes skip=${skip} \
+ if=${script} of=${dest} 2>/dev/null
+}
+
+extract_header() {
+ extract_chunk_index "${SELF}" "${TMP}/header.sh" 0
+}
+
+extract_runscript() {
+ extract_chunk_index "${SELF}" "${TMP}/run.sh.xz" 1
+ xz -d "${TMP}/run.sh.xz"
+}
+
+extract_payload() {
+ extract_chunk_index "${SELF}" "${TMP}/payload.tar.xz" 2
+ tar -C "${TMP}" -x -f payload.tar.xz
+}
+
+
+main() {
+ SELF="$(cd $(dirname ${0}) && pwd)/$(basename ${0})"
+ TMP="$(mktemp -d /tmp/installer-XXXXXXX)"
+
+ extract_header
+ extract_runscript
+ #extract_chunks "${self}" "${tmp}"
+
+ cd "${TMP}"
+ source run.sh
+
+ # Function 'deploy' is provided by run.sh
+ if [ "$(type -t deploy)" == 'function' ]; then
+ deploy
+ else
+ printf "ERROR: Deploy function not found.\n"
+ fi
+
+ # Cleanup
+ rm -rf "${TMP}"
+}
+
+main ${@}
+exit 0
+

Generated by cgit