summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
blob: 0f4b24f23338c6ffb0e0b3c478e3ed45698d7088 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local configuration_file_name='config'
info 'Getting configuration file.'
local IFS_backup="$IFS"
IFS=","
local host
for host in ${SLX_SERVER}; do
    info "Trying host \"$host\"."
    wget --timeout 5 --quiet "http://${host}/${SLX_SERVER_BASE}${configuration_file_name}" \
        --output-document "/$configuration_file_name"
    local return_code="$?"
    [[ $return_code == 0 ]] && break
    continue
done
IFS="$IFS_backup"
if [[ $return_code != 0 ]]; then
    warn "Downloading OpenSLX configuration file from all server in \"${SLX_SERVER}\" in location \"${SLX_SERVER_BASE}${configuration_file_name}\" failed. Return code: $return_code"
    emergency_shell -n "$0"
    return 1
fi
source "/$configuration_file_name"
mkdir --parents "$SLX_CONFIGURATION_LOCATION"
mv "/$configuration_file_name" "$SLX_CONFIGURATION_LOCATION"