summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh
blob: bc2cb13154047c458f11eb98155f34a8fac98783 (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
#!/usr/bin/env bash
# -*- coding: utf-8 -*-

type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh

. /etc/openslx

if [ -z "$SLX_NO_CONFIG_TGZ" ]; then
	# build config.tgz url from SLX_KCL_SERVERS and SLX_BASE_PATH
	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
	info "Download config.tgz from '$conftgz_url'..."
	slx-tools download_retry -s "${conftgz_url}" > "/etc/config.tgz"

	if [[ ! -s "/etc/config.tgz" ]]; then
		emergency_shell \
			"Downloading 'config.tgz' from '${slx_server}/${SLX_BASE_PATH}' failed with: $return_code"
	fi
fi