summaryrefslogtreecommitdiffstats
path: root/testModule
diff options
context:
space:
mode:
authorJonathan Bauer2015-05-27 16:32:57 +0200
committerJonathan Bauer2015-05-27 16:32:57 +0200
commit0abace2bbec9e17a3630c463e4e3c329c967334b (patch)
tree986a9bebd62c2dd596c85bf44bbec68d00cccd13 /testModule
parentremoved hacked systemd rpms and grub2.conf (diff)
downloadsystemd-init-0abace2bbec9e17a3630c463e4e3c329c967334b.tar.gz
systemd-init-0abace2bbec9e17a3630c463e4e3c329c967334b.tar.xz
systemd-init-0abace2bbec9e17a3630c463e4e3c329c967334b.zip
restructuring & bit of documentation ;)
dracut module now in 'dnbd3-qcow2-rootfs'. ALLLLL dracut related stuff goes in here!
Diffstat (limited to 'testModule')
-rwxr-xr-xtestModule/binaries/busyboxbin504912 -> 0 bytes
-rwxr-xr-xtestModule/binaries/dnbd3-clientbin31150 -> 0 bytes
-rwxr-xr-xtestModule/binaries/systemd-preserve-process-markerbin7728 -> 0 bytes
-rwxr-xr-xtestModule/debugging_tools/busyboxbin931664 -> 0 bytes
-rwxr-xr-xtestModule/debugging_tools/endlessbin6752 -> 0 bytes
-rw-r--r--testModule/debugging_tools/endless.c10
-rwxr-xr-xtestModule/debugging_tools/nbd-clientbin59639 -> 0 bytes
-rw-r--r--testModule/debugging_tools/nbd-debugging.kobin463248 -> 0 bytes
-rw-r--r--testModule/debugging_tools/network.functions23
-rwxr-xr-xtestModule/debugging_tools/qemu-nbdbin7131314 -> 0 bytes
-rwxr-xr-xtestModule/debugging_tools/qemu-nbd-systemd-markbin7128103 -> 0 bytes
-rw-r--r--testModule/debugging_tools/setup-network.sh84
-rwxr-xr-xtestModule/hooks/cmdline/enable-sysrq.sh2
-rwxr-xr-xtestModule/hooks/cmdline/expand-kcl-ip.sh36
-rwxr-xr-xtestModule/hooks/cmdline/mark-root-device.sh9
-rwxr-xr-xtestModule/hooks/mount/mount-root-device.sh4
-rwxr-xr-xtestModule/hooks/pre-mount/fetch-config.sh39
-rwxr-xr-xtestModule/hooks/pre-mount/mount-qcow.sh49
-rwxr-xr-xtestModule/hooks/pre-pivot/mount-tmp.sh40
-rwxr-xr-xtestModule/hooks/pre-udev/lo-setup.sh1
-rwxr-xr-xtestModule/hooks/pre-udev/load-dnbd3-nbd-modules.sh32
-rwxr-xr-xtestModule/kernel_modules/dnbd3.kobin1345285 -> 0 bytes
-rw-r--r--testModule/kernel_modules/nbd.kobin463216 -> 0 bytes
-rw-r--r--testModule/library.sh38
-rw-r--r--testModule/module-setup.sh121
-rwxr-xr-xtestModule/scripts/prepare-disks211
-rwxr-xr-xtestModule/scripts/setup-qcow2137
-rw-r--r--testModule/systemd-preserve-process-marker.c33
-rw-r--r--testModule/udev/70-openslx-disk.rules8
29 files changed, 0 insertions, 877 deletions
diff --git a/testModule/binaries/busybox b/testModule/binaries/busybox
deleted file mode 100755
index 7eceacf7..00000000
--- a/testModule/binaries/busybox
+++ /dev/null
Binary files differ
diff --git a/testModule/binaries/dnbd3-client b/testModule/binaries/dnbd3-client
deleted file mode 100755
index 76924b49..00000000
--- a/testModule/binaries/dnbd3-client
+++ /dev/null
Binary files differ
diff --git a/testModule/binaries/systemd-preserve-process-marker b/testModule/binaries/systemd-preserve-process-marker
deleted file mode 100755
index 45beb51d..00000000
--- a/testModule/binaries/systemd-preserve-process-marker
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/busybox b/testModule/debugging_tools/busybox
deleted file mode 100755
index 1212ae20..00000000
--- a/testModule/debugging_tools/busybox
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/endless b/testModule/debugging_tools/endless
deleted file mode 100755
index de7a8c0a..00000000
--- a/testModule/debugging_tools/endless
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/endless.c b/testModule/debugging_tools/endless.c
deleted file mode 100644
index 22c9bc50..00000000
--- a/testModule/debugging_tools/endless.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-int main(int argc, char *argv[]) {
- // Provides a dummy worker.
- while (1)
- sleep(999999999);
-}
diff --git a/testModule/debugging_tools/nbd-client b/testModule/debugging_tools/nbd-client
deleted file mode 100755
index 7bb2207f..00000000
--- a/testModule/debugging_tools/nbd-client
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/nbd-debugging.ko b/testModule/debugging_tools/nbd-debugging.ko
deleted file mode 100644
index 47cf6cd6..00000000
--- a/testModule/debugging_tools/nbd-debugging.ko
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/network.functions b/testModule/debugging_tools/network.functions
deleted file mode 100644
index 89ca5a20..00000000
--- a/testModule/debugging_tools/network.functions
+++ /dev/null
@@ -1,23 +0,0 @@
-wait_for_iface() {
- local DEVICE=$1
- local TIMEOUT=10
- echo -n "Waiting for interface $DEVICE: "
- # Some systems don't have operstate. Seems to be hardware dependent
- [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 10000
- if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
- while true; do
- # check linkstate
- [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
- TIMEOUT=$(( $TIMEOUT - 1 )) # don't wait forever, the pcnet iface of vmware will never be "up" although it's working
- [ "$TIMEOUT" -le 0 ] && break
- # else
- echo -n "."
- usleep 500000
- done
- else
- # we really don't have a operstate .. then just wait a sec and hope for the best.
- sleep 1
- fi
- echo ".$(cat "/sys/class/net/${DEVICE}/operstate" 2>/dev/null)"
-}
-true
diff --git a/testModule/debugging_tools/qemu-nbd b/testModule/debugging_tools/qemu-nbd
deleted file mode 100755
index b34a3ff7..00000000
--- a/testModule/debugging_tools/qemu-nbd
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/qemu-nbd-systemd-mark b/testModule/debugging_tools/qemu-nbd-systemd-mark
deleted file mode 100755
index 03c2a6b1..00000000
--- a/testModule/debugging_tools/qemu-nbd-systemd-mark
+++ /dev/null
Binary files differ
diff --git a/testModule/debugging_tools/setup-network.sh b/testModule/debugging_tools/setup-network.sh
deleted file mode 100644
index 3b32a68c..00000000
--- a/testModule/debugging_tools/setup-network.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/bin/bash
-
-echo "Setting up network..."
-
-echo "Main MAC address is '$MAC'"
-
-# setup network
-source /inc/network.functions
-
-# set up loopback networking
-echo "Setting up loopback"
-ip link set dev lo up 2>/dev/null
-ip addr add 127.0.0.1/8 dev lo 2>/dev/null
-
-echo "Setting up bridge"
-BRIDGE="br0"
-
-# Following was supposed to prevent scripts from getting confused by multiple interfaces with same MAC - does not work though
-## Flip mac address of original interface - this var is not local so init sees the changes too
-#MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')"
-#ip link set addr "$MAC" "$SLAVE"
-
-mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d"
-
-#IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':')
-IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#')
-
-if ! echo "$IP_OUT" | grep -q -- "$MAC"; then
- drop_shell "Boot interface not found in interface list. NIC driver missing?"
-fi
-
-for LINE in $IP_OUT; do
- IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}')
- IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm
- echo "${IFACE} = ${IFMAC}"
-
- if [ "x$IFMAC" == "x$MAC" ]; then
- brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE"
- brctl stp "$BRIDGE" 0
- brctl setfd "$BRIDGE" 0.000000000001
- ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE"
- ip link set dev "$IFACE" up
- wait_for_iface "$IFACE"
- brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE"
-
- # save our variables for retry on fail
- echo "IFACE=$IFACE" > /run/network.conf
-
- # analyze ip information from the kernel command line and put parts
- # of it into several variables
- if [ -n "$CLIENTIP" ] ; then
- # set static ip address
- ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE"
- ip link set dev "$BRIDGE" up
- [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE"
- else
- NOIPYET="yes"
- fi
- # Ignore this device later on when systemd handles network interfaces (see hacked 99-systemd.rules in systemd data dir)
- echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNEL==\"eth*\", ATTR{address}==\"$IFMAC\", TAG+=\"openslxignore\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/01-ignore-boot-interface.rules"
- fi
- # youdev
- echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$IFMAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$IFACE\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/70-net-boot-nic-name.rules"
- # continue...
- IFACE=""
-done
-
-wait_for_iface "$BRIDGE"
-
-# udhcpc
-PARAM=
-if [ -n "$CLIENTIP" ]; then
- PARAM="-r $CLIENTIP"
-fi
-echo -n "$CLIENTIP" > "/run/firstip"
-echo -n "$GATEWAY" > "/run/firstgw"
-
-# save our variables for retry on fail ff.
-echo "CLIENTIP=$CLIENTIP" >> /run/network.conf
-echo "GATEWAY=$GATEWAY" >> /run/network.conf
-echo "BRIDGE=$BRIDGE" >> /run/network.conf
-
-udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
-# udhcpc return value will be return value of this script
diff --git a/testModule/hooks/cmdline/enable-sysrq.sh b/testModule/hooks/cmdline/enable-sysrq.sh
deleted file mode 100755
index f779aa7a..00000000
--- a/testModule/hooks/cmdline/enable-sysrq.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-# enables magic sysrq keys
-echo 1 > /proc/sys/kernel/sysrq
diff --git a/testModule/hooks/cmdline/expand-kcl-ip.sh b/testModule/hooks/cmdline/expand-kcl-ip.sh
deleted file mode 100755
index 9f617b09..00000000
--- a/testModule/hooks/cmdline/expand-kcl-ip.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-command -v warn >/dev/null || . /lib/dracut-lib.sh
-
-# fakes the cmdline to fix the ip parsing in darcut's net-lib.sh
-[ -d /fake ] || mkdir /fake
-
-# need to be a tmpfs for the hack to work
-mount -t tmpfs tmpfs /fake
-
-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::$gateway_ip:$net_mask:hiwi-test-28:eno1:none"
- warn "Final dracut ip config: $final_dracut_ip_config"
- sed --regexp-extended "s/ip=[^ ]*/ip=$final_dracut_ip_config/g" /proc/cmdline > /fake/cmdline
-done
-
-
-# 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-test-28:eno1:none' /proc/cmdline; then
- warn 'Haxing cmdline did not work :( sad pandaz...'
-fi
diff --git a/testModule/hooks/cmdline/mark-root-device.sh b/testModule/hooks/cmdline/mark-root-device.sh
deleted file mode 100755
index b7282521..00000000
--- a/testModule/hooks/cmdline/mark-root-device.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-# set rootok and root as dracut expects them to be set by
-# the module preparing the root filesystem.
-#
-# Once the root filesystem is mounted per dnbd3 and
-# exported as qcow2 per nbd, /dev/root will be a symlink
-# to /dev/nbd0 as this is then our rootfs-device
-rootok=1
-root=block:/dev/root
-
diff --git a/testModule/hooks/mount/mount-root-device.sh b/testModule/hooks/mount/mount-root-device.sh
deleted file mode 100755
index d02f9002..00000000
--- a/testModule/hooks/mount/mount-root-device.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-# this rudimentary script just mounts the rootfs device that was symlinked to
-# /dev/root to dracut's $NEWROOT (usually /sysroot).
-
-mount /dev/root $NEWROOT
diff --git a/testModule/hooks/pre-mount/fetch-config.sh b/testModule/hooks/pre-mount/fetch-config.sh
deleted file mode 100755
index a90481c8..00000000
--- a/testModule/hooks/pre-mount/fetch-config.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-# load dracut functions
-command -v getarg >/dev/null || . /lib/dracut-lib.sh
-
-# read SLX_SERVER and SLX_BASE from the kernel command line
-SLX_SERVER=$(getarg slxsrv)
-SLX_BASE=$(getarg slxbase)
-SLX_CONFIG_DIR="/opt/openslx"
-SLX_CONFIG_FILE="/opt/openslx/config"
-
-if [ -z "$SLX_SERVER" ]; then
- warn "No 'slxsrv' parameter found in the kernel command line!"
- warn "Skipping OpenSLX configuration..."
- return 1
-fi
-if [ -z "$SLX_BASE" ]; then
- warn "No 'slxbase' parameter found in the kernel command line!"
- warn "Skipping OpenSLX configuration..."
- return 1
-fi
-
-info "Getting configuration from OPENSLX-Server..."
-WGET="$(busybox which wget)"
-if [ -z $WGET ]; then
- # do nothing
- warn "'wget' not found. Skipping openslx configuration..."
- return 1
-fi
-
-# ok then we are ready to download the config
-mkdir -p "${SLX_CONFIG_DIR}"
-$WGET -T 5 -q "http://${SLX_SERVER}/${SLX_BASE}/config" -O "${SLX_CONFIG_FILE}"
-RET="$?"
-if [ $RET -ne 0 ]; then
- warn "Downloading OpenSLX configuration from ${SLX_SERVER}/${SLX_BASE} failed: $RET"
- emergency_shell -n "$0"
- return 1
-else
- return 0
-fi
diff --git a/testModule/hooks/pre-mount/mount-qcow.sh b/testModule/hooks/pre-mount/mount-qcow.sh
deleted file mode 100755
index d70492bf..00000000
--- a/testModule/hooks/pre-mount/mount-qcow.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-###############################################################################
-# CHECKS
-#
-
-SETUP_ROOTFS_SCRIPT="/sbin/setup-qcow2"
-
-if [ ! -e "${SETUP_ROOTFS_SCRIPT}" ]; then
- warn "No such file of directory: ${SETUP_ROOTFS_SCRIPT}"
- emergency_shell -n "Error in $0"
- return 1
-fi
-
-if [ ! -x "${SETUP_ROOTFS_SCRIPT}" ]; then
- warn "Cannot execute: ${SETUP_ROOTFS_SCRIPT}"
- emergency_shell -n "Error in $0"
- return 1
-fi
-
-#
-# END CHECKS
-###############################################################################
-
-###############################################################################
-# MAIN CODE
-#
-
-# ok, let's source the setup script
-if ! . ${SETUP_ROOTFS_SCRIPT} ; then
- warn "Could not source: ${SETUP_ROOTFS_SCRIPT}"
- emergency_shell -n "Error in $0"
- return 1
-fi
-
-# just go over the functions in the right order ;-)
-for fun in connect_dnbd3 create_qcow export_qcow connect_qcow; do
- if ! $fun; then
- # something failed, drop a shell for debugging
- warn "'$fun' failed with: $?"
- emergency_shell -n "Error in $fun"
- return 1
- fi
-done
-
-# all good, we are done
-return 0
-
-#
-# END MAIN CODE
-###############################################################################
diff --git a/testModule/hooks/pre-pivot/mount-tmp.sh b/testModule/hooks/pre-pivot/mount-tmp.sh
deleted file mode 100755
index 3e702064..00000000
--- a/testModule/hooks/pre-pivot/mount-tmp.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-# This script only checks if we found a usable partition for the
-# future /tmp. The discovery of that partition is done by udev during
-# the initqueue. If a valid partition is found (either GPT with the label
-# OPENSLX_TMP or MBR with the type 0x44) its path will be written to
-# /tmp/openslx.tmpdisk
-OPENSLX_TMP_DISK_FLAG="/tmp/openslx.disk.tmp"
-
-if [ ! -e "$OPENSLX_TMP_DISK_FLAG" ]; then
- warn "'$OPENSLX_TMP_DISK_FLAG' not found!"
- warn "Systemd will manage $NEWROOT/tmp on its own."
- # no partition for the future /tmp found, just
- # let systemd manage it then (probably a tmpfs)
- return 1
-fi
-
-# in /tmp/openslx.disk.tmp is the name of the device
-# to mount as /tmp in the real system
-# meaning we need to mount it to /sysroot/tmp here.
-
-OPENSLX_TMP_DISK_DEV="$(cat $OPENSLX_TMP_DISK_FLAG)"
-
-# sanity check: is the content a block device?
-if [ ! -b "$OPENSLX_TMP_DISK_DEV" ]; then
- warn "'$OPENSLX_TMP_DISK_DEV' appears not to be a block device!"
- warn "Systemd will manage $NEWROOT/tmp on its own."
- return 1
-fi
-
-# all good, keep on
-if ! mount -t auto "$OPENSLX_TMP_DISK_DEV" $NEWROOT/tmp; then
- # something else went wrong :(
- warn "Mounting '$OPENSLX_TMP_DISK_DEV' to '$NEWROOT/tmp' failed with: $!"
- warn "Systemd will manage $NEWROOT/tmp on its own."
- return 1
-fi
-
-# still here? mount worked wohoo
-# set permissions
-chmod a+rwxt $NEWROOT/tmp
-return 0
diff --git a/testModule/hooks/pre-udev/lo-setup.sh b/testModule/hooks/pre-udev/lo-setup.sh
deleted file mode 100755
index 9103afd9..00000000
--- a/testModule/hooks/pre-udev/lo-setup.sh
+++ /dev/null
@@ -1 +0,0 @@
-/sbin/initqueue --name ifup-lo --unique --onetime /sbin/ifup lo -m
diff --git a/testModule/hooks/pre-udev/load-dnbd3-nbd-modules.sh b/testModule/hooks/pre-udev/load-dnbd3-nbd-modules.sh
deleted file mode 100755
index 29f9f210..00000000
--- a/testModule/hooks/pre-udev/load-dnbd3-nbd-modules.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-# include dracut-lib.sh to use 'warn'
-command -v warn >/dev/null || . /lib/dracut-lib.sh
-
-NBD_MOD_PATH="/usr/lib/modules/current/extra/nbd.ko"
-DNBD3_MOD_PATH="/usr/lib/modules/current/extra/dnbd3.ko"
-
-# do we actually have our modules?
-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 "${DNBD3_MOD_PATH}"; then
- warn "Failed to load DNBD3 kernel module..."
- emergency_shell -n "Error in $0"
- return 1
-fi
-
-if ! insmod "${NBD_MOD_PATH}"; then
- warn "Failed to load NBD kernel module..."
- emergency_shell -n "Error in $0"
- return 1
-fi
-
-return 0
diff --git a/testModule/kernel_modules/dnbd3.ko b/testModule/kernel_modules/dnbd3.ko
deleted file mode 100755
index d7b7ce3b..00000000
--- a/testModule/kernel_modules/dnbd3.ko
+++ /dev/null
Binary files differ
diff --git a/testModule/kernel_modules/nbd.ko b/testModule/kernel_modules/nbd.ko
deleted file mode 100644
index e8c3f40f..00000000
--- a/testModule/kernel_modules/nbd.ko
+++ /dev/null
Binary files differ
diff --git a/testModule/library.sh b/testModule/library.sh
deleted file mode 100644
index d3f97aff..00000000
--- a/testModule/library.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-cat /proc/cmdline >/tmp/cmdline
-
-replace_cmd() {
- sed --regexp-extended "s/$1=[^ ]*/$1=$2/g" /tmp/cmdline -i
-}
-
-getcmdline() {
- local _line
- local _i
- local CMDLINE_ETC_D
- local CMDLINE_ETC
- unset _line
-
- if [ -e /etc/cmdline ]; then
- while read -r _line; do
- CMDLINE_ETC="$CMDLINE_ETC $_line";
- done </etc/cmdline;
- fi
- for _i in /etc/cmdline.d/*.conf; do
- [ -e "$_i" ] || continue
- while read -r _line; do
- CMDLINE_ETC_D="$CMDLINE_ETC_D $_line";
- done <"$_i";
- done
- ## NOTE: We modify this to be able to alter kernel command line arguments
- ## at runtime.
- if [ -e /tmp/cmdline ]; then
- read -r CMDLINE </tmp/cmdline;
- CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE"
- else
- ##
- if [ -e /proc/cmdline ]; then
- read -r CMDLINE </proc/cmdline;
- CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE"
- fi
- fi
- printf "%s" "$CMDLINE"
-}
diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh
deleted file mode 100644
index b3f14c1d..00000000
--- a/testModule/module-setup.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/bin/bash
-
-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 8 ]; 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
-}
-
-depends() {
- echo base network bash kernel-modules
- return 0
-}
-
-installkernel() {
- instmods ext4
-}
-
-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.ko" \
- /usr/lib/modules/current/extra/dnbd3.ko
- inst "$moddir/kernel_modules/nbd.ko" \
- /usr/lib/modules/current/extra/nbd.ko
-
- ### HOOKS
- ## HOOK cmdline
- # enables sysrq-shortcuts
- inst_hook cmdline 00 "$moddir/hooks/cmdline/enable-sysrq.sh"
-
- # 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"
-
- # sets environment variables to tell dracut which device
- # holds the future root filesystem
- inst_hook cmdline 90 "$moddir/hooks/cmdline/mark-root-device.sh"
-
- ## HOOK pre-udev
- # loads the dnbd3/nbd kernel modules
- inst_hook pre-udev 00 "$moddir/hooks/pre-udev/load-dnbd3-nbd-modules.sh"
-
- # setup loopback device
- inst_hook pre-udev 00 "$moddir/hooks/pre-udev/lo-setup.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"
-
- # this is the main hook where all the magic is triggered
- inst_hook pre-mount 10 "$moddir/hooks/pre-mount/mount-qcow.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"
-
- ### 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
-
- # the script triggered by udev upon finding the right partitions
- 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
-
- # Debugging Uncomment this version if you need some useful debugging tools
- # in your iniramfs.
- inst_multiple lsblk ping ip ifconfig sshd htop tail head cat vim \
- touch sed lsmod insmod qemu-img sleep route wget find lsof strace \
- chroot switch_root pivot_root qemu-nbd mount nbd-client fdisk mkfs.xfs
- # Production:
- # inst_multiple insmod qemu-img qemu-nbd
- return 0
-}
diff --git a/testModule/scripts/prepare-disks b/testModule/scripts/prepare-disks
deleted file mode 100755
index 2e68dd9e..00000000
--- a/testModule/scripts/prepare-disks
+++ /dev/null
@@ -1,211 +0,0 @@
-#!/bin/bash
-###############################################################################
-# GLOBALS
-#
-
-# flag file containing pids of running instances for concurrency checks
-declare -rg OPENSLX_DISK_FLAG="/tmp/openslx.disk"
-# file that will contain the name of the device used for the /tmp partition
-# - label 'OPENSLX_TMP' in GPT / type '0x44' in MBR
-declare -rg OPENSLX_TMP_MARKER="/tmp/openslx.disk.tmp"
-# file that will contain the name of the device used for storing qcow2
-# - label 'OPENSLX_SYS' in GPT / type '0x46' in MBR
-declare -rg OPENSLX_SYS_MARKER="/tmp/openslx.disk.sys"
-# mount point for system partition
-declare -rg OPENSLX_SYS_MOUNT="/opt/openslx/system"
-
-#
-# END GLOBALS
-###############################################################################
-
-###############################################################################
-# FUNCTION DEFINITIONS
-#
-# helper to mount the OPENSLX_SYS partition to /opt/openslx/system
-# Usage: mount_sys_part <path_to_sys_partition>
-mount_sys_part() {
- if [ ! -b "$1" ]; then
- warn "($$) Refusing to mount '$1' as its not a block device!"
- return 1
- fi
-
- local OPENSLX_SYS_DEVICE="$1"
- mkdir -p ${OPENSLX_SYS_MOUNT}
- if ! mount -t auto "${OPENSLX_SYS_DEVICE}" "${OPENSLX_SYS_MOUNT}"; then
- warn "($$) Mounting '${OPENSLX_SYS_DEVICE}' to '${OPENSLX_SYS_MOUNT}' failed."
- return 1
- fi
- return 0
-
-}
-#
-# generic helper to format the given partition with the given filesystem or
-# from the prefdefined list of xfs, ext4, ...
-# Usage: format_disk <dev> <fs>
-# e.g. format_disk /dev/sda1 xfs
-format_disk () {
- local TARGET_DEVICE="$1"
- local fslist="xfs ext4"
- # if we have a second arguments, its the filesystem of choice
- local fs
- [ $# -ge 2 ] && fslist="$2"
- for fs in $fslist ; do
- unset found
- local MKFS="$(busybox which mkfs.$fs)"
- if [ -n $MKFS ]; then
- found=yes
- case "mkfs.$fs" in
- mkfs.xfs) fopt="-fq" ;;
- mkfs.ext4) fopt="-Fq" ;;
- esac
- info "($$) Formatting $TARGET_DEVICE as $fs"
- return $(${MKFS} ${fopt} "${TARGET_DEVICE}")
- fi
- [ -n "$found" ] && break
- done
- # still here? then we didn't find a proper formatter...
- warn "($$) Could not format $PART_DEV as $fs."
- return 1
-}
-
-#
-# END FUNCTION DEFINITIONS
-###############################################################################
-
-###############################################################################
-# MAIN CODE
-#
-
-command -v warn >/dev/null || . /lib/dracut-lib.sh
-
-# let check the arguments
-if [ "$#" -ne 2 ]; then
- warn "($$) '$0' need 2 arguments: '$0 [OPENSLX_SYS|OPENSLX_TMP] <dev_path>'"
- exit 1
-fi
-# $1 sane?
-if [ "x$1" != "xOPENSLX_SYS" ] && [ "x$1" != "xOPENSLX_TMP" ]; then
- warn "($$) First arg needs to be either 'OPENSLX_SYS' or 'OPENSLX_TMP', given: $1"
- exit 1
-fi
-# $2 sane?
-if [ ! -b "/dev/$2" ]; then
- warn "($$) Second arg appears not to be a block device!"
- exit 1
-fi
-
-# ok all seems well, set the arguments
-PART_TYPE="$1"
-PART_DEV="/dev/$2"
-
-unset OPENSLX_TMP_DEVICE
-unset OPENSLX_SYS_DEVICE
-
-# lets check if we are already running
-INSTANCES="$(grep "$PART_TYPE" "$OPENSLX_DISK_FLAG" | busybox wc -l)"
-if [ "$INSTANCES" -ge 1 ]; then
- # uhoh we are not alone! Need to check
- # if the other instance actually did its job
- warn "($$) '$0' already running for $PART_TYPE on $PART_DEV... checking state."
- # here two/three cases depending on which PART_TYPE we are
- # currently processing.
- for timeout in 1 1 2; do
- # always give the other instance time to finish
- # but only check 3 times overall
- sleep $timeout
- case "$PART_TYPE" in
- OPENSLX_TMP)
- # was the tmp partition marker created with a device?
- if [ ! -f "${OPENSLX_TMP_MARKER}" ]; then
- info "($$) Invalid state: no marker for $PART_TYPE"
- continue
- fi
- # it was, is it a valid block device?
- OPENSLX_TMP_DEVICE="$(cat ${OPENSLX_TMP_MARKER})"
- if [ -z $OPENSLX_TMP_DEVICE -o ! -b $OPENSLX_TMP_DEVICE ]; then
- info "($$) Invalid state: no for device $OPENSLX_TMP_DEVICE"
- continue
- fi
- # its detected, its a block device and as mounting is
- # done later, we can not check for more at this point
- info "($$) Valid state for $OPENSLX_TMP_DEVICE as $PART_TYPE"
- exit 0
- ;;
- OPENSLX_SYS)
- # was the system partition marker created with a device?
- if [ ! -f "${OPENSLX_SYS_MARKER}" ]; then
- info "($$) Invalid state: no marker for $PART_TYPE"
- continue
- fi
- # it was, is it a valid block device?
- OPENSLX_SYS_DEVICE="$(cat ${OPENSLX_SYS_MARKER})"
- if [ -z $OPENSLX_SYS_DEVICE -o ! -b $OPENSLX_SYS_DEVICE ]; then
- info "($$) Invalid state: no for device $OPENSLX_SYS_DEVICE"
- continue
- fi
- # its detected, its a block device, is it mounted?
- if mount | grep -qE "^$OPENSLX_SYS_DEVICE\ on $OPENSLX_SYS_MOUNT"; then
- info "($$) Valid state for $OPENSLX_SYS_DEVICE as $PART_TYPE"
- exit 0
- fi
- # if its not mounted, we want to keep on, so no exit!
- ;;
- *)
- # weird case which should never happen
- warn "($$) If you see this, then $0 was called with a bad PART_TYPE: $@"
- continue
- ;;
- esac
- done
- warn "($$) Timeout reached!"
- warn "($$) '$PART_TYPE' was found but not device was associated to it!"
-fi
-
-# We write our pid to $OPENSLX_DISK_FLAG in order to make sure
-# we are the only instance of this script running.
-info "($$) Processing: $PART_TYPE -> $PART_DEV ($$)"
-echo "$PART_TYPE.$$" >> "$OPENSLX_DISK_FLAG"
-
-# if we are still here, then we can go on and process the partition
-if [ "$PART_TYPE" = "OPENSLX_TMP" ]; then
- # always format /tmp partition
- if ! format_disk "${PART_DEV}" xfs; then
- # error while formatting, cleanup
- warn "($$) Error formatting $PART_DEV ... removing $$"
- sed -i "/^${PART_TYPE}\.$$/d" "${OPENSLX_DISK_FLAG}"
- exit 1
- fi
- info "($$) Using '$PART_DEV' as '$PART_TYPE'"
- # mark it for later: in pre-pivot we will check this file
- # and mount it as $NEWROOT/tmp
- echo "$PART_DEV" > "$OPENSLX_TMP_MARKER"
- # remove our pid from OPENSLX_DISK_FLAG
- sed -i "/^${PART_TYPE}\.$$/d" "${OPENSLX_DISK_FLAG}"
- exit 0
-fi
-if [ "$PART_TYPE" = "OPENSLX_SYS" ]; then
- # TODO make the formatting of the system partition configurable
- if ! format_disk "${PART_DEV}" xfs; then
- # error while formatting, cleanup
- warn "($$) Error formatting $PART_DEV ... removing $$"
- sed -i "/^${PART_TYPE}\.$$/d" "${OPENSLX_DISK_FLAG}"
- exit 1
- fi
- # mark it
- # mount it now, since qemu-nbd needs it asap!
- if mount_sys_part "$PART_DEV"; then
- # mount worked, mark it as done
- info "($$) Using '$PART_DEV' as '$PART_TYPE'"
- echo "$PART_DEV" > "$OPENSLX_SYS_MARKER"
- sed -i "/^${PART_TYPE}\.$$/d" "${OPENSLX_DISK_FLAG}"
- exit 0
- else
- warn "($$) 'mount_sys_part' failed in $0"
- sed -i "/^${PART_TYPE}\.$$/d" "${OPENSLX_DISK_FLAG}"
- exit 1
- fi
-fi
-
-#
-# END MAIN CODE
-###############################################################################
diff --git a/testModule/scripts/setup-qcow2 b/testModule/scripts/setup-qcow2
deleted file mode 100755
index 70babc17..00000000
--- a/testModule/scripts/setup-qcow2
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/usr/bin/bash
-
-# dracut-lib to use debugging functions
-command -v warn >/dev/null || . /lib/dracut-lib.sh
-command -v emergency_shell >/dev/null || . /lib/dracut-lib.sh
-
-###############################################################################
-# GLOBALS
-#
-# TODO make this configurable
-[ -f /opt/openslx/config ] && . /opt/openslx/config
-[ -z $SLX_DNBD3_SERVER ] && SLX_DNBD3_SERVER="132.230.4.1"
-[ -z $SLX_STAGE4 ] && SLX_STAGE4="stage4/joe/centos7"
-[ -z $SLX_STAGE4_RID ] && SLX_STAGE4_RID="4"
-declare -rg DNBD3_SERVER="$SLX_DNBD3_SERVER"
-declare -rg DNBD3_IMAGE="$SLX_STAGE4"
-declare -rg DNBD3_RID="$SLX_STAGE4_RID"
-declare -rg DNBD3_DEVICE="/dev/dnbd0"
-declare -rg QCOW_CONTAINER="/opt/openslx/system/system.qcow2"
-#
-# END GLOBALS
-###############################################################################
-
-###############################################################################
-# FUNCTION DEFINITIONS
-#
-# helper to do some sanity checks
-check_dnbd3() {
- if [ ! command -v "dnbd3-client" >/dev/null ]; then
- warn "No 'dnbd3-client' found. Was the initramfs built correctly?"
- emergency_shell -n "Error in $0"
- return 1
- fi
- return 0
-}
-
-# helper to connect to the dnbd3-server
-connect_dnbd3() {
- # check if it already connected
- local current_image_name="$(cat /sys/block/${DNBD3_DEVICE#/dev/}/net/image_name)"
- [ "x${current_image_name}" != "x(null)" ] && return 0
-
- # not connected yet, do it
- if ! dnbd3-client -h "${DNBD3_SERVER}" \
- -i "${DNBD3_IMAGE}" \
- -r "${DNBD3_RID}" \
- -d "${DNBD3_DEVICE}" ; then
- warn "Failed to mount $DNBD3_IMAGE from $DNBD3_SERVER to $DNBD3_DEVICE"
- emergency_shell -n "Error in $0"
- return 1
- fi
- return 0
-}
-
-# helper to create the qcow2 container file using
-# DNBD3_DEVICE as the base of the filesystem
-# QCOW_CONTAINER as the writable file
-# (our future rootfs)
-create_qcow() {
- # check if we already created the qcow2-container
- [ -e "$QCOW_CONTAINER" ] && return 0
-
- # check if we have our target directory, if not create it
- [ ! -d "$(busybox dirname $QCOW_CONTAINER)" ] && \
- mkdir -p "$(busybox dirname $QCOW_CONTAINER)"
-
- # we did not, let's create it
- if ! qemu-img create -f qcow2 -o \
- backing_file="$DNBD3_DEVICE",backing_fmt=qcow2 "$QCOW_CONTAINER"; then
- warn "Failed to create qcow2-Container from $DNBD3_DEVICE"
- emergency_shell -n "Error in $0"
- rm -f -- "$QCOW_CONTAINER"
- return 1
- fi
- return 0
-}
-# helper to start qemu-nbd on localhost:2000
-# use our wrapper to set argv[0][0] to '@'
-# this keeps qemu-nbd running after switching root
-export_qcow() {
- # check if we already have a qemu-nbd
- if [ -e /tmp/qemu-nbd.pid ]; then
- kill -0 $(cat /tmp/qemu-nbd.pid) && return 0
- fi
- # since we use the wrapper, we need a little more logic to see if it runs
- /usr/bin/systemd-preserve-process-marker \
- /usr/bin/qemu-nbd -t -p 2000 "$QCOW_CONTAINER" &
- # the wrapper returns 255 if the qemu-nbd binary is missing
- local qemu_nbd_pid="$!"
- for i in 0.5 1 2; do
- sleep $i
- if ! kill -0 $qemu_nbd_pid; then
- # not running
- wait $qemu_nbd_pid
- local ret_wrapper="$?"
- if [ "${ret_wrapper}" -eq 127 ]; then
- # wrapper was not found by bash
- warn "No such file or directory: /usr/bin/systemd-preserve-process-marker"
- elif [ "${ret_wrapper}" -eq 255 ]; then
- # qemu-nbd was not found
- warn "No such file or directory: /usr/bin/qemu-nbd"
- fi
- emergency_shell -n "Error in $0"
- return 1
- else
- # all good, qemu-nbd is running, remember its pid
- echo $qemu_nbd_pid > /tmp/qemu-nbd.pid
- return 0
- fi
- done
- # fallback
- return 1
-}
-# helper to mount the qcow2-container per nbd
-connect_qcow() {
- # try to mount the locally exported qcow2-container using nbd-client
- if /usr/bin/systemd-preserve-process-marker \
- nbd-client --persist 127.0.0.1 2000 /dev/nbd0; then
- # it worked, lets set the symlink to /dev/root as dracut needs it
- # later on to mount that device to the future root (/sysroot)
- ln -sf /dev/nbd0 /dev/root
- return 0
- else
- # this is pretty bad, dracut would spawn an emergency later on
- # since there is no /dev/root to mount.
- # For debugging purposes, we drop an emergency shell ourselves
- # if the mount fails.
- warn "Could not mount /dev/nbd0 from 127.0.0.1:2000."
- emergency_shell -n "Error in $0"
- return 1
- fi
-}
-#
-# END FUNCTION DEFINITIONS
-###############################################################################
-
-# No main, use functions!
diff --git a/testModule/systemd-preserve-process-marker.c b/testModule/systemd-preserve-process-marker.c
deleted file mode 100644
index 8f0fc108..00000000
--- a/testModule/systemd-preserve-process-marker.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-void print_array(int argc, char *argv[]) {
- // Helper function to print given array with given length.
- int i = 0;
- int j = 0;
- for (i = 0; i < argc; i ++) {
- j = 0;
- while(argv[i][j] != '\0')
- printf("%c", argv[i][j++]);
- printf(" ");
- }
- printf("\n");
-}
-int main(int argc, char *argv[]) {
- int count;
- // Last item acts as null pointer.
- char **copy = calloc(sizeof(char *), argc);
- // Slice first given command line argument.
- for (count = 0; count < argc - 1; count++)
- copy[count] = strdup(argv[count + 1]);
- // Adding systemd indicator to preserve wrapped process during changing
- // root filesystem. We mark wrapper and child process.
- argv[0][0] = '@';
- copy[0][0] = '@';
- if (-1 == execvp(argv[1], copy)) {
- perror("Executing child process failed.");
- return -1;
- }
-}
diff --git a/testModule/udev/70-openslx-disk.rules b/testModule/udev/70-openslx-disk.rules
deleted file mode 100644
index 3f5e382f..00000000
--- a/testModule/udev/70-openslx-disk.rules
+++ /dev/null
@@ -1,8 +0,0 @@
-# GPT rules
-KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART_ENTRY_NAME}=="OPENSLX_TMP" RUN+="/sbin/prepare-disks %E{ID_PART_ENTRY_NAME} %k"
-KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART_ENTRY_NAME}=="OPENSLX_SYS" RUN+="/sbin/prepare-disks %E{ID_PART_ENTRY_NAME} %k"
-
-# MBR rules
-KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="dos" ENV{ID_PART_ENTRY_TYPE}=="0x44" RUN+="/sbin/prepare-disks OPENSLX_TMP %k"
-KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="dos" ENV{ID_PART_ENTRY_TYPE}=="0x46" RUN+="/sbin/prepare-disks OPENSLX_SYS %k"
-