summaryrefslogtreecommitdiffstats
path: root/dev-tools/exampleDracutModule/apply-package.sh
blob: 25a685b2e07a3fd0d121f35c7c9d3b300b8ebc48 (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
27
28
29
30
31
32
33
34
35
36
37
38
#!/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

    echo 'Getting package.'
    IFS_backup="$IFS"
    IFS=','
    for host in ${slx_server}; do
        echo "Trying host \"$host\"."
        if wget --timeout 5 \
            "http://${host}/${slx_server_base}config.tar.gz" \
            --output-document - | tar --extract --verbose --gzip --directory \
                "$NEWROOT"
        then
            break
        fi
    done
    IFS="$IFS_backup"
}
exceptions.catch
{
    echo "$exceptions_last_traceback"
    emergency_shell "error in ${BASH_SOURCE[0]}"
}