summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
diff options
context:
space:
mode:
authorjandob2016-01-07 15:16:37 +0100
committerjandob2016-01-07 15:16:37 +0100
commitba9b0250b392c4cbaa4a9f85d89e4c4a84797065 (patch)
tree18d4a04f6d11be1bda23fd5e00b3bf684a038158 /builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
parentadd qemu-nbd build function (diff)
downloadsystemd-init-ba9b0250b392c4cbaa4a9f85d89e4c4a84797065.tar.gz
systemd-init-ba9b0250b392c4cbaa4a9f85d89e4c4a84797065.tar.xz
systemd-init-ba9b0250b392c4cbaa4a9f85d89e4c4a84797065.zip
change hooks variable scoping; introduce /etc/openslx config
Diffstat (limited to 'builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh')
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh57
1 files changed, 39 insertions, 18 deletions
diff --git a/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh b/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
index 4930c94a..3cbe6996 100755
--- a/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
+++ b/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
@@ -1,22 +1,43 @@
-local configuration_file_name='config'
-info 'Getting configuration file.'
-local IFS_backup="$IFS"
+#!/usr/bin/env bash
+( # subshell for variable scoping
+# region imports
+type getarg >/dev/null 2>&1 || source /lib/dracut-lib.sh
+source "/usr/lib/rebash/core.sh"
+core.import exceptions
+exceptions.activate
+core.import utils
+core.import logging
+# endregion
+logging.set_commands_log_level debug
+logging.set_log_level debug
+
+# TODO make configurable via kernel command line
+configuration_file_name='config'
+
+slx_server="$(getargs slxsrv=)"
+slx_server_base="$(getargs slxbase=)"
+
+logging.info 'Getting configuration file.'
+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
+host
+for host in ${slx_server}; do
+ logging.info "Trying host \"$host\"."
+ if wget --timeout 5 "http://${host}/${slx_server_base}${configuration_file_name}" \
+ --output-document "/etc/openslx"; then
+ break
+ fi
done
IFS="$IFS_backup"
-if [[ $return_code != 0 ]]; then
- warn "Downloading OpenSLX configuration file from any of the servers \"${SLX_SERVER}\" at location \"${SLX_SERVER_BASE}${configuration_file_name}\" failed. Return code: $return_code"
- emergency_shell -n "$0"
- return 1
+
+if [[ ! -e "/etc/openslx" ]]; then
+ logging.warn "Downloading OpenSLX configuration file from any of the servers \"${slx_server}\" at location \"${slx_server_base}${configuration_file_name}\" failed. Return code: $return_code"
+ exit 1
fi
-source "/$configuration_file_name"
-mkdir --parents "$SLX_CONFIGURATION_LOCATION"
-mv "/$configuration_file_name" "$SLX_CONFIGURATION_LOCATION"
+) || exit $?
+# region vim modline
+
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+
+# endregion