blob: 083fbc6e83e7cd6a11e23e6e62be1ecfa0d7ff41 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/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
# this module unpacks the config.tgz
temporary_extract_directory="$(mktemp -d)"
exceptions.try
{
logging.set_commands_level debug
logging.set_level debug
exceptions.activate
if [[ -e "/etc/config.tgz" ]]; then
tar --extract --preserve-permissions \
--file="/etc/config.tgz" \
--directory="$temporary_extract_directory"
fi
}
exceptions.catch
{
logging.error "Failed to extract '/etc/config.tgz' to '$temporary_extract_directory'."
logging.error "$exceptions_last_traceback"
emergency_shell "error in ${BASH_SOURCE[0]}"
}
# extracted to temporary directory, now check for SLX_LOCAL_CONFIGURATION
source "/etc/openslx"
exceptions.try
{
logging.set_commands_level debug
logging.set_level debug
exceptions.activate
if [[ -z "$SLX_LOCAL_CONFIGURATION" ]]; then
logging.warn "SLX_LOCAL_CONFIGURATION is not set in '/etc/openslx'."
exit 0
fi
if [[ ! -d "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]]; then
logging.warn "SLX_LOCAL_CONFIGURATION is set but no corresponding folder found in '/etc/config.tgz'."
exit 0
fi
# still here? then process to merge the localized configuration files with the common files.
cd "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}"
tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${temporary_extract_directory}"
}
exceptions.catch
{
# errors here are not critical, so no emergency shell
logging.error "Failed to merge local configuration files for '$SLX_LOCAL_CONFIGURATION'."
logging.error "$exceptions_last_traceback"
emergency_shell "error in ${BASH_SOURCE[0]}"
}
# now just copy everything from the temporary_extract_directory to the future root
exceptions.try
{
logging.set_commands_level debug
logging.set_level debug
exceptions.activate
cd "${temporary_extract_directory}"
# purge openslx-configs/
rm -rf "openslx-configs"
tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${NEWROOT}"
}
exceptions.catch
{
# errors here are not critical, so no emergency shell
logging.error "Failed to copy extracted configuration files to '$NEWROOT'."
logging.error "$exceptions_last_traceback"
emergency_shell "error in ${BASH_SOURCE[0]}"
}
|