From 49fb72dbce75a6b48ff49426596931320ddb1a7a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 12 Nov 2018 12:31:33 +0100 Subject: [conf-tgz] send uuid in the request, if present + formatting --- .../modules.d/conf-tgz/hooks/fetch-config-tgz.sh | 50 ++++++++++++---------- 1 file changed, 28 insertions(+), 22 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 index 263eff75..eb32cfda 100755 --- a/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh +++ b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh @@ -8,30 +8,36 @@ 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 + # 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 TIMEOUT in 1 1 2 3; do - if wget --timeout 5 \ - "http://${slx_server#@}/${slx_server_base}/config.tgz" \ - --output-document "/etc/config.tgz"; then - break - fi - done - IFS="$IFS_backup" + # check if system's uuid was set + if [ -s "/run/system-uuid" ]; then + uuid="$(cat /run/system-uuid)" + if [ -n "$uuid" ]; then + uuid_url="?uuid=$uuid" + fi + fi + logging.info "Download config.tgz from '${slx_server#@}'..." + IFS_backup="$IFS" + IFS=',' + # to stay compatible with busybox's wget we do not use '--tries' + for TIMEOUT in 1 1 2 3; do + if wget -q -T $TIMEOUT \ + "http://${slx_server#@}/${slx_server_base}/config.tgz$uuid_url" \ + --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 + if [[ ! -e "/etc/config.tgz" ]]; then + logging.warn "Downloading 'config.tgz' from '${slx_server}' failed. Return code: $return_code" + return 1 + fi } exceptions.catch { -- cgit v1.2.3-55-g7522