summaryrefslogtreecommitdiffstats
path: root/testModule/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'testModule/hooks')
-rwxr-xr-xtestModule/hooks/cmdline.sh22
-rwxr-xr-xtestModule/hooks/cmdlineOLD.sh30
-rwxr-xr-xtestModule/hooks/mount.sh10
-rwxr-xr-xtestModule/hooks/nbd-cmdline.sh5
-rwxr-xr-xtestModule/hooks/pre-mount.sh24
-rwxr-xr-xtestModule/hooks/pre-udev.sh44
6 files changed, 81 insertions, 54 deletions
diff --git a/testModule/hooks/cmdline.sh b/testModule/hooks/cmdline.sh
new file mode 100755
index 00000000..b1f06ea6
--- /dev/null
+++ b/testModule/hooks/cmdline.sh
@@ -0,0 +1,22 @@
+echo 1 > /proc/sys/kernel/sysrq
+
+# fakes the cmdline to fix the ip parsing when using
+# syslinux's IPAPPEND 1 mask
+[ -d /fake ] || mkdir /fake
+
+# need to be a tmpfs for the hack to work
+mount -t tmpfs tmpfs /fake
+
+# append ':hiwi:eth0:none' to the 'ip=' parameter we got
+# from syslinux's IPAPPEND 1
+sed 's/\(ip=\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}:\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\)/\1:hiwi:eno1:none/' /proc/cmdline > /fake/cmdline
+
+# bind mount it. Can we trust mount return codes here?
+# if so, we should check what we get in $?
+mount -o bind /fake/cmdline /proc/cmdline
+
+# check if it worked
+if ! grep 'hiwi:eth0:none' /proc/cmdline; then
+ command -v warn >/dev/null || . /lib/dracut-lib.sh
+ warn 'Haxing cmdline did not work :( sad pandaz...'
+fi
diff --git a/testModule/hooks/cmdlineOLD.sh b/testModule/hooks/cmdlineOLD.sh
deleted file mode 100755
index 95f6f6a6..00000000
--- a/testModule/hooks/cmdlineOLD.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-# Converts ip configuration format given by the pxe pre boot provider to a
-# dracut compatible static ip configuration.
-
-source /usr/lib/test-library.sh
-
-for parameter in $(getargs ip=); do
- local temp="$parameter:"
- set --
- while [ -n "$temp" ]; do
- set -- "$@" "${temp%%:*}"
- temp=${temp#*:}
- done
-
- [ -n "$1" ] && ip=$1
- [ -n "$2" ] && server_ip=$2
- [ -n "$3" ] && gateway_ip=$3
- [ -n "$4" ] && net_mask=$4
-
- warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask"
- local final_dracut_ip_config="$ip:$server_ip:$gateway_ip:$net_mask:dracut_test_client:enp0s3:none"
- warn "Final dracut ip config: $final_dracut_ip_config"
- replace_cmd ip "$final_dracut_ip_config"
- echo "root-path=nfs:$server_ip:/">>/tmp/cmdline
-done
-
-# NOTE: Doesn't work since dracuts needed version of mount doesn't support
-# binds.
-#cat /proc/cmdline | sed --regexp-extended 's/ip=[^ ]+//g' \
-# >"$temporary_kernel_commandline_file_path" && \
-#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline
diff --git a/testModule/hooks/mount.sh b/testModule/hooks/mount.sh
index 28958fb6..e893642d 100755
--- a/testModule/hooks/mount.sh
+++ b/testModule/hooks/mount.sh
@@ -1,7 +1,3 @@
-if [ $MOUNT_READY ]; then
- warn '............MOUNT ALREADY DONE.............'
-else
- export MOUNT_READY=true
- warn '............MOUNT.............'
- mount /dev/nbd0 /sysroot
-fi
+#!/bin/bash
+
+mount /dev/root $NEWROOT
diff --git a/testModule/hooks/nbd-cmdline.sh b/testModule/hooks/nbd-cmdline.sh
new file mode 100755
index 00000000..6464646f
--- /dev/null
+++ b/testModule/hooks/nbd-cmdline.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+rootok=1
+root=block:/dev/root
+
diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh
index 5a93aef3..b22cdc35 100755
--- a/testModule/hooks/pre-mount.sh
+++ b/testModule/hooks/pre-mount.sh
@@ -1,19 +1,9 @@
#!/usr/bin/bash
-if [ $PRE_MOUNT_READY ]; then
- warn '............PRE-MOUNT ALREADY DONE.............'
-else
- export PRE_MOUNT_READY=true
- warn '............PRE-MOUNT.............'
- insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko
- local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i \
- stage4/torben/test -r 1 -d /dev/dnbd0)"
- # NOTE: Out comment this line if you need more than on dnbd0 device and
- # determine it automatically.
- dnbd3_device_node=/dev/dnbd0
- qemu-img create -f qcow2 -o \
- backing_file="$dnbd3_device_node",backing_fmt=qcow2 /run/test.qcow2
- insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko
- /usr/bin/systemd-preserve-process-marker /usr/bin/qemu-nbd \
- --connect=/dev/nbd0 /run/test.qcow2 --socket /run/qemu-nbd-TEST
-fi
+while ! /sbin/setup-qcow2; do
+ sleep 0.5
+done
+
+while ! /sbin/setup-nbdroot; do
+ sleep 0.5
+done
diff --git a/testModule/hooks/pre-udev.sh b/testModule/hooks/pre-udev.sh
new file mode 100755
index 00000000..578169e9
--- /dev/null
+++ b/testModule/hooks/pre-udev.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/bash
+
+# include dracut-lib.sh to use 'warn'
+command -v warn >/dev/null || . /lib/dracut-lib.sh
+
+SETUP_SCRIPT="/sbin/setup-qcow2"
+NBDROOT_SCRIPT="/sbin/setup-nbdroot"
+NBD_MOD_PATH="/usr/lib/modules/current/extra/nbd.ko"
+DNBD3_MOD_PATH="/usr/lib/modules/current/extra/dnbd3.ko"
+
+# sanity checks
+if [ ! -e "${SETUP_SCRIPT}" ]; then
+ warn "No such file of directory: ${SETUP_SCRIPT}"
+ emergency_shell -n "Error in $0"
+ return 1
+fi
+if [ ! -e "${NBD_MOD_PATH}" ]; then
+ warn "No such file of directory: ${NBD_MOD_PATH}"
+ emergency_shell -n "Error in $0"
+ return 1
+fi
+if [ ! -e "${DNBD3_MOD_PATH}" ]; then
+ warn "No such file of directory: ${DNBD3_MOD_PATH}"
+ emergency_shell -n "Error in $0"
+ return 1
+fi
+
+# load the kernel modules for dnbd3 and nbd
+if ! insmod /usr/lib/modules/current/extra/dnbd3.ko; then
+ warn "Failed to load DNBD3 kernel module..."
+ emergency_shell -n "Error in $0"
+ return 1
+fi
+
+if ! insmod /usr/lib/modules/current/extra/nbd.ko; then
+ warn "Failed to load NBD kernel module..."
+ emergency_shell -n "Error in $0"
+ return 1
+fi
+
+# now let's "install" the setup script in the initqueue
+#/sbin/initqueue --settled --unique "${SETUP_SCRIPT}"
+#/sbin/initqueue --settled --unique "${NBDROOT_SCRIPT}"
+#/sbin/initqueue --settled --unique "/sbin/retry-nbdroot"