summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-rootfs/hooks
diff options
context:
space:
mode:
authorjandob2016-01-07 16:40:37 +0100
committerjandob2016-01-07 16:40:37 +0100
commitfc39d8b96dfe1874d625dd4daa389b56f775699d (patch)
tree1b657ee8a50a37b7f15f8e8a099aedd7c673c951 /builder/dnbd3-rootfs/hooks
parentchange hooks variable scoping; introduce /etc/openslx config (diff)
downloadsystemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.tar.gz
systemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.tar.xz
systemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.zip
change hooks variable scoping
Diffstat (limited to 'builder/dnbd3-rootfs/hooks')
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/cmdline/prepare-kernel-command-line-parameter.sh4
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh3
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh26
-rwxr-xr-xbuilder/dnbd3-rootfs/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh2
4 files changed, 19 insertions, 16 deletions
diff --git a/builder/dnbd3-rootfs/hooks/cmdline/prepare-kernel-command-line-parameter.sh b/builder/dnbd3-rootfs/hooks/cmdline/prepare-kernel-command-line-parameter.sh
index c038aecc..4c388178 100755
--- a/builder/dnbd3-rootfs/hooks/cmdline/prepare-kernel-command-line-parameter.sh
+++ b/builder/dnbd3-rootfs/hooks/cmdline/prepare-kernel-command-line-parameter.sh
@@ -54,11 +54,11 @@ if [ -z "$dracut_interface_name" ]; then
fi
mount --options bind "${writeable_proc_cmdline_path}cmdline" /proc/cmdline
-if [ -z $(getargs "$SLX_SERVER") ]; then
+if [ -z $(getargs slxsrv=) ]; then
warn 'No "slxsrv" parameter found in the kernel command line.'
exit 1
fi
-if [ -z $(getargs "$SLX_SERVER_BASE") ]; then
+if [ -z $(getargs slxbase=) ]; then
warn 'No "slxbase" parameter found in the kernel command line.'
exit 1
fi
diff --git a/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh b/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
index 3cbe6996..299e3135 100755
--- a/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
+++ b/builder/dnbd3-rootfs/hooks/pre-mount/fetch-config.sh
@@ -1,5 +1,4 @@
#!/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"
@@ -8,6 +7,7 @@ exceptions.activate
core.import utils
core.import logging
# endregion
+( # subshell for variable scoping
logging.set_commands_log_level debug
logging.set_log_level debug
@@ -35,6 +35,7 @@ if [[ ! -e "/etc/openslx" ]]; then
exit 1
fi
) || exit $?
+exceptions.deactivate
# region vim modline
# vim: set tabstop=4 shiftwidth=4 expandtab:
diff --git a/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh
index 4e70db35..3b96239b 100755
--- a/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh
+++ b/builder/dnbd3-rootfs/hooks/pre-mount/prepare-root-partition.sh
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
-( # subshell for variable scoping
# region imports
-source /lib/dracut-lib.sh
+type getarg >/dev/null 2>&1 || source /lib/dracut-lib.sh
source "/usr/lib/rebash/core.sh"
core.import exceptions
exceptions.activate
@@ -10,6 +9,7 @@ core.import logging
logging.set_commands_log_level debug
logging.set_log_level debug
# endregion
+( # subshell for variable scoping
SLX_SERVER_BASE="$(getargs slxbase=)"
source /etc/openslx
@@ -61,7 +61,7 @@ then
echo change > /sys/block/nbd0/uevent
udevadm settle
- # wait for partitions TODO make nicer :)
+ # wait for partitions TODO make nicer
#touch $read_only_device
#udevadm settle
else
@@ -75,14 +75,16 @@ else
read_only_device="$loop_device"
fi
-while ! read_only_partition=$(utils.find_block_device \
- "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device"); do
-#if ! read_only_partition=$(utils.find_block_device \
- #"$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device"); then
- logging.warn "Trying to find unique device with identifier" \
- "'${SLX_SYSTEM_PARTITION_IDENTIFIER}'; matched devices:" \
- "'${read_only_partition}'"
- sleep 0.5
+for i in 0.5 1 2; do
+ if read_only_partition=$(utils.find_block_device \
+ "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device"); then
+ break
+ else
+ logging.warn "Failed to find unique device with identifier" \
+ "'${SLX_SYSTEM_PARTITION_IDENTIFIER}'; matched devices:" \
+ "'${read_only_partition}'"
+ sleep $i
+ fi
done
# endregion
@@ -136,9 +138,9 @@ modprobe dm_snapshot
dmsetup create "$writable_partition_name" --noudevsync --table \
"0 $partition_size snapshot $read_only_partition $writable_device $persistent $chunksize"
dmsetup mknodes --noudevsync "$writable_partition_name"
-exceptions.deactivate
# endregion
) || exit $?
+exceptions.deactivate
# region vim modline
# vim: set tabstop=4 shiftwidth=4 expandtab:
diff --git a/builder/dnbd3-rootfs/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh b/builder/dnbd3-rootfs/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh
index 118ef921..fd00593c 100755
--- a/builder/dnbd3-rootfs/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh
+++ b/builder/dnbd3-rootfs/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh
@@ -1,3 +1,3 @@
source "/etc/openslx"
-mkdir --parents "$SLX_CONFIGURATION_LOCATION"
+mkdir --parents "${NEWROOT}${SLX_CONFIGURATION_LOCATION}"
cp "/etc/openslx" "${NEWROOT}${SLX_CONFIGURATION_LOCATION}"