summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/hooks/pre-mount/fetch-config.sh
blob: a90481c8a06dc651a621156843cd82d542d2dc9f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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