diff options
author | Jonathan Bauer | 2017-03-07 11:14:32 +0100 |
---|---|---|
committer | Jonathan Bauer | 2017-03-07 11:14:32 +0100 |
commit | 9b61577c3ceb809c2473d4757590a01054466eaf (patch) | |
tree | 2bbbd2dc0a7e79f8509b53bef2f1aba939900489 /builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh | |
parent | Yannick Bilger's WLAN boot prototype (diff) | |
download | systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.gz systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.tar.xz systemd-init-9b61577c3ceb809c2473d4757590a01054466eaf.zip |
moved all dracut modules to modules.d/ + support
Diffstat (limited to 'builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh')
-rwxr-xr-x | builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh new file mode 100755 index 00000000..8c3bed23 --- /dev/null +++ b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- + +source '/usr/lib/rebash/core.sh' +core.import exceptions +core.import logging +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh + +exceptions.try +{ + logging.set_commands_level debug + logging.set_level debug + # NOTE: "getarg" raises an exception so deactivate exceptions for now. + exceptions.deactivate + slx_server="$(getarg slxsrv=)" + slx_server_base="$(getarg slxbase=)" + exceptions.activate + + logging.info "Download config.tgz from '${slx_server}'..." + IFS_backup="$IFS" + IFS=',' + for host in ${slx_server}; do + logging.info "Trying host \"$host\"." + if wget --timeout 5 \ + "http://${host}/${slx_server_base}/config.tgz" \ + --output-document "/etc/config.tgz" + then + break + fi + done + IFS="$IFS_backup" + + if [[ ! -e "/etc/config.tgz" ]]; then + logging.warn "Downloading 'config.tgz' from '${slx_server}' failed. Return code: $return_code" + exit 1 + fi +} +exceptions.catch +{ + logging.error "$exceptions_last_traceback" + emergency_shell "error in ${BASH_SOURCE[0]}" +} |