diff options
| author | jandob | 2016-01-07 16:40:37 +0100 |
|---|---|---|
| committer | jandob | 2016-01-07 16:40:37 +0100 |
| commit | fc39d8b96dfe1874d625dd4daa389b56f775699d (patch) | |
| tree | 1b657ee8a50a37b7f15f8e8a099aedd7c673c951 /builder | |
| parent | change hooks variable scoping; introduce /etc/openslx config (diff) | |
| download | systemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.tar.gz systemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.tar.xz systemd-init-fc39d8b96dfe1874d625dd4daa389b56f775699d.zip | |
change hooks variable scoping
Diffstat (limited to 'builder')
5 files changed, 69 insertions, 29 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}" diff --git a/builder/dnbd3-rootfs/module-setup.sh b/builder/dnbd3-rootfs/module-setup.sh index b4440ddd..3b60417d 100755 --- a/builder/dnbd3-rootfs/module-setup.sh +++ b/builder/dnbd3-rootfs/module-setup.sh @@ -68,6 +68,7 @@ check() { } depends() { + # DEBUG: echo base network bash kernel-modules systemd-initrd dracut-systemd fs-lib rootfs-block echo base network bash kernel-modules # NOTE: btrfs module should be used if it would work. } @@ -97,12 +98,44 @@ installkernel() { } install() { + if dracut_module_included "systemd-initrd"; then + # TODO analyze qemu-nbd pivot-root bug! + inst_script "$moddir/services/dnbd3-generator.sh" \ + $systemdutildir/system-generators/dnbd3-generator + inst "$moddir/hooks/pre-mount/prepare-root-partition.sh" \ + /sbin/dnbd3root + inst "$moddir/hooks/pre-mount/fetch-config.sh" \ + /sbin/fetch-config + #region old approach + #inst_simple "${moddir}/services/dnbd3root.service" \ + #"${systemdsystemunitdir}/dnbd3root.service" + #mkdir -p "${initdir}/${systemdsystemunitdir}/sysinit.target.wants" + #ln_r "${systemdsystemunitdir}/dnbd3root.service" \ + #"${systemdsystemunitdir}/sysinit.target.wants/dnbd3root.service" + # don't kill at switch_root + #mkdir -p "${initdir}/${systemdsystemunitdir}/initrd-root-fs.target.wants" + #ln_r "${systemdsystemunitdir}/dnbd3root.service" \ + #"${systemdsystemunitdir}/initrd-root-fs.target.wants/dnbd3root.service" + # todo don't kill after switch_root + #works if initrd-root-fs wants dnbd3.service (on /sysroot) + #endregion + else + # get the openslx config from the servers configured in the kernel command + # line (${SLX_SERVER}/${SLX_SERVER_BASE}/config) + inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.sh" + # make the final blockdevice for the root system (dnbd3 -> qemu-nbd -> + # device-mapper) + inst_hook pre-mount 10 "$moddir/hooks/pre-mount/prepare-root-partition.sh" + fi + # region binaries inst "$moddir/binaries/dnbd3/build/dnbd3-client" /usr/bin/dnbd3-client inst "$moddir/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker" \ /usr/bin/systemd-preserve-process-marker + # TODO: static linked qemu-nbd still needed? + #inst "$moddir/binaries/qemu/qemu-nbd" /usr/bin/qemu-nbd # endregion @@ -115,13 +148,6 @@ install() { # load nbd.ko, dnbd3.ko inst_hook pre-udev 00 "$moddir/hooks/pre-udev/load-custom-kernel-modules.sh" - # get the openslx config from the servers configured in the kernel command - # line (${SLX_SERVER}/${SLX_SERVER_BASE}/config) - inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.sh" - # make the final blockdevice for the root system (dnbd3 -> qemu-nbd -> - # device-mapper) - inst_hook pre-mount 10 "$moddir/hooks/pre-mount/prepare-root-partition.sh" - inst_hook mount 10 "$moddir/hooks/mount/mount-root-device.sh" inst_hook pre-pivot 00 "$moddir/hooks/pre-pivot/copy-openslx-configuration-into-newroot.sh" @@ -135,18 +161,22 @@ install() { for file_path in "$moddir/scripts/rebash/"*; do inst "$file_path" "/usr/lib/rebash/$(basename "$file_path")" done + + # TODO currently not used # This script is triggered by udev upon finding the right partitions for # persistent sessions. - inst "$moddir/scripts/prepare-persistent-disks" \ - /sbin/prepare-persistent-disks + #inst "$moddir/scripts/prepare-persistent-disks" \ + #/sbin/prepare-persistent-disks # endregion # region configuration files + # TODO currently not used # Udev rules detecting 44, 45, 46 partitions and running # "prepare-persistent-disks" to prepare persistent partitions. - inst "$moddir/udev/70-openslx-disk.rules" /etc/udev/rules.d/70-openslx-disk.rules + #inst "$moddir/udev/70-openslx-disk.rules" /etc/udev/rules.d/70-openslx-disk.rules + # Use terminal readline settings from the template system. inst /etc/inputrc /etc/inputrc @@ -156,10 +186,17 @@ install() { inst_multiple lsblk ping ip ifconfig sshd htop tail head vim touch sed \ lsmod sleep route wget find lsof strace chroot switch_root pivot_root \ mount fdisk mkfs.xfs env busybox ps agetty \ - insmod qemu-nbd blockdev partx dmsetup sed cut awk tr insmod qemu-nbd \ + insmod blockdev partx dmsetup sed cut awk tr insmod qemu-nbd \ blockdev partx dmsetup cat cut awk losetup dd mkfs.ext4 grep \ - basename dirname sort + basename dirname sort diff mktemp nohup genfstab mountpoint qemu-img # Production: - # inst_multiple insmod qemu-nbd blockdev partx dmsetup cat cut awk tr \ + # inst_multiple insmod blockdev partx dmsetup cat cut awk tr \ # losetup dd mkfs.ext4 grep } + +# region vim modline + +# vim: set tabstop=4 shiftwidth=4 expandtab: +# vim: foldmethod=marker foldmarker=region,endregion: + +# endregion |
