summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh')
-rwxr-xr-xbuilder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh b/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh
new file mode 100755
index 00000000..a90481c8
--- /dev/null
+++ b/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh
@@ -0,0 +1,39 @@
+# load dracut functions
+command -v getarg >/dev/null || . /lib/dracut-lib.sh
+
+# read SLX_SERVER and SLX_BASE from the kernel command line
+SLX_SERVER=$(getarg slxsrv)
+SLX_BASE=$(getarg slxbase)
+SLX_CONFIG_DIR="/opt/openslx"
+SLX_CONFIG_FILE="/opt/openslx/config"
+
+if [ -z "$SLX_SERVER" ]; then
+ warn "No 'slxsrv' parameter found in the kernel command line!"
+ warn "Skipping OpenSLX configuration..."
+ return 1
+fi
+if [ -z "$SLX_BASE" ]; then
+ warn "No 'slxbase' parameter found in the kernel command line!"
+ warn "Skipping OpenSLX configuration..."
+ return 1
+fi
+
+info "Getting configuration from OPENSLX-Server..."
+WGET="$(busybox which wget)"
+if [ -z $WGET ]; then
+ # do nothing
+ warn "'wget' not found. Skipping openslx configuration..."
+ return 1
+fi
+
+# ok then we are ready to download the config
+mkdir -p "${SLX_CONFIG_DIR}"
+$WGET -T 5 -q "http://${SLX_SERVER}/${SLX_BASE}/config" -O "${SLX_CONFIG_FILE}"
+RET="$?"
+if [ $RET -ne 0 ]; then
+ warn "Downloading OpenSLX configuration from ${SLX_SERVER}/${SLX_BASE} failed: $RET"
+ emergency_shell -n "$0"
+ return 1
+else
+ return 0
+fi