summaryrefslogtreecommitdiffstats
path: root/modules.d/conf-tgz/hooks/s3-fetch-config-tgz.sh
blob: 1d032a198273a921b3af496908dfc25e93f7691a (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
#!/bin/ash
# -*- coding: utf-8 -*-

. /etc/openslx

[ -n "$SLX_NO_CONFIG_TGZ" ] && exit 0

# build config.tgz url from SLX_KCL_SERVERS and SLX_BASE_PATH
# both are written to /etc/openslx by dnbd3-rootfs's s3-fetch-config.sh script
conftgz_url="http://${SLX_KCL_SERVERS}/${SLX_BASE_PATH}/config.tgz"

# check if system's uuid was set
if [ -s "/run/system-uuid" ]; then
	uuid="$(cat /run/system-uuid)"
	if [ -n "$uuid" ]; then
		conftgz_url="${conftgz_url}?uuid=${uuid}"
	fi
fi
echo "Download config.tgz from '$conftgz_url'..."
slx-tools download_retry --slx-time 20 -sS "${conftgz_url}" > "/etc/config.tgz"

if ! [ -s "/etc/config.tgz" ]; then
	echo "Failed to download '${conftgz_url}'"
	exit 1
fi

exit 0