summaryrefslogtreecommitdiffstats
path: root/builder/dnbd3-qcow2-rootfs/module-setup.sh
diff options
context:
space:
mode:
authortorben2015-11-05 15:25:43 +0100
committertorben2015-11-05 15:25:43 +0100
commit5d853b5a1f037ef0888fd039fdf4bd86739fcb11 (patch)
tree1d92b1a99fb8a3faf79cb3aec130bf4929fa87cc /builder/dnbd3-qcow2-rootfs/module-setup.sh
parentMerge branch 'master' of git.openslx.org:openslx-ng/systemd-init (diff)
downloadsystemd-init-5d853b5a1f037ef0888fd039fdf4bd86739fcb11.tar.gz
systemd-init-5d853b5a1f037ef0888fd039fdf4bd86739fcb11.tar.xz
systemd-init-5d853b5a1f037ef0888fd039fdf4bd86739fcb11.zip
Refactor structure.
Diffstat (limited to 'builder/dnbd3-qcow2-rootfs/module-setup.sh')
-rwxr-xr-xbuilder/dnbd3-qcow2-rootfs/module-setup.sh115
1 files changed, 36 insertions, 79 deletions
diff --git a/builder/dnbd3-qcow2-rootfs/module-setup.sh b/builder/dnbd3-qcow2-rootfs/module-setup.sh
index 4d8418b3..eb81f347 100755
--- a/builder/dnbd3-qcow2-rootfs/module-setup.sh
+++ b/builder/dnbd3-qcow2-rootfs/module-setup.sh
@@ -1,114 +1,72 @@
#!/bin/bash
+source "$moddir/scripts/utils.sh"
+
check() {
- if ! type -f qemu-nbd >/dev/null; then
- echo "'qemu-nbd' not found on this system, install it to use this module."
- return 1
- fi
- if ! type -f qemu-img >/dev/null; then
- echo "'qemu-img' not found on this system, install it to use this module."
- return 1
- fi
- if ! type -f nbd-client >/dev/null; then
- echo "'nbd-client' not found on this system, install it to use this module."
- return 1
- else
- # check version
- local nbd_client_version="$(nbd-client --help 2>&1 | grep -oE '3\.[0-9]+')"
- local nbd_client_version_major="${nbd_client_version%.*}"
- local nbd_client_version_minor="${nbd_client_version#*.}"
- if [ "${nbd_client_version_major}" -ne 3 ]; then
- # nbd-client probably too old
- echo "The nbd-client major version is not 3, meaning its probably too old."
- return 1
- fi
- if [ "${nbd_client_version_minor}" -gt 11 ]; then
- # TODO check if ver = 3.9 has the same new syntax...
- echo "The nbd-client minor version is greater than 8. A new syntax has been
- introduced starting with 3.10 which we do not support."
- return 1
- fi
- return 0
- fi
+ compile_nbd && \
+ compile_dnbd3 && \
+ compile_systemd_preserve_process_marker &&
}
depends() {
echo base network bash kernel-modules
- return 0
}
installkernel() {
- instmods ext4
+ inst "$moddir/binaries/dnbd3/build/dnbd3.ko" \
+ /usr/lib/modules/current/extra/dnbd3.ko
+ inst "$moddir/binaries/nbd/nbd.ko" \
+ /usr/lib/modules/current/extra/nbd.ko
+
+ instmods ext4 btrfs
}
install() {
- ### BINARIES
- #
- # busybox: cause we want lightweight tools
- inst "$moddir/binaries/busybox" /usr/bin/busybox
- # dnbd3-client: needed to mount remote dnbd3 filesystem.
- inst "$moddir/binaries/dnbd3-client" /usr/bin/dnbd3-client
- # A generic wrapper program to prepend a "@" to each process
- # spawned by given nested programs.
- inst "$moddir/binaries/systemd-preserve-process-marker" \
- /usr/bin/systemd-preserve-process-marker
- # NOTE: These modules are build again Kernel: 3.10.0-229.1.2.el7.x86_64
- # TODO: build these in check() !
- inst "$moddir/kernel_modules/dnbd3/build/dnbd3.ko" \
- /usr/lib/modules/current/extra/dnbd3.ko
- inst "$moddir/kernel_modules/nbd/nbd.ko" \
- /usr/lib/modules/current/extra/nbd.ko
+ # region binaries
- ### HOOKS
- ## HOOK cmdline
- # enables sysrq-shortcuts
- inst_hook cmdline 00 "$moddir/hooks/cmdline/enable-sysrq.sh"
+ 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
- # expands the ip parameter in the kernel command line to
- # make it dracut-compatible
- # TODO: dracut still parses this incorrectly...
- inst_hook cmdline 10 "$moddir/hooks/cmdline/expand-kcl-ip.sh"
+ # endregion
- # sets environment variables to tell dracut which device
- # holds the future root filesystem
- inst_hook cmdline 90 "$moddir/hooks/cmdline/mark-root-device.sh"
+ # region hooks
- ## HOOK pre-udev
- # loads the dnbd3/nbd kernel modules
- inst_hook pre-udev 00 "$moddir/hooks/pre-udev/load-dnbd3-nbd-modules.sh"
+ inst_hook cmdline 00 "$moddir/hooks/cmdline/enable-sysrq.sh"
+ inst_hook cmdline 10 "$moddir/hooks/cmdline/prepare-network-kcl-parameter.sh"
+ inst_hook cmdline 90 "$moddir/hooks/cmdline/set-dracut-environment-variables.sh"
- # setup loopback device
- inst_hook pre-udev 00 "$moddir/hooks/pre-udev/lo-setup.sh"
+ inst_hook pre-udev 00 "$moddir/hooks/pre-udev/load-custom-kernel-modules.sh"
+ inst_hook pre-udev 00 "$moddir/hooks/pre-udev/setup-loopback-device.sh"
- ## HOOK pre-mount
# this is the configuration hook where the config stuff is wget'ed
- inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.sh"
-
+ # TODO
+ #inst_hook pre-mount 00 "$moddir/hooks/pre-mount/fetch-config.sh"
# this is the main hook where all the magic is triggered
- inst_hook pre-mount 10 "$moddir/hooks/pre-mount/mount-qcow.sh"
+ #inst_hook pre-mount 10 "$moddir/hooks/pre-mount/mount-qcow.sh"
+
+ inst_hook pre-mount 10 "$moddir/hooks/pre-mount/prepare-root-partition.sh"
- ## HOOK mount
- # this simply mounts the prepared /dev/root to $NEWROOT
- # aka "the dracut way"
inst_hook mount 10 "$moddir/hooks/mount/mount-root-device.sh"
- ## HOOK pre-pivot
- # this checks whether we found a partition suitable for
- # the future /tmp and if so, mounts it
inst_hook pre-pivot 00 "$moddir/hooks/pre-pivot/mount-tmp.sh"
+ # endregion
+
+ ## TODO deprecated
### SCRIPTS
# the main magic script containing all the functions needed
# to prepare the qcow2-based root filesystem
- inst "$moddir/scripts/setup-qcow2" /sbin/setup-qcow2
-
+ #inst "$moddir/scripts/setup-qcow2" /sbin/setup-qcow2
+ #
# the script triggered by udev upon finding the right partitions
- inst "$moddir/scripts/prepare-disks" /sbin/prepare-disks
-
+ #inst "$moddir/scripts/prepare-disks" /sbin/prepare-disks
+ ##
# udev rules detecting 44, 45, 46 partitions and running
# 'prepare-disks' to do then format/mount/use them
- 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
+ ##
# Debugging Uncomment this version if you need some useful debugging tools
# in your iniramfs.
@@ -117,5 +75,4 @@ install() {
chroot switch_root pivot_root qemu-nbd mount nbd-client fdisk mkfs.xfs
# Production:
# inst_multiple insmod qemu-img qemu-nbd
- return 0
}