summaryrefslogtreecommitdiffstats
path: root/builder/modules.d
diff options
context:
space:
mode:
Diffstat (limited to 'builder/modules.d')
-rwxr-xr-xbuilder/modules.d/bootnet-conf/module-setup.sh13
-rwxr-xr-xbuilder/modules.d/bootnet-conf/scripts/gen-bootnet-conf.sh18
-rwxr-xr-xbuilder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh42
-rwxr-xr-xbuilder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh72
-rwxr-xr-xbuilder/modules.d/conf-tgz/module-setup.sh46
m---------builder/modules.d/dnbd3-rootfs/binaries/dnbd30
m---------builder/modules.d/dnbd3-rootfs/binaries/qemu-xmount0
-rw-r--r--builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/Makefile12
-rw-r--r--builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c33
m---------builder/modules.d/dnbd3-rootfs/binaries/xmount0
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/configuration/bash3
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh33
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh66
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh28
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh10
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh53
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh32
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh33
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh89
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh163
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/set-dracut-environment-variables.sh16
-rw-r--r--builder/modules.d/dnbd3-rootfs/hooks/shutdown-umount.sh8
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/module-setup.sh269
-rw-r--r--builder/modules.d/dnbd3-rootfs/scripts/build.sh126
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh35
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh34
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/scripts/device-add-write-layer.sh26
m---------builder/modules.d/dnbd3-rootfs/scripts/rebash0
-rw-r--r--builder/modules.d/dnbd3-rootfs/scripts/tools.sh105
-rw-r--r--builder/modules.d/dnbd3-rootfs/services/dnbd3root.service17
-rw-r--r--builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules7
-rwxr-xr-xbuilder/modules.d/dns/module-setup.sh13
-rwxr-xr-xbuilder/modules.d/dns/scripts/gen-resolv-conf.sh11
-rwxr-xr-xbuilder/modules.d/ib-conf/module-setup.sh13
-rwxr-xr-xbuilder/modules.d/ib-conf/scripts/gen-ib-conf.sh24
-rw-r--r--builder/modules.d/wlan-boot/README152
-rwxr-xr-xbuilder/modules.d/wlan-boot/binaries/dhcpcdbin0 -> 299775 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/binaries/systemd-preserve-process-markerbin0 -> 8776 bytes
-rw-r--r--builder/modules.d/wlan-boot/certs/Deutsche_Telekom_Root_CA_2.pem22
-rw-r--r--builder/modules.d/wlan-boot/chroot/README44
-rw-r--r--builder/modules.d/wlan-boot/chroot/environment.tarbin0 -> 5309455 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/bin/shbin0 -> 960376 bytes
-rw-r--r--builder/modules.d/wlan-boot/chroot/environment/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem22
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/ld-linux-x86-64.so.2bin0 -> 164440 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libc.so.6bin0 -> 2107816 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libcom_err.so.2bin0 -> 15840 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libcrypto.so.10bin0 -> 2016960 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libdbus-1.so.3bin0 -> 304552 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libdl.so.2bin0 -> 19520 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libgssapi_krb5.so.2bin0 -> 316528 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libk5crypto.so.3bin0 -> 202576 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libkeyutils.so.1bin0 -> 15688 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5.so.3bin0 -> 950496 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5support.so.0bin0 -> 62720 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/liblzma.so.5bin0 -> 153192 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libm.so.6bin0 -> 1141560 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libnl-3.so.200bin0 -> 118240 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libnl-genl-3.so.200bin0 -> 29352 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libpcre.so.1bin0 -> 398272 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libpthread.so.0bin0 -> 142304 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libresolv.so.2bin0 -> 110808 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/librt.so.1bin0 -> 44096 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libselinux.so.1bin0 -> 147120 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libssl.so.10bin0 -> 449880 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libtinfo.so.5bin0 -> 174520 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/lib64/libz.so.1bin0 -> 90632 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-hooks/10-wpa_supplicant118
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-run-hooks387
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/usr/bin/systemd-preserve-process-markerbin0 -> 8776 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/usr/sbin/dhcpcdbin0 -> 299775 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/chroot/environment/usr/sbin/wpa_supplicantbin0 -> 1451632 bytes
-rw-r--r--builder/modules.d/wlan-boot/chroot/wpa_libs.lst21
-rwxr-xr-xbuilder/modules.d/wlan-boot/debug/binaries/busybox.tarbin0 -> 614400 bytes
-rwxr-xr-xbuilder/modules.d/wlan-boot/debug/hooks/install_busybox.sh5
-rwxr-xr-xbuilder/modules.d/wlan-boot/debug/scripts/restart_wpa.sh7
-rw-r--r--builder/modules.d/wlan-boot/debug/services/debug-shell.service33
-rwxr-xr-xbuilder/modules.d/wlan-boot/hooks/parse-wlan-kernel-command-line-parameter.sh38
-rwxr-xr-xbuilder/modules.d/wlan-boot/hooks/prepare-newroot.sh47
-rwxr-xr-xbuilder/modules.d/wlan-boot/hooks/start_wlan.sh93
-rwxr-xr-xbuilder/modules.d/wlan-boot/module-setup.sh65
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/01-test8
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/02-dump8
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/10-wpa_supplicant118
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone48
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/20-resolv.conf204
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/29-lookup-hostname40
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/30-hostname155
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-dhcpcd-compat41
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ntp.conf141
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-yp.conf56
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ypbind.in86
-rwxr-xr-xbuilder/modules.d/wlan-boot/scripts/dhcpcd-run-hooks387
-rw-r--r--builder/modules.d/wlan-boot/services/dhcp.service14
-rw-r--r--builder/modules.d/wlan-boot/services/wpa_supplicant.service16
-rw-r--r--builder/modules.d/wlan-boot/udev/80-net-wlan.rules2
95 files changed, 3828 insertions, 0 deletions
diff --git a/builder/modules.d/bootnet-conf/module-setup.sh b/builder/modules.d/bootnet-conf/module-setup.sh
new file mode 100755
index 00000000..f1d6697f
--- /dev/null
+++ b/builder/modules.d/bootnet-conf/module-setup.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+check() {
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ echo dnbd3-rootfs
+}
+install() {
+ inst_hook pre-pivot 50 "$moddir/scripts/gen-bootnet-conf.sh"
+}
diff --git a/builder/modules.d/bootnet-conf/scripts/gen-bootnet-conf.sh b/builder/modules.d/bootnet-conf/scripts/gen-bootnet-conf.sh
new file mode 100755
index 00000000..ec82f143
--- /dev/null
+++ b/builder/modules.d/bootnet-conf/scripts/gen-bootnet-conf.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+mac="$(getargs BOOTIF=)"
+mac="$(echo $mac | cut -c 4- | tr '-' ':')"
+if [ -n "${mac}" ]; then
+ cat << EOF >> "${NEWROOT}/etc/sysconfig/network-scripts/ifcfg-bootnet"
+DEVICE=bootnet
+NAME=bootnet
+HWADDR=${mac}
+BOOTPROTO=dhcp
+ONBOOT=yes
+NM_CONTROLLED=yes
+EOF
+else
+ echo "Could not parse MAC"
+fi
diff --git a/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh
new file mode 100755
index 00000000..8c3bed23
--- /dev/null
+++ b/builder/modules.d/conf-tgz/hooks/fetch-config-tgz.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+exceptions.try
+{
+ logging.set_commands_level debug
+ logging.set_level debug
+ # NOTE: "getarg" raises an exception so deactivate exceptions for now.
+ exceptions.deactivate
+ slx_server="$(getarg slxsrv=)"
+ slx_server_base="$(getarg slxbase=)"
+ exceptions.activate
+
+ logging.info "Download config.tgz from '${slx_server}'..."
+ IFS_backup="$IFS"
+ IFS=','
+ for host in ${slx_server}; do
+ logging.info "Trying host \"$host\"."
+ if wget --timeout 5 \
+ "http://${host}/${slx_server_base}/config.tgz" \
+ --output-document "/etc/config.tgz"
+ then
+ break
+ fi
+ done
+ IFS="$IFS_backup"
+
+ if [[ ! -e "/etc/config.tgz" ]]; then
+ logging.warn "Downloading 'config.tgz' from '${slx_server}' failed. Return code: $return_code"
+ exit 1
+ fi
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
diff --git a/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
new file mode 100755
index 00000000..083fbc6e
--- /dev/null
+++ b/builder/modules.d/conf-tgz/hooks/unpack-config-tgz.sh
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+# this module unpacks the config.tgz
+temporary_extract_directory="$(mktemp -d)"
+exceptions.try
+{
+ logging.set_commands_level debug
+ logging.set_level debug
+ exceptions.activate
+ if [[ -e "/etc/config.tgz" ]]; then
+ tar --extract --preserve-permissions \
+ --file="/etc/config.tgz" \
+ --directory="$temporary_extract_directory"
+ fi
+}
+exceptions.catch
+{
+ logging.error "Failed to extract '/etc/config.tgz' to '$temporary_extract_directory'."
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# extracted to temporary directory, now check for SLX_LOCAL_CONFIGURATION
+source "/etc/openslx"
+exceptions.try
+{
+ logging.set_commands_level debug
+ logging.set_level debug
+ exceptions.activate
+ if [[ -z "$SLX_LOCAL_CONFIGURATION" ]]; then
+ logging.warn "SLX_LOCAL_CONFIGURATION is not set in '/etc/openslx'."
+ exit 0
+ fi
+ if [[ ! -d "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}" ]]; then
+ logging.warn "SLX_LOCAL_CONFIGURATION is set but no corresponding folder found in '/etc/config.tgz'."
+ exit 0
+ fi
+ # still here? then process to merge the localized configuration files with the common files.
+ cd "${temporary_extract_directory}/openslx-configs/${SLX_LOCAL_CONFIGURATION}"
+ tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${temporary_extract_directory}"
+}
+exceptions.catch
+{
+ # errors here are not critical, so no emergency shell
+ logging.error "Failed to merge local configuration files for '$SLX_LOCAL_CONFIGURATION'."
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+
+# now just copy everything from the temporary_extract_directory to the future root
+exceptions.try
+{
+ logging.set_commands_level debug
+ logging.set_level debug
+ exceptions.activate
+ cd "${temporary_extract_directory}"
+ # purge openslx-configs/
+ rm -rf "openslx-configs"
+ tar --create --preserve-permissions * | tar --extract --preserve-permissions --directory "${NEWROOT}"
+}
+exceptions.catch
+{
+ # errors here are not critical, so no emergency shell
+ logging.error "Failed to copy extracted configuration files to '$NEWROOT'."
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
diff --git a/builder/modules.d/conf-tgz/module-setup.sh b/builder/modules.d/conf-tgz/module-setup.sh
new file mode 100755
index 00000000..946344bf
--- /dev/null
+++ b/builder/modules.d/conf-tgz/module-setup.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+
+source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd '../' && \
+ cd *'dnbd3-rootfs/scripts/rebash' && pwd)/core.sh"
+core.import exceptions
+core.import logging
+
+check() {
+ local __doc__='
+ Checks whether needed assumptions are satisfied.
+
+ Example:
+
+ `check`
+ '
+
+ # Here we could build our package file.
+
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ local __doc__='
+ Outputs all dependent dracut modules to make this module work.
+
+ >>> depends
+ +doc_test_contains
+ base
+ '
+ echo base
+}
+install() {
+ local __doc__='
+ Copies all needed files into the initramfs image and registers all needed
+ dracut hooks.
+
+ Example:
+
+ `install`
+ '
+ inst_hook pre-mount 10 "$moddir/hooks/fetch-config-tgz.sh"
+ inst_hook pre-pivot 10 "$moddir/hooks/unpack-config-tgz.sh"
+ inst_multiple tar wget mktemp
+}
diff --git a/builder/modules.d/dnbd3-rootfs/binaries/dnbd3 b/builder/modules.d/dnbd3-rootfs/binaries/dnbd3
new file mode 160000
+Subproject 210b653ff4043a27992389e765a2c3a79938a54
diff --git a/builder/modules.d/dnbd3-rootfs/binaries/qemu-xmount b/builder/modules.d/dnbd3-rootfs/binaries/qemu-xmount
new file mode 160000
+Subproject 4873cd023da8511ed9792a318d1456c94904612
diff --git a/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/Makefile b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/Makefile
new file mode 100644
index 00000000..406ec50f
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/Makefile
@@ -0,0 +1,12 @@
+CC=gcc
+OPTS=-c -Wall
+SOURCES=$(wildcard *.c)
+OBJECTS=$(SOURCES:.c=.o)
+BINS=$(SOURCES:.c=)
+
+all: $(BINS)
+
+$(BINS): $(OBJECTS)
+
+clean:
+ rm -f $(BINS) $(OBJECTS)
diff --git a/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c
new file mode 100644
index 00000000..8f0fc108
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c
@@ -0,0 +1,33 @@
+#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/builder/modules.d/dnbd3-rootfs/binaries/xmount b/builder/modules.d/dnbd3-rootfs/binaries/xmount
new file mode 160000
+Subproject 015137556fce1e21273f198ae0b9158157f74f7
diff --git a/builder/modules.d/dnbd3-rootfs/configuration/bash b/builder/modules.d/dnbd3-rootfs/configuration/bash
new file mode 100755
index 00000000..adefda40
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/configuration/bash
@@ -0,0 +1,3 @@
+alias poweroff='poweroff --force'
+alias halt='poweroff'
+alias reboot='reboot --force'
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh
new file mode 100755
index 00000000..ee308af6
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-dnbd3-service-into-newroot.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+systemd_system_unit_path="$(dirname "$(find / -name dracut-mount.service \
+ -type f -print -quit)")"
+new_systemd_system_unit_path="${NEWROOT}/lib/systemd/system"
+cp "${systemd_system_unit_path}/dnbd3root.service" \
+ "${new_systemd_system_unit_path}/dnbd3root.service"
+mkdir --parents "${new_systemd_system_unit_path}/sysinit.target.wants"
+! ln --symbolic '../dnbd3root.service' \
+ "${new_systemd_system_unit_path}/sysinit.target.wants/dnbd3root.service"
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
new file mode 100755
index 00000000..a887d8c9
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-dracut-systemd-files-into-newroot.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+# Needed to be able to go back to dracut at system shutdown.
+temporary_directory_path="$(mktemp --directory)"
+mount --options bind / "$temporary_directory_path"
+cp --recursive --no-target-directory "$temporary_directory_path" /run/initramfs
+umount "$temporary_directory_path"
+rm --dir "$temporary_directory_path"
+}
+exceptions.catch
+{
+ logging.warn "Failed to copy initramfs to /run/initramfs, shutdown hooks" \
+ "will not work."
+}
+
+exceptions.try
+{
+# Dracut may not be installed on the new root. Thus copy all services over.
+systemd_system_unit_path="$(dirname "$(find / -name dracut-mount.service \
+ -type f -print -quit)")"
+new_systemd_system_unit_path="${NEWROOT}/lib/systemd/system"
+
+mkdir --parents "$new_systemd_system_unit_path/initrd.target.wants"
+for file in \
+ dracut-cmdline.service \
+ dracut-initqueue.service \
+ dracut-mount.service \
+ dracut-pre-mount.service \
+ dracut-pre-pivot.service \
+ dracut-pre-trigger.service \
+ dracut-pre-udev.service
+do
+ cp "${systemd_system_unit_path}/${file}" \
+ "${new_systemd_system_unit_path}/${file}"
+ # "ln" returns an error if the link already exists.
+ source_path="../${file}"
+ target_path="${new_systemd_system_unit_path}/initrd.target.wants/${file}"
+ ln --symbolic "$source_path" "$targetPath" &>/dev/null || \
+ logging.warn "Failed to link \"$source_path\" to \"$target_path\"."
+done
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+
+# region vim modline
+
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh b/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh
new file mode 100755
index 00000000..6a56f857
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/copy-openslx-configuration-into-newroot.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+source "/etc/openslx"
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+mkdir --parents "${NEWROOT}${SLX_CONFIGURATION_LOCATION}"
+cp "/etc/openslx" "${NEWROOT}${SLX_CONFIGURATION_LOCATION}"
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh b/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh
new file mode 100755
index 00000000..f159e3ae
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/enable-sysrq.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+
+# Enables magic sysrq kernel supported key combinations.
+echo 1 > /proc/sys/kernel/sysrq
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh
new file mode 100755
index 00000000..23c5f004
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/fetch-config.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+# NOTE: "getarg" raises an exception so deactivate exceptions for now.
+exceptions.deactivate
+configuration_file_name="$(getarg slx_configuration_filename=)"
+if [ -z "$configuration_file_name" ]; then
+ configuration_file_name='config'
+fi
+slx_server="$(getarg slxsrv=)"
+slx_server_base="$(getarg slxbase=)"
+exceptions.activate
+
+logging.info 'Getting configuration file.'
+IFS_backup="$IFS"
+IFS=','
+for host in ${slx_server}; do
+ logging.info "Trying host \"$host\"."
+ if wget --timeout 5 \
+ "http://${host}/${slx_server_base}/${configuration_file_name}" \
+ --output-document '/etc/openslx'
+ then
+ break
+ fi
+done
+IFS="$IFS_backup"
+
+if [[ ! -e "/etc/openslx" ]]; then
+ logging.warn "Downloading OpenSLX configuration file from any of the servers \"${slx_server}\" at location \"${slx_server_base}/${configuration_file_name}\" failed. Return code: $return_code"
+ exit 1
+fi
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh b/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh
new file mode 100755
index 00000000..fe153265
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/load-custom-kernel-modules.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+DNBD3_MOD_PATH="/usr/lib/modules/current/extra/dnbd3.ko"
+
+if [ ! -e "${DNBD3_MOD_PATH}" ]; then
+ logging.warn "No such file of directory: ${DNBD3_MOD_PATH}"
+ exit 1
+fi
+
+# load the kernel modules for dnbd3 and nbd
+if ! insmod "${DNBD3_MOD_PATH}"; then
+ logging.warn "Failed to load DNBD3 kernel module..."
+ exit 1
+fi
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh
new file mode 100755
index 00000000..35443def
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+if ! getarg root=; then
+ source "/etc/openslx"
+ mount /dev/mapper/root "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS
+ if [ -n "$SLX_GENERATE_FSTAB_SCRIPT" ]; then
+ eval "$SLX_GENERATE_FSTAB_SCRIPT"
+ else
+ echo "" > "$NEWROOT/etc/fstab"
+ fi
+fi
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh
new file mode 100755
index 00000000..20041ecf
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/prepare-kernel-command-line-parameter.sh
@@ -0,0 +1,89 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import exceptions
+core.import logging
+# endregion
+(
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+SLX_INITIAL_KERNEL_COMMAND_LINE="$(cat /proc/cmdline | tr --delete '\n')"
+
+# This location will be used to have a writable kernel command line file
+# location.
+writeable_proc_cmdline_path='/writable_proc_cmdline/'
+mkdir --parents "$writeable_proc_cmdline_path"
+# NOTE: The fake writeable overlay have to be a temporary filesystem for the
+# hack to work.
+mount --types tmpfs tmpfs "$writeable_proc_cmdline_path"
+echo -n "$SLX_INITIAL_KERNEL_COMMAND_LINE" > \
+ "${writeable_proc_cmdline_path}/cmdline"
+
+logging.debug \
+ '-----------------------Kernel-Command-Line:------------------------------'
+logging.debug "${SLX_INITIAL_KERNEL_COMMAND_LINE}"
+logging.debug \
+ '-------------------------------------------------------------------------'
+
+for parameter in $(getargs BOOTIF=); do
+ logging.debug "PXE given boot interface $parameter"
+ dracut_interface_name="bootnet:$(echo $parameter | \
+ sed --regexp-extended 's/.{2}[:\-]((.{2}[:\-]){5}.{2})/\1/' | \
+ sed s/-/:/g)"
+ logging.debug "Dracut interface name is: $dracut_interface_name"
+ logging.plain -n " ifname=$dracut_interface_name" >> \
+ "${writeable_proc_cmdline_path}cmdline"
+done
+for parameter in $(getargs ip=); do
+ 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
+
+ logging.debug "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask"
+ dracut_ip_configuration="$ip::$gateway_ip:$net_mask::bootnet:off"
+ logging.debug "Dracut ip configuration is: $dracut_ip_configuration"
+ sed --regexp-extended "s/ip=[^ ]*/ip=$dracut_ip_configuration/g" \
+ --in-place "${writeable_proc_cmdline_path}cmdline"
+done
+
+if [ -z "$dracut_ip_configuration" ]; then
+ logging.warn 'No "ip" parameter found in the kernel command line.'
+fi
+if [ -z "$dracut_interface_name" ]; then
+ logging.warn 'No "BOOTIF" parameter found in the kernel command line.'
+fi
+mount --options bind "${writeable_proc_cmdline_path}cmdline" /proc/cmdline
+
+if [ -z "$(getargs slxsrv=)" ]; then
+ logging.warn 'No "slxsrv" parameter found in the kernel command line.'
+ exit 1
+fi
+if [ -z "$(getargs slxbase=)" ]; then
+ logging.warn 'No "slxbase" parameter found in the kernel command line.'
+ exit 1
+fi
+
+logging.debug \
+ '-----------------------Dracut-Kernel-Command-Line:-----------------------'
+logging.debug "$(logging.cat /proc/cmdline)"
+logging.debug \
+ '-------------------------------------------------------------------------'
+)
+# region vim modline
+
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
new file mode 100755
index 00000000..3e93253f
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -0,0 +1,163 @@
+#!/usr/bin/env bash
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import '/usr/lib/openslx/tools.sh'
+core.import exceptions
+core.import utils
+core.import logging
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+# endregion
+exceptions.try
+{
+source /etc/openslx
+logging.set_commands_level debug
+logging.set_level debug
+[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
+logging.set_log_file "$SLX_LOG_FILE_PATH"
+
+# region find writable partition
+if [[ "$SLX_WRITABLE_DEVICE_IDENTIFIER" != '' ]] &&
+ ! persistent_device="$(
+ tools.find_block_device "$SLX_WRITABLE_DEVICE_IDENTIFIER" '' \
+ "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS"
+ )"
+then
+ logging.warn "Failed to find unique device with identifier" \
+ "\"${SLX_WRITABLE_DEVICE_IDENTIFIER}\"; matched devices:" \
+ "\"${persistent_device}\""
+fi
+if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" ] && [ -n "$persistent_device" ]
+then
+ persistent_mountpoint=/mnt/slx_writable_device
+ storage_file_path="${persistent_mountpoint}/$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH"
+ ! mkdir --parents "$(dirname "$storage_file_path")"
+ if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
+ logging.warn "Failed to mount $persistent_device, checking filesystem."
+ ! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \
+ "$persistent_device"
+ if ! mount --type auto "$persistent_device" "$persistent_mountpoint"
+ then
+ logging.warn "Mounting $persistent_device, still failing," \
+ "creating new filesystem on device"
+ $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \
+ "$persistent_device"
+ fi
+ if ! mount --type auto "$persistent_device" "$persistent_mountpoint"
+ then
+ logging.warn "Mounting $persistent_device, still failing," \
+ "giving up, and using ramdisk"
+ persistent_device=""
+ fi
+ fi
+ if [ -n "$persistent_device" ]; then
+ if [ ! -e "$storage_file_path" ]; then
+ # Create a sparse file.
+ dd of="$storage_file_path" bs=1M \
+ seek="$SLX_WRITABLE_DEVICE_STORAGE_MAXIMUM_FILE_SIZE_IN_MB" count=0
+ fi
+ persistent_device="$(losetup --find)"
+ losetup "$persistent_device" "$storage_file_path"
+ fi
+fi
+
+# "P" for persistent storage, "N" for not persistent (affects dmsetup call,
+# see scripts/device-add-write-layer.sh)
+persistent='N'
+if [ -n "$persistent_device" ]; then
+ writable_device="$persistent_device"
+ if [ "$SLX_WRITABLE_DEVICE_PERSISTENT" = "yes" ]; then
+ persistent='P'
+ fi
+else
+ ramdisk_size_in_kb="$SLX_RAMDISK_SIZE_IN_KB"
+ if [ "$ramdisk_size_in_kb" = '' ]; then
+ ramdisk_size_in_kb="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"
+ fi
+ # NOTE: If the kernel modul "brd" is compiled into current kernel we can't
+ # configure ram disk size dynamically. In this case it have to be
+ # configured via kernel command line: "brd.rd_size=SITE_IN_KILOBYTE"
+ # statically:
+ #! rmmod brd 2>/dev/null
+ #modprobe brd max_part=1 rd_size="$ramdisk_size_in_kb"
+ #writable_device='/dev/ram0'
+ ramdisk_location="$(mktemp)"
+ dd of="$ramdisk_location" seek="$ramdisk_size_in_kb" count=0 1>/dev/null
+ writable_device="$(losetup --find)"
+ losetup "$writable_device" "$ramdisk_location"
+fi
+# endregion
+# region connect dnbd3
+IFS_backup="$IFS"
+IFS=","
+return_code=1
+for host in ${SLX_DNBD3_SERVERS}; do
+ logging.info "Trying host \"$host\"."
+ if systemd-preserve-process-marker dnbd3-client --host "$host" --image \
+ "${SLX_DNBD3_IMAGE}" --device "$SLX_DNBD3_DEVICE" \
+ --rid "$SLX_DNBD3_RID"
+ then
+ return_code=0
+ break
+ fi
+done
+IFS="$IFS_backup"
+
+if [[ $return_code != 0 ]]; then
+ logging.warn "Failed to connect \"${SLX_DNBD3_IMAGE}\" (revision" \
+ "\"$SLX_DNBD3_RID\") from one of \"$SLX_DNBD3_SERVERS\" to" \
+ "\"$SLX_DNBD3_DEVICE\"."
+ exit 1
+fi
+# endregion
+# region scan partitions
+if [ "$SLX_LOG_FILE_PATH" != "" ]; then
+ read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE" \
+ 2>>"$SLX_LOG_FILE_PATH")"
+else
+ read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE")"
+fi
+
+
+# Fail fast if no device could be determined.
+[ -z "$read_only_device" ] && exit 1
+# endregion
+# region find read-only partition
+if [ -z "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" ]; then
+ if [ -z "$SLX_SYSTEM_PARTITION_IDENTIFIER" ]; then
+ # if empty use whole device
+ read_only_partition="$read_only_device"
+ true
+ else
+ read_only_partition="$(tools.find_block_device \
+ "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device")"
+ fi
+else
+ eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT"
+fi
+if [[ ! $? || -z "$read_only_partition" ]]; then
+ logging.error "Failed to find unique device with identifier" \
+ "\"${SLX_SYSTEM_PARTITION_IDENTIFIER}\"; matched devices:" \
+ "\"${read_only_partition}\""
+ exit 1
+fi
+# endregion
+
+logging.info "Using read-only partition: $read_only_partition"
+logging.info "Using writable device $writable_device, persistency: $persistent"
+
+# combine devices with device mapper
+device-add-write-layer "root" "$read_only_partition" "$writable_device" \
+ "$persistent"
+
+}
+exceptions.catch
+{
+ logging.error "$exceptions_last_traceback"
+ emergency_shell "error in ${BASH_SOURCE[0]}"
+}
+# region vim modline
+
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/set-dracut-environment-variables.sh b/builder/modules.d/dnbd3-rootfs/hooks/set-dracut-environment-variables.sh
new file mode 100755
index 00000000..ad80349b
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/set-dracut-environment-variables.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+
+# Set rootok and root as dracut expects them to be set by the module preparing
+# the root filesystem.
+
+# Tell dracut that we parsed the command line and all needed parameters are
+# available.
+rootok=1
+# Tell dracut where the final root fs will be located.
+root=block:/dev/devicemapper/root
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/shutdown-umount.sh b/builder/modules.d/dnbd3-rootfs/hooks/shutdown-umount.sh
new file mode 100644
index 00000000..29b52187
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/hooks/shutdown-umount.sh
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+source /etc/openslx
+
+umount /oldroot
+dmsetup --noudevsync remove root
+losetup --detach-all
+umount /mnt/*
+dnbd3-client --device "$SLX_DNBD3_DEVICE" --close
diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh
new file mode 100755
index 00000000..549900ad
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh
@@ -0,0 +1,269 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source "$(dirname "${BASH_SOURCE[0]}")/scripts/rebash/core.sh"
+core.import exceptions
+core.import logging
+core.import utils
+core.import "$(core_abs_path "$(dirname "${BASH_SOURCE[0]}")/scripts/build.sh")"
+# endregion
+# region forward "build-initrfams.sh" logging configuration if present.
+_parse_dracut_args() {
+ local __doc__='
+ Set log level via dracut logging options and returns current debug state.
+
+ >>> echo "$_debug"
+ 1
+ >>> _parse_dracut_args; echo $?
+ 1
+
+ >>> _parse_dracut_args --stdlog 3; echo $?
+
+ >>> _parse_dracut_args --stdlog 4; echo $?
+ >>> logging.get_commands_level
+ >>> logging.get_level
+ 0
+ debug
+ debug
+
+ >>> logging.get_level
+ critical
+ >>> _parse_dracut_args --stdlog 4 --verbose
+ >>> logging.get_level
+ debug
+
+ >>> _parse_dracut_args --stdlog 4 --unknown-dracut-option; echo $?
+ 0
+ '
+ local verbose=false
+ local debug=false
+ while true; do
+ case "$1" in
+ --stdlog)
+ shift
+ local level="$1"
+ shift
+ [[ "$level" -ge 4 ]] && debug=true
+ ;;
+ --verbose)
+ shift
+ verbose=true
+ ;;
+ '')
+ break
+ ;;
+ *)
+ shift
+ ;;
+ esac
+ local level
+ $verbose && level=info
+ $debug && level=debug
+ logging.set_level "$level"
+ logging.set_commands_level debug
+ done
+ $debug
+ return $?
+}
+_debug=0
+_parse_dracut_args ${dracut_args[*]} || _debug=$?
+# endregion
+clean() {
+ local __doc__='
+ Removes all compiled kernel specific files.
+ NOTE: This method is triggered manually and not supported by dracut itself.
+
+ Example:
+
+ `clean`
+ '
+ build_clean_xmount "$moddir/binaries/xmount/"
+ build_clean_qemu_xmount "$moddir/binaries/qemu-xmount/"
+ build_clean_dnbd3 "$moddir/binaries/dnbd3/"
+ build_clean_systemd_preserve_process_marker \
+ "$moddir/binaries/systemd-preserve-process-marker/"
+ return 0
+}
+# region dracut plugin api
+check() {
+ local __doc__='
+ Checks wether all template system assumptions are satisfied.
+
+ Example:
+
+ `check`
+ '
+ exceptions.activate
+ # NOTE: xmount must be compiled before qemu_xmount
+ local xmount_is_built=true
+ if [[ ! -f "$moddir/binaries/xmount/trunk/build/src/xmount" ]]; then
+ if ! build_compile_xmount "$moddir/binaries/xmount/"; then
+ xmount_is_built=false
+ fi
+ fi
+ if $xmount_is_built && [[ \
+ ! -f "$moddir/binaries/qemu-xmount/libxmount_input_qemu.so" \
+ ]]; then
+ build_compile_qemu_xmount "$moddir/binaries/qemu-xmount/" || \
+ xmount_is_built=false
+ fi
+ $xmount_is_built || logging.warn \
+ "Compiling \"xmount\" failed -> No support for container files (only raw images)."
+
+ if [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3.ko" ]] || \
+ [[ ! -f "$moddir/binaries/dnbd3/build/dnbd3-client" ]]
+ then
+ build_compile_dnbd3 "$moddir/binaries/dnbd3/"
+ [[ $? != 0 ]] && return 1
+ fi
+ if [[ ! -f "$moddir/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker" ]]; then
+ build_compile_systemd_preserve_process_marker \
+ "$moddir/binaries/systemd-preserve-process-marker/"
+ [[ $? != 0 ]] && return 1
+ fi
+ # NOTE: This are workarounds for:
+ # - distributions where "systemd-udevd" doesn't lives in "/usr/lib" but in
+ # "/lib".
+ local alternate_systemd_udevd_location='/lib/systemd/systemd-udevd'
+ if [[ ! -f "${systemdutildir}/systemd-udevd" ]] && \
+ [[ -f "$alternate_systemd_udevd_location" ]]; then
+ mkdir --parents "${initdir}${systemdutildir}"
+ ln --symbolic --force "$alternate_systemd_udevd_location" \
+ "${initdir}${systemdutildir}/systemd-udevd"
+ #cp "$alternate_systemd_udevd_location" \
+ # "${initdir}${systemdutildir}/systemd-udevd" 1>&2
+ fi
+ # - "/usr/bin/sh" isn't available but "/bin/sh".
+ if [[ ! -f /usr/bin/sh ]] && [[ -f /bin/sh ]]; then
+ ln --symbolic --force /bin/sh /usr/bin/sh
+ fi
+ exceptions.deactivate
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ local __doc__='
+ Outputs all dependent dracut modules to make this module work.
+
+ >>> depends
+ +doc_test_contains
+ base
+ '
+ echo base network bash kernel-modules shutdown
+}
+installkernel() {
+ local __doc__='
+ Copies all needed kernel modules into initramfs file needed work at
+ runtime.
+
+ Example:
+
+ `installkernel`
+ '
+ inst "$moddir/binaries/dnbd3/build/dnbd3.ko" \
+ /usr/lib/modules/current/extra/dnbd3.ko
+ instmods dm_snapshot btrfs crc32c
+}
+install() {
+ local __doc__='
+ Copies all needed files into the initramfs image and registers all needed
+ dracut hooks.
+
+ Example:
+
+ `install`
+ '
+ # 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
+ inst "$moddir/scripts/device-add-write-layer.sh" \
+ /usr/bin/device-add-write-layer
+ inst "$moddir/scripts/container-unpack-xmount.sh" \
+ /usr/bin/container-unpack-xmount
+ # xmount
+ local \
+ xmount_installation="$moddir/binaries/xmount/trunk/build/release_build"
+ inst "${xmount_installation}/usr/bin/xmount" /usr/bin/xmount
+ for file in ${xmount_installation}/usr/lib/xmount/*; do
+ inst "$file" /usr/lib/xmount/"$(basename "$file")"
+ done
+ inst "$moddir/binaries/qemu-xmount/libxmount_input_qemu.so" \
+ /usr/lib/xmount/libxmount_input_qemu.so
+ # endregion
+ # region hooks
+ inst_hook cmdline 00 "$moddir/hooks/enable-sysrq.sh"
+ # NOTE: Can be used to support old style ip append syntax and have an
+ # exclusive interface name.
+ inst_hook cmdline 10 \
+ "$moddir/hooks/prepare-kernel-command-line-parameter.sh"
+ inst_hook cmdline 90 "$moddir/hooks/set-dracut-environment-variables.sh"
+ inst_hook pre-udev 00 "$moddir/hooks/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/fetch-config.sh"
+ # make the final blockdevice for the root system (dnbd3 -> xmount ->
+ # device-mapper)
+ if dracut_module_included "systemd-initrd"; then
+ inst "$moddir/hooks/prepare-root-partition.sh" \
+ /usr/bin/dnbd3root
+ inst_simple "${moddir}/services/dnbd3root.service" \
+ "${systemdsystemunitdir}/dnbd3root.service"
+ mkdir --parents \
+ "${initdir}/${systemdsystemunitdir}/dracut-mount.service.requires"
+ ln_r "${systemdsystemunitdir}/dnbd3root.service" \
+ "${systemdsystemunitdir}/dracut-mount.service.requires/dnbd3root.service"
+ mkdir --parents \
+ "${initdir}/${systemdsystemunitdir}/initrd.target.requires"
+ ln_r "${systemdsystemunitdir}/dnbd3root.service" \
+ "${systemdsystemunitdir}/initrd.target.requires/dnbd3root.service"
+ # Copy systemd services to new root (so they don't get killed after
+ # switch_root)
+ inst_hook pre-pivot 00 \
+ "$moddir/hooks/copy-dnbd3-service-into-newroot.sh"
+ inst_hook pre-pivot 00 \
+ "$moddir/hooks/copy-dracut-systemd-files-into-newroot.sh"
+ inst_hook pre-shutdown 00 "$moddir/hooks/shutdown-umount.sh"
+ else
+ inst_hook pre-mount 10 "$moddir/hooks/prepare-root-partition.sh"
+ fi
+ inst_hook mount 10 "$moddir/hooks/mount-root-device.sh"
+ inst_hook pre-pivot 00 \
+ "$moddir/hooks/copy-openslx-configuration-into-newroot.sh"
+ # endregion
+ # region scripts
+ local file_path
+ for file_path in "$moddir/scripts/rebash/"*; do
+ inst "$file_path" "/usr/lib/rebash/$(basename "$file_path")"
+ done
+ inst "$moddir/scripts/tools.sh" "/usr/lib/openslx/tools.sh"
+ # endregion
+ # region configuration files
+ # Use terminal readline settings from the template system.
+ inst /etc/inputrc /etc/inputrc
+ # Set some aliases for the initramfs context.
+ if [[ "$_debug" == 0 ]]; then
+ inst "$moddir/configuration/bash" '/etc/bash.bashrc'
+ inst "$moddir/configuration/bash" '/etc/profile.d/aliases'
+ fi
+ # endregion
+ inst_multiple \
+ awk \
+ basename bash blockdev \
+ cat cut \
+ dd diff dirname dmsetup \
+ find fsck.ext4 \
+ grep \
+ insmod \
+ losetup lsblk \
+ mkfifo mkfs.ext4 mktemp mount mountpoint \
+ sed sleep sort \
+ tee touch tr \
+ wget
+}
+# endregion
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/build.sh b/builder/modules.d/dnbd3-rootfs/scripts/build.sh
new file mode 100644
index 00000000..47e5dcc7
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/scripts/build.sh
@@ -0,0 +1,126 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# shellcheck source=./rebash/core.sh
+source "$(dirname "${BASH_SOURCE[0]}")/rebash/core.sh"
+core.import logging
+
+build_compile_qemu_xmount() {
+ local __doc__='
+ Compiles qemu libxmount.
+ NOTE: expects xmount installation under
+ $1/../xmount/trunk/build/release_build/
+
+ Provides the following file:
+ "$1/libxmount_input_qemu.so"
+
+ Example:
+
+ `build_compile_qemu_xmount /qemu_source /xmount/installation`
+ '
+ pushd "$1"
+ local xmount_installation="../xmount/trunk/build/release_build/usr"
+ [ ! -z "$2" ] && xmount_installation="$2"
+ ./configure --enable-xmount-input --python="$(which python2)" \
+ --extra-cflags="-fPIC" \
+ --extra-cflags="-std=gnu99" \
+ --extra-cflags="-I${xmount_installation}/include" \
+ --extra-cflags="-I${xmount_installation}/include/xmount" \
+ --disable-fdt --target-list=""
+ make -j4 libxmount_input_qemu.so
+ local ret=$?
+ popd
+ return $ret
+}
+build_clean_qemu_xmount() {
+ local __doc__='Clean the build of `build_compile_qemu_xmount`.'
+ pushd "$1"
+ make clean
+ popd
+ return $?
+}
+build_compile_xmount() {
+ local __doc__='
+ Compiles xmount.
+
+ Provides the xmount installation under:
+ "$1/trunk/build/release_build/"
+
+ Example:
+
+ `build_compile_xmount /xmount_source /xmount_source/build /usr`
+ '
+ pushd "$1"
+
+ local destination_directory="./release_build"
+ [ ! -z "$2" ] && destination_directory="$2"
+ local install_prefix="/usr"
+ [ ! -z "$3" ] && install_prefix="$3"
+
+ mkdir --parents trunk/build
+ cd trunk/build || return 1
+ cmake -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="$install_prefix" ..
+ make -j4
+ make install DESTDIR="$destination_directory"
+ local ret=$?
+ popd
+ return $ret
+}
+build_clean_xmount() {
+ local __doc__='Clean the build of `build_compile_xmount`.'
+ rm --recursive --force "$1/trunk/build"
+}
+build_compile_dnbd3() {
+ local __doc__='
+ Compiles dnbd3 kernel module and client.
+
+ Provides the following file:
+ "$1/build/dnbd3.ko"
+ "$1/build/dnbd3-client"
+
+ Examples:
+
+ `build_compile_dnbd3 path/to/dnbd3/source/`
+ '
+ pushd "$1"
+ # NOTE: The generic way would be: "./build.sh" but this tries to build
+ # more than we really need and takes more time.
+ mkdir --parents build
+ pushd build
+ cmake ../
+ make -j4 dnbd3 dnbd3-client
+ popd
+ return $?
+}
+build_clean_dnbd3() {
+ local __doc__='Clean the build of `build_compile_dnbd3`.'
+ rm --recursive --force "$1/build"
+ return $?
+}
+build_compile_systemd_preserve_process_marker() {
+ local __doc__='
+ Compiles simple c program.
+
+ Examples:
+
+ `build_compile_systemd_preserve_process_marker path/to/program/folder`
+ '
+ pushd "$1"
+ make
+ popd
+ return $?
+}
+build_clean_systemd_preserve_process_marker() {
+ local __doc__='
+ Clean the build of
+ `build_compile_systemd_preserve_process_marker`.
+ '
+ pushd "$1"
+ make clean
+ popd
+ return $?
+}
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh
new file mode 100755
index 00000000..53fd73dc
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-qemu.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source "/usr/lib/rebash/core.sh"
+core.import exceptions
+exceptions.activate
+# endregion
+
+in_device="$1"
+nbd_device="$2" # TODO detect first free nbd device
+
+systemd-preserve-process-marker qemu-nbd --connect="$nbd_device" \
+ "$in_device" --read-only --persistent --nocache
+
+# TODO better way to wait for the device to be made?
+i=0
+while [ ! -b "$nbd_device" ]; do
+ [ $i -ge 20 ] && exit 1
+ if [ $UDEVVERSION -ge 143 ]; then
+ udevadm settle --exit-if-exists="$nbd_device"
+ else
+ sleep 0.1
+ fi
+ i=$(($i + 1))
+done
+
+# NBD doesn't emit uevents when it gets connected, so kick it
+# TODO get path from $nbd_device
+echo change > /sys/block/nbd0/uevent
+udevadm settle
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh
new file mode 100755
index 00000000..c7e1b45c
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/scripts/container-unpack-xmount.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+source '/usr/lib/rebash/core.sh'
+core.import logging
+core.import utils
+core.import exceptions
+exceptions.activate
+# endregion
+logging.set_level info
+logging.set_commands_level info
+
+# NOTE: All output has to be forwarded to standard error because determined
+# device should be printed on standard output.
+in_device="$1"
+mkdir --parents /mnt/xmount
+loop_device="$(losetup --find)"
+if ! utils.dependency_check xmount; then
+ logging.warn "\"xmount\" not found, assuming raw image." 1>&2
+elif systemd-preserve-process-marker xmount --in qemu "$in_device" --out raw \
+ /mnt/xmount &>/dev/null
+then
+ in_device="/mnt/xmount/*.dd"
+else
+ logging.warn "\"xmount\" call failed, assuming raw image." 1>&2
+fi
+losetup "$loop_device" $in_device --partscan
+udevadm settle
+echo "$loop_device"
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/device-add-write-layer.sh b/builder/modules.d/dnbd3-rootfs/scripts/device-add-write-layer.sh
new file mode 100755
index 00000000..2e4116a7
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/scripts/device-add-write-layer.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+# shellcheck source=./rebash/core.sh
+source "/usr/lib/rebash/core.sh"
+core.import exceptions
+exceptions.activate
+# endregion
+
+combined_device_name="$1"
+read_only_device="$2"
+writable_device="$3"
+persistent="$4" # P or N
+chunksize='1'
+
+partition_size="$(blockdev --getsz "$read_only_device")"
+writable_partition_name='root'
+modprobe dm_snapshot
+dmsetup create "$combined_device_name" --noudevsync --table \
+ "0 $partition_size snapshot $read_only_device $writable_device $persistent $chunksize"
+dmsetup mknodes --noudevsync "$combined_device_name"
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/rebash b/builder/modules.d/dnbd3-rootfs/scripts/rebash
new file mode 160000
+Subproject 6ca5b39c862aed6a13146f4121fb51f784b1eb4
diff --git a/builder/modules.d/dnbd3-rootfs/scripts/tools.sh b/builder/modules.d/dnbd3-rootfs/scripts/tools.sh
new file mode 100644
index 00000000..bace775e
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/scripts/tools.sh
@@ -0,0 +1,105 @@
+#!/usr/bin/env bash
+# -*- coding: utf-8 -*-
+# region imports
+# shellcheck source=./rebash/core.sh
+source "/usr/lib/rebash/core.sh"
+core.import logging
+# endregion
+tools__doc_test_setup__='
+lsblk() {
+ if [[ "${@: -1}" == "" ]];then
+ echo "lsblk: : not a block device"
+ return 1
+ fi
+ if [[ "${@: -1}" != "/dev/sdb" ]];then
+ echo "/dev/sda disk"
+ echo "/dev/sda1 part SYSTEM_LABEL 0x7"
+ echo "/dev/sda2 part"
+ fi
+ if [[ "${@: -1}" != "/dev/sda" ]];then
+ echo "/dev/sdb disk"
+ echo "/dev/sdb1 part boot_partition "
+ echo "/dev/sdb2 part system_partition"
+ fi
+}
+blkid() {
+ [[ "${@: -1}" != "/dev/sda2" ]] && return 0
+ echo "gpt"
+ echo "only discoverable by blkid"
+ echo "boot_partition"
+ echo "192d8b9e"
+}
+sleep() {
+ ((_test_sleep_time++))
+}
+'
+
+tools_find_block_device() {
+ # shellcheck disable=SC2034,SC2016
+ local __doc__='
+ >>> tools.find_block_device "boot_partition"
+ /dev/sdb1
+ >>> tools.find_block_device "boot_partition" /dev/sda
+ /dev/sda2
+ >>> tools.find_block_device "discoverable by blkid"
+ /dev/sda2
+ >>> tools.find_block_device "_partition"
+ /dev/sdb1 /dev/sdb2
+ >>> tools.find_block_device "not matching anything"; echo $?
+ 1
+ >>> tools.find_block_device ""; echo $?
+ 1
+
+ >>> local _test_sleep_time=0
+ >>> tools.find_block_device "not matching anything" /dev/sda 10; echo $?
+ >>> echo $_test_sleep_time
+ 1
+ 10
+ '
+ local partition_pattern="$1"
+ [ "$partition_pattern" = '' ] && return 1
+ local device="$2"
+ local timeout=0
+ [ ! -z "$3" ] && timeout="$3"
+ tools_find_block_device_simple() {
+ local device_info
+ lsblk --noheadings --list --paths --output \
+ NAME,TYPE,LABEL,PARTLABEL,UUID,PARTUUID ${device:+"$device"} \
+ | sort --unique | while read -r device_info; do
+ local current_device
+ current_device=$(echo "$device_info" | cut -d' ' -f1)
+ if [[ "$device_info" = *"${partition_pattern}"* ]]; then
+ echo "$current_device"
+ fi
+ done
+ }
+ tools_find_block_device_deep() {
+ local device_info
+ lsblk --noheadings --list --paths --output NAME ${device:+"$device"} \
+ | sort --unique | cut -d' ' -f1 | while read -r current_device; do
+ blkid -p -o value "$current_device" \
+ | while read -r device_info; do
+ if [[ "$device_info" = *"${partition_pattern}"* ]]; then
+ echo "$current_device"
+ fi
+ done
+ done
+ }
+ while ((timeout >= 0)); do
+ local candidates
+ candidates=($(tools_find_block_device_simple))
+ (( ${#candidates[@]} == 0 )) && candidates=($(tools_find_block_device_deep))
+ (( ${#candidates[@]} > 1 )) && echo "${candidates[@]}" && return 1
+ (( ${#candidates[@]} == 1 )) && echo "${candidates[0]}" && return 0
+ ((timeout == 0)) || sleep 1
+ ((timeout--))
+ done
+ # no candidates
+ return 1
+}
+alias tools.find_block_device="tools_find_block_device"
+
+# region vim modline
+# vim: set tabstop=4 shiftwidth=4 expandtab:
+# vim: foldmethod=marker foldmarker=region,endregion:
+# endregion
diff --git a/builder/modules.d/dnbd3-rootfs/services/dnbd3root.service b/builder/modules.d/dnbd3-rootfs/services/dnbd3root.service
new file mode 100644
index 00000000..592b049d
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/services/dnbd3root.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=root fs on dnbd3 (distributed network block device)
+After=dracut-pre-mount.service network.target
+Before=dracut-mount.service
+DefaultDependencies=no
+IgnoreOnIsolate=true
+#OnFailure=emergency.target
+#Conflicts=shutdown.target
+#ConditionKernelCommandLine=!
+#ConditionPathExists=/etc/multipath.conf
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+KillMode=none
+ExecStart=/usr/bin/dnbd3root
+#ExecStop=echo 'stopping dnbd3'
diff --git a/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules b/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules
new file mode 100644
index 00000000..9aad9a41
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/udev/70-openslx-disk.rules
@@ -0,0 +1,7 @@
+# GPT rules
+KERNEL=="sd?[0-9]" SUBSYSTEM=="block" ENV{ID_PART_TABLE_TYPE}=="gpt" ENV{ID_PART_ENTRY_NAME}=="OPENSLX_TMP" RUN+="/sbin/prepare-persistent-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-persistent-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-persistent-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-persistent-disks OPENSLX_SYS %k"
diff --git a/builder/modules.d/dns/module-setup.sh b/builder/modules.d/dns/module-setup.sh
new file mode 100755
index 00000000..3bad6548
--- /dev/null
+++ b/builder/modules.d/dns/module-setup.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+check() {
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ echo base
+}
+install() {
+ inst_hook pre-mount 50 "$moddir/scripts/gen-resolv-conf.sh"
+}
diff --git a/builder/modules.d/dns/scripts/gen-resolv-conf.sh b/builder/modules.d/dns/scripts/gen-resolv-conf.sh
new file mode 100755
index 00000000..1601bb12
--- /dev/null
+++ b/builder/modules.d/dns/scripts/gen-resolv-conf.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+CONFFILE="/etc/resolv.conf"
+
+DNS=$(getargs dns=)
+HOSTNAME=$(getargs hostname=)
+
+[ -n "$DNS" ] && echo "nameserver $DNS" >> "$CONFFILE"
+[ -n "$HOSTNAME" ] && echo "$HOSTNAME" >> /etc/hostname
diff --git a/builder/modules.d/ib-conf/module-setup.sh b/builder/modules.d/ib-conf/module-setup.sh
new file mode 100755
index 00000000..0a80d89e
--- /dev/null
+++ b/builder/modules.d/ib-conf/module-setup.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+check() {
+ # Tell dracut that this module should only be included if it is required
+ # explicitly.
+ return 255
+}
+depends() {
+ echo dnbd3-rootfs
+}
+install() {
+ inst_hook pre-pivot 50 "$moddir/scripts/gen-ib-conf.sh"
+}
diff --git a/builder/modules.d/ib-conf/scripts/gen-ib-conf.sh b/builder/modules.d/ib-conf/scripts/gen-ib-conf.sh
new file mode 100755
index 00000000..2d4b7a27
--- /dev/null
+++ b/builder/modules.d/ib-conf/scripts/gen-ib-conf.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh
+
+IPSUFFIX=$(
+ ip -4 -o addr show dev bootnet | \
+ awk '{split($4,a,"/");split(a[1],b,".");print b[3]"."b[4]}'
+)
+
+cat << EOF >> "${NEWROOT}/etc/sysconfig/network-scripts/ifcfg-ib0"
+DEVICE=ib0
+NAME=ib0
+TYPE=Infiniband
+BOOTPROTO=static
+IPADDR=10.12.${IPSUFFIX}
+BROADCAST=10.12.255.255
+NETWORK=10.12.0.0
+NETMASK=255.255.0.0
+ONBOOT=yes
+NM_CONTROLLED=yes
+CONNECTED_MODE=yes
+MTU=65520
+EOF
+
diff --git a/builder/modules.d/wlan-boot/README b/builder/modules.d/wlan-boot/README
new file mode 100644
index 00000000..71bc5ff5
--- /dev/null
+++ b/builder/modules.d/wlan-boot/README
@@ -0,0 +1,152 @@
+############################################
+### README DRACUT MODUL FOR WLAN SUPPORT ###
+############################################
+
+SHORT LIST OF FILES
+=============
+
+/hooks
+/hooks/parse-wlan-kernel-command-line-parameter.sh
+/hooks/start_wlan.sh
+/hooks/prepare-newroot.sh
+/services
+/services/dhcp.service
+/services/wpa_supplicant.service
+/udev
+/udev/80-net-wlan.rules
+/binaries
+/binaries/systemd-preserve-process-marker
+/binaries/dhcpcd
+/scripts
+/scripts/dhcpcd-hooks
+/scripts/dhcpcd-hooks/20-resolv.conf
+/scripts/dhcpcd-hooks/10-wpa_supplicant
+/scripts/dhcpcd-run-hooks
+/certs
+/certs/Deutsche_Telekom_Root_CA_2.pem
+/debug
+/debug/services
+/debug/services/debug-shell.service
+/debug/binaries
+/debug/binaries/busybox.tar
+/debug/hooks
+/debug/hooks/install_busybox.sh
+/debug/scripts
+/debug/scripts/restart_wpa.sh
+/module-setup.sh
+/chroot
+
+
+WIFI DRIVER AND CHIP
+====================
+
+this module was built with the iwlwifi Linux kernel driver and tested with Intel Corporation Centrino Wireless-N 100
+
+
+BUILDING THE INITRAMFS
+======================
+
+./build-initramfs.sh -s -d -p initramfs-wlan - --add "wlan crypt"
+
+
+KERNEL COMMAND LINE EXAMPLE FOR EDUROAM
+=======================================
+
+../vmlinuz-centos-old slxsrv=132.230.8.90 slxbase=slx/cos7/ rd.shell rd.break=switch-root ssid=eduroam user=testoslx@hs-offenburg.de pw=password123
+
+
+SEQUENCE
+========
+
+ ----------------------- cmdline
+ / |
+ / |
+ parse the command line |
+ v
+ ----------------------- udev
+ / |
+ / |
+ set the interface name |
+ v
+ pre-mount ------------------------
+ | \
+ | \
+ | ------- start wlan -------
+ v / \
+ ---------------------- pre-pivot / \
+ / set link up start dhcpcd.service ------
+ / \
+ prepare newroot \
+ start wpa_supplicant.service
+
+
+
+
+HOOKS
+=====
+
+cmdline
+-------
+
+/hooks/parse-wlan-kernel-command-line-parameter.sh
+search the command line for 'ssid=' and 'pw=' and generates the wpa_supplicant configuration file /etc/wpa_supplicant.conf If you connect to eduroam you also need 'user='. It is important for dhcpcd that the config file includes the path to the ctrl_interface.
+
+
+pre-mount
+---------
+
+/hooks/start_wlan.sh
+this script sets up the wlan interface and starts the dhcp.service. The dhcp.service runs the dhcp client dhcpcd which starts the wpa_supplicant.service if no wpa_supplicant already running. The script is waiting until its possible to ping the slxsrv from the command line.
+
+
+pre-pivot
+---------
+
+/hooks/prepare-newroot.sh
+copy files to the new system and disable NetworkManager
+
+
+
+SERVICES
+========
+
+/services/dhcp.service
+this service manages the dhcp client dhcpcd. It will be invoked by the start_wlan.sh script while pre-mount.
+
+/services/wpa_supplicant.service
+this service manages the wpa_supplicant. It will be invoked by dhcpcd.
+
+
+DHCP
+====
+
+dhcpcd
+------
+
+the dhcp client we use is dhcpcd. dhcpcd runs /libexec/dhcpcd-run-hooks if an event occurs like no carrier is available. We want to use this hook event to restart wpa_supplicant every time we lost the connection. But in fact it doesnt work after the switch root, cause of any reason dhcpcd doesnt run the script.
+
+
+dhcpcd-run-hooks
+----------------
+
+dhcpcd-run-hooks is used by dhcpcd to run any system and user defined hook scripts. It executes all scripts in /libexec/dhcpcd-hooks/.
+
+
+/debug/scripts/restart_wpa.sh
+-----------------------------
+
+this script restarts the wpa_supplicant
+
+DEBUG
+=====
+
+rescue shell
+------------
+
+after the new system booted you have a busybox available on tty9. You can use this if you lost the connection after the switch root.
+
+
+CHROOT
+======
+
+here you find an environment which provides dhcpcd and wpa_supplicant. It isnt included automaticly, because its not really tested. For more Information you find some manual steps at chroot/README.
diff --git a/builder/modules.d/wlan-boot/binaries/dhcpcd b/builder/modules.d/wlan-boot/binaries/dhcpcd
new file mode 100755
index 00000000..933e4cc7
--- /dev/null
+++ b/builder/modules.d/wlan-boot/binaries/dhcpcd
Binary files differ
diff --git a/builder/modules.d/wlan-boot/binaries/systemd-preserve-process-marker b/builder/modules.d/wlan-boot/binaries/systemd-preserve-process-marker
new file mode 100755
index 00000000..99d1e0c4
--- /dev/null
+++ b/builder/modules.d/wlan-boot/binaries/systemd-preserve-process-marker
Binary files differ
diff --git a/builder/modules.d/wlan-boot/certs/Deutsche_Telekom_Root_CA_2.pem b/builder/modules.d/wlan-boot/certs/Deutsche_Telekom_Root_CA_2.pem
new file mode 100644
index 00000000..05879ff3
--- /dev/null
+++ b/builder/modules.d/wlan-boot/certs/Deutsche_Telekom_Root_CA_2.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc
+MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj
+IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB
+IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE
+RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl
+U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290
+IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU
+ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC
+QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr
+rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S
+NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc
+QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH
+txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP
+BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC
+AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp
+tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa
+IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl
+6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+
+xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU
+Cm26OWMohpLzGITY+9HPBVZkVw==
+-----END CERTIFICATE-----
diff --git a/builder/modules.d/wlan-boot/chroot/README b/builder/modules.d/wlan-boot/chroot/README
new file mode 100644
index 00000000..8d6a5e50
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/README
@@ -0,0 +1,44 @@
+rd.break=pre-mount:
+===================
+
+rm /lib/dracut/hooks/pre-mount/00-start-wlan.sh
+
+MOUNT
+=====
+
+mkdir /chroot
+mount -t tmpfs tmpfs /chroot/
+cd /chroot/
+tar xzf /root/environment.tar
+
+cd environment
+
+mount -t proc proc proc/
+mount -o bind /sys sys/
+mount -o bind /dev dev/
+
+CONFIG
+======
+
+
+cp /etc/wpa_supplicant.conf etc/
+
+cd ..
+
+chroot environment /usr/bin/systemd-preserver-process-marker wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
+chroot environment /usr/bin/systemd-preserver-process-marker dhcpcd wlan0
+
+
+rd.break=switch-root
+====================
+
+rm /sysroot/etc/systemd/system/sysinit.target.wants/dhcp.service
+rm /sysroot/etc/systemd/system/sysinit.target.wants/wpa_supplicant.service
+
+
+mkdir /sysroot/chroot
+mount -o bind /chroot /sysroot/chroot/
+
+mount -t proc proc /sysroot/chroot/environment/proc/
+mount -o bind /sys /sysroot/chroot/environment/sys/
+mount -o bind /dev /sysroot/chroot/environment/dev/
diff --git a/builder/modules.d/wlan-boot/chroot/environment.tar b/builder/modules.d/wlan-boot/chroot/environment.tar
new file mode 100644
index 00000000..2838ecea
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment.tar
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/bin/sh b/builder/modules.d/wlan-boot/chroot/environment/bin/sh
new file mode 100755
index 00000000..5672e081
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/bin/sh
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem b/builder/modules.d/wlan-boot/chroot/environment/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem
new file mode 100644
index 00000000..05879ff3
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem
@@ -0,0 +1,22 @@
+-----BEGIN CERTIFICATE-----
+MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEc
+MBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2Vj
+IFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENB
+IDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5MjM1OTAwWjBxMQswCQYDVQQGEwJE
+RTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxl
+U2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290
+IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEU
+ha88EOQ5bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhC
+QN/Po7qCWWqSG6wcmtoIKyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1Mjwr
+rFDa1sPeg5TKqAyZMg4ISFZbavva4VhYAUlfckE8FQYBjl2tqriTtM2e66foai1S
+NNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aKSe5TBY8ZTNXeWHmb0moc
+QqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTVjlsB9WoH
+txa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAP
+BgNVHRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOC
+AQEAlGRZrTlk5ynrE/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756Abrsp
+tJh6sTtU6zkXR34ajgv8HzFZMQSyzhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpa
+IzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8rZ7/gFnkm0W09juwzTkZmDLl
+6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4Gdyd1Lx+4ivn+
+xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU
+Cm26OWMohpLzGITY+9HPBVZkVw==
+-----END CERTIFICATE-----
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/ld-linux-x86-64.so.2 b/builder/modules.d/wlan-boot/chroot/environment/lib64/ld-linux-x86-64.so.2
new file mode 100755
index 00000000..b39bc468
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/ld-linux-x86-64.so.2
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libc.so.6 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libc.so.6
new file mode 100755
index 00000000..58b51aa6
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libc.so.6
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libcom_err.so.2 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libcom_err.so.2
new file mode 100755
index 00000000..5617634d
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libcom_err.so.2
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libcrypto.so.10 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libcrypto.so.10
new file mode 100755
index 00000000..fcb9e36a
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libcrypto.so.10
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libdbus-1.so.3 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libdbus-1.so.3
new file mode 100755
index 00000000..b024940b
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libdbus-1.so.3
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libdl.so.2 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libdl.so.2
new file mode 100755
index 00000000..3d6cddcb
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libdl.so.2
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libgssapi_krb5.so.2 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libgssapi_krb5.so.2
new file mode 100755
index 00000000..3f5c6a07
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libgssapi_krb5.so.2
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libk5crypto.so.3 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libk5crypto.so.3
new file mode 100755
index 00000000..18d24b6d
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libk5crypto.so.3
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libkeyutils.so.1 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkeyutils.so.1
new file mode 100755
index 00000000..c9fdf185
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkeyutils.so.1
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5.so.3 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5.so.3
new file mode 100755
index 00000000..20c40016
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5.so.3
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5support.so.0 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5support.so.0
new file mode 100755
index 00000000..08d42cd7
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libkrb5support.so.0
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/liblzma.so.5 b/builder/modules.d/wlan-boot/chroot/environment/lib64/liblzma.so.5
new file mode 100755
index 00000000..3e2841a6
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/liblzma.so.5
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libm.so.6 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libm.so.6
new file mode 100755
index 00000000..9e471ce5
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libm.so.6
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-3.so.200 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-3.so.200
new file mode 100755
index 00000000..03733566
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-3.so.200
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-genl-3.so.200 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-genl-3.so.200
new file mode 100755
index 00000000..2fbb7caa
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libnl-genl-3.so.200
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libpcre.so.1 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libpcre.so.1
new file mode 100755
index 00000000..4e100f6b
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libpcre.so.1
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libpthread.so.0 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libpthread.so.0
new file mode 100755
index 00000000..f3b670d7
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libpthread.so.0
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libresolv.so.2 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libresolv.so.2
new file mode 100755
index 00000000..08ea9aed
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libresolv.so.2
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/librt.so.1 b/builder/modules.d/wlan-boot/chroot/environment/lib64/librt.so.1
new file mode 100755
index 00000000..d19805a0
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/librt.so.1
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libselinux.so.1 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libselinux.so.1
new file mode 100755
index 00000000..22335824
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libselinux.so.1
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libssl.so.10 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libssl.so.10
new file mode 100755
index 00000000..163d81b3
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libssl.so.10
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libtinfo.so.5 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libtinfo.so.5
new file mode 100755
index 00000000..74001427
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libtinfo.so.5
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/lib64/libz.so.1 b/builder/modules.d/wlan-boot/chroot/environment/lib64/libz.so.1
new file mode 100755
index 00000000..257c46b1
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/lib64/libz.so.1
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-hooks/10-wpa_supplicant b/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-hooks/10-wpa_supplicant
new file mode 100755
index 00000000..adea9957
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-hooks/10-wpa_supplicant
@@ -0,0 +1,118 @@
+# Start, reconfigure and stop wpa_supplicant per wireless interface.
+# This is needed because wpa_supplicant lacks hotplugging of any kind
+# and the user should not be expected to have to wire it into their system
+# if the base system doesn't do this itself.
+
+if [ -z "$wpa_supplicant_conf" ]; then
+ for x in \
+ /etc/wpa_supplicant/wpa_supplicant-"$interface".conf \
+ /etc/wpa_supplicant/wpa_supplicant.conf \
+ /etc/wpa_supplicant-"$interface".conf \
+ /etc/wpa_supplicant.conf \
+ ; do
+ if [ -s "$x" ]; then
+ wpa_supplicant_conf="$x"
+ break
+ fi
+ done
+fi
+: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}
+
+wpa_supplicant_ctrldir()
+{
+ local dir
+
+ dir=$(key_get_value "[[:space:]]*ctrl_interface=" \
+ "$wpa_supplicant_conf")
+ dir=$(trim "$dir")
+ case "$dir" in
+ DIR=*)
+ dir=${dir##DIR=}
+ dir=${dir%%[[:space:]]GROUP=*}
+ dir=$(trim "$dir")
+ ;;
+ esac
+ printf %s "$dir"
+}
+
+wpa_supplicant_start()
+{
+ local dir err errn
+
+ # If the carrier is up, don't bother checking anything
+ [ "$ifcarrier" = "up" ] && return 0
+
+ # Pre flight checks
+ if [ ! -s "$wpa_supplicant_conf" ]; then
+ syslog warn \
+ "$wpa_supplicant_conf does not exist"
+ syslog warn "not interacting with wpa_supplicant(8)"
+ return 1
+ fi
+ dir=$(wpa_supplicant_ctrldir)
+ if [ -z "$dir" ]; then
+ syslog warn \
+ "ctrl_interface not defined in $wpa_supplicant_conf"
+ syslog warn "not interacting with wpa_supplicant(8)"
+ return 1
+ fi
+
+ wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 && return 0
+ syslog info "starting wpa_supplicant"
+ driver=${wpa_supplicant_driver:+-D}$wpa_supplicant_driver
+ err=$(systemctl start wpa_supplicant 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to start wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+wpa_supplicant_reconfigure()
+{
+ local dir err errn
+
+ dir=$(wpa_supplicant_ctrldir)
+ [ -z "$dir" ] && return 1
+ if ! wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1; then
+ wpa_supplicant_start
+ return $?
+ fi
+ syslog info "reconfiguring wpa_supplicant"
+ err=$(wpa_cli -p "$dir" -i "$interface" reconfigure 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to reconfigure wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+wpa_supplicant_stop()
+{
+ local dir err errn
+
+ dir=$(wpa_supplicant_ctrldir)
+ [ -z "$dir" ] && return 1
+ wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 || return 0
+ syslog info "stopping wpa_supplicant"
+ err=$(wpa_cli -i"$interface" terminate 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to start wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+if [ "$ifwireless" = "1" ] && \
+ type wpa_supplicant >/dev/null 2>&1 && \
+ type wpa_cli >/dev/null 2>&1
+then
+ case "$reason" in
+ PREINIT|NOCARRIER) wpa_supplicant_start;;
+ RECONFIGURE) wpa_supplicant_reconfigure;;
+ DEPARTED) wpa_supplicant_stop;;
+ esac
+fi
diff --git a/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-run-hooks b/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-run-hooks
new file mode 100755
index 00000000..8caf0dc9
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/libexec/dhcpcd-run-hooks
@@ -0,0 +1,387 @@
+#!/bin/sh
+# dhcpcd client configuration script
+
+# Handy variables and functions for our hooks to use
+case "$reason" in
+ ROUTERADVERT)
+ ifsuffix=".ra";;
+ INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
+ ifsuffix=".dhcp6";;
+ IPV4LL)
+ ifsuffix=".ipv4ll";;
+ *)
+ ifsuffix=".dhcp";;
+esac
+ifname="$interface$ifsuffix"
+
+from=from
+signature_base="# Generated by dhcpcd"
+signature="$signature_base $from $ifname"
+signature_base_end="# End of dhcpcd"
+signature_end="$signature_base_end $from $ifname"
+state_dir=/var/run/dhcpcd
+_detected_init=false
+
+: ${if_up:=false}
+: ${if_down:=false}
+: ${syslog_debug:=false}
+
+# Ensure that all arguments are unique
+uniqify()
+{
+ local result= i=
+ for i do
+ case " $result " in
+ *" $i "*);;
+ *) result="$result $i";;
+ esac
+ done
+ echo "${result# *}"
+}
+
+# List interface config files in a directory.
+# If dhcpcd is running as a single instance then it will have a list of
+# interfaces in the preferred order.
+# Otherwise we just use what we have.
+list_interfaces()
+{
+ local i= x= ifaces=
+ for i in $interface_order; do
+ for x in "$1"/$i.*; do
+ [ -f "$x" ] && ifaces="$ifaces${ifaces:+ }${x##*/}"
+ done
+ done
+ for x in "$1"/*; do
+ [ -f "$x" ] && ifaces="$ifaces${ifaces:+ }${x##*/}"
+ done
+ uniqify $ifaces
+}
+
+# Trim function
+trim()
+{
+ local var="$*"
+
+ var=${var#"${var%%[![:space:]]*}"}
+ var=${var%"${var##*[![:space:]]}"}
+ if [ -z "$var" ]; then
+ # So it seems our shell doesn't support wctype(3) patterns
+ # Fall back to sed
+ var=$(echo "$*" | sed -e 's/^[[:space:]]*//;s/[[:space:]]*$//')
+ fi
+ printf %s "$var"
+}
+
+# We normally use sed to extract values using a key from a list of files
+# but sed may not always be available at the time.
+key_get_value()
+{
+ local key="$1" value= x= line=
+
+ shift
+ if type sed >/dev/null 2>&1; then
+ sed -n "s/^$key//p" $@
+ else
+ for x do
+ while read line; do
+ case "$line" in
+ "$key"*) echo "${line##$key}";;
+ esac
+ done < "$x"
+ done
+ fi
+}
+
+# We normally use sed to remove markers from a configuration file
+# but sed may not always be available at the time.
+remove_markers()
+{
+ local m1="$1" m2="$2" x= line= in_marker=0
+
+ shift; shift
+ if type sed >/dev/null 2>&1; then
+ sed "/^$m1/,/^$m2/d" $@
+ else
+ for x do
+ while read line; do
+ case "$line" in
+ "$m1"*) in_marker=1;;
+ "$m2"*) in_marker=0;;
+ *) [ $in_marker = 0 ] && echo "$line";;
+ esac
+ done < "$x"
+ done
+ fi
+}
+
+# Compare two files.
+comp_file()
+{
+
+ [ -e "$1" -a -e "$2" ] || return 1
+
+ if type cmp >/dev/null 2>&1; then
+ cmp -s "$1" "$2"
+ elif type diff >/dev/null 2>&1; then
+ diff -q "$1" "$2" >/dev/null
+ else
+ # Hopefully we're only working on small text files ...
+ [ "$(cat "$1")" = "$(cat "$2")" ]
+ fi
+}
+
+# Compare two files.
+# If different, replace first with second otherwise remove second.
+change_file()
+{
+
+ if [ -e "$1" ]; then
+ if comp_file "$1" "$2"; then
+ rm -f "$2"
+ return 1
+ fi
+ fi
+ cat "$2" > "$1"
+ rm -f "$2"
+ return 0
+}
+
+# Compare two files.
+# If different, copy or link depending on target type
+copy_file()
+{
+
+ if [ -h "$2" ]; then
+ [ "$(readlink "$2")" = "$1" ] && return 1
+ ln -sf "$1" "$2"
+ else
+ comp_file "$1" "$2" && return 1
+ cat "$1" >"$2"
+ fi
+}
+
+# Save a config file
+save_conf()
+{
+
+ if [ -f "$1" ]; then
+ rm -f "$1-pre.$interface"
+ cat "$1" > "$1-pre.$interface"
+ fi
+}
+
+# Restore a config file
+restore_conf()
+{
+
+ [ -f "$1-pre.$interface" ] || return 1
+ cat "$1-pre.$interface" > "$1"
+ rm -f "$1-pre.$interface"
+}
+
+# Write a syslog entry
+syslog()
+{
+ local lvl="$1"
+
+ if [ "$lvl" = debug ]; then
+ ${syslog_debug} || return 0
+ fi
+ [ -n "$lvl" ] && shift
+ [ -n "$*" ] || return 0
+ case "$lvl" in
+ err|error) echo "$interface: $*" >&2;;
+ *) echo "$interface: $*";;
+ esac
+ if type logger >/dev/null 2>&1; then
+ logger -i -p daemon."$lvl" -t dhcpcd-run-hooks "$interface: $*"
+ fi
+}
+
+# Check for a valid domain name as per RFC1123 with the exception of
+# allowing - and _ as they seem to be widely used.
+valid_domainname()
+{
+ local name="$1" label
+
+ [ -z "$name" -o ${#name} -gt 255 ] && return 1
+
+ while [ -n "$name" ]; do
+ label="${name%%.*}"
+ [ -z "$label" -o ${#label} -gt 63 ] && return 1
+ case "$label" in
+ -*|_*|*-|*_) return 1;;
+ # some sh require - as the first or last character in the class
+ # when matching it
+ *[![:alnum:]_-]*) return 1;;
+ esac
+ [ "$name" = "${name#*.}" ] && break
+ name="${name#*.}"
+ done
+ return 0
+}
+
+valid_domainname_list()
+{
+ local name
+
+ for name do
+ valid_domainname "$name" || return $?
+ done
+ return 0
+}
+
+# Check for a valid path
+valid_path()
+{
+
+ case "$@" in
+ *[![:alnum:]#%+-_:\.,@~\\/\[\]=\ ]*) return 1;;
+ esac
+ return 0
+}
+
+# With the advent of alternative init systems, it's possible to have
+# more than one installed. So we need to try and guess what one we're
+# using unless overriden by configure.
+detect_init()
+{
+ _service_exists=""
+ _service_cmd=""
+ _service_status=""
+
+ [ -n "$_service_cmd" ] && return 0
+
+ if ${_detected_init}; then
+ [ -n "$_service_cmd" ]
+ return $?
+ fi
+
+ # Detect the running init system.
+ # As systemd and OpenRC can be installed on top of legacy init
+ # systems we try to detect them first.
+ local status=""
+ : ${status:=status}
+ if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
+ _service_exists="/bin/systemctl --quiet is-enabled \$1.service"
+ _service_status="/bin/systemctl --quiet is-active \$1.service"
+ _service_cmd="/bin/systemctl \$2 \$1.service"
+ elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then
+ _service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
+ _service_status="/usr/bin/systemctl --quiet is-active \$1.service"
+ _service_cmd="/usr/bin/systemctl \$2 \$1.service"
+ elif [ -x /sbin/rc-service -a \
+ -s /libexec/rc/init.d/softlevel -o -s /run/openrc/softlevel ]
+ then
+ _service_exists="/sbin/rc-service -e \$1"
+ _service_cmd="/sbin/rc-service \$1 -- -D \$2"
+ elif [ -x /usr/sbin/invoke-rc.d ]; then
+ _service_exists="/usr/sbin/invoke-rc.d --query --quiet \$1 start >/dev/null 2>&1 || [ \$? = 104 ]"
+ _service_cmd="/usr/sbin/invoke-rc.d \$1 \$2"
+ elif [ -x /sbin/service ]; then
+ _service_exists="/sbin/service \$1 >/dev/null 2>&1"
+ _service_cmd="/sbin/service \$1 \$2"
+ elif [ -x /usr/sbin/service ]; then
+ _service_exists="/usr/sbin/service \$1 $status >/dev/null 2>&1"
+ _service_cmd="/usr/sbin/service \$1 \$2"
+ elif [ -x /bin/sv ]; then
+ _service_exists="/bin/sv status \1 >/dev/null 2>&1"
+ _service_cmd="/bin/sv \$1 \$2"
+ elif [ -x /usr/bin/sv ]; then
+ _service_exists="/usr/bin/sv status \1 >/dev/null 2>&1"
+ _service_cmd="/usr/bin/sv \$1 \$2"
+ elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
+ _service_exists="[ -x /etc/rc.d/rc.\$1 ]"
+ _service_cmd="/etc/rc.d/rc.\$1 \$2"
+ _service_status="/etc/rc.d/rc.\$1 status >/dev/null 2>&1"
+ else
+ for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
+ if [ -d $x ]; then
+ _service_exists="[ -x $x/\$1 ]"
+ _service_cmd="$x/\$1 \$2"
+ _service_status="$x/\$1 $status >/dev/null 2>&1"
+ break
+ fi
+ done
+ if [ -e /etc/arch-release ]; then
+ _service_status="[ -e /var/run/daemons/\$1 ]"
+ elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then
+ _service_status="$x/\$1 check >/dev/null 2>&1"
+ fi
+ fi
+
+ _detected_init=true
+ if [ -z "$_service_cmd" ]; then
+ syslog err "could not detect a useable init system"
+ return 1
+ fi
+ return 0
+}
+
+# Check a system service exists
+service_exists()
+{
+
+ if [ -z "$_service_exists" ]; then
+ detect_init || return 1
+ fi
+ eval $_service_exists
+}
+
+# Send a command to a system service
+service_cmd()
+{
+
+ if [ -z "$_service_cmd" ]; then
+ detect_init || return 1
+ fi
+ eval $_service_cmd
+}
+
+# Send a command to a system service if it is running
+service_status()
+{
+
+ if [ -z "$_service_cmd" ]; then
+ detect_init || return 1
+ fi
+ if [ -n "$_service_status" ]; then
+ eval $_service_status
+ else
+ service_command $1 status >/dev/null 2>&1
+ fi
+}
+
+# Handy macros for our hooks
+service_command()
+{
+
+ service_exists $1 && service_cmd $1 $2
+}
+service_condcommand()
+{
+
+ service_exists $1 && service_status $1 && service_cmd $1 $2
+}
+
+# We source each script into this one so that scripts run earlier can
+# remove variables from the environment so later scripts don't see them.
+# Thus, the user can create their dhcpcd.enter/exit-hook script to configure
+# /etc/resolv.conf how they want and stop the system scripts ever updating it.
+for hook in \
+ /etc/dhcpcd.enter-hook \
+ /libexec/dhcpcd-hooks/* \
+ /etc/dhcpcd.exit-hook
+do
+ for skip in $skip_hooks; do
+ case "$hook" in
+ */*~) continue 2;;
+ */"$skip") continue 2;;
+ */[0-9][0-9]"-$skip") continue 2;;
+ */[0-9][0-9]"-$skip.sh") continue 2;;
+ esac
+ done
+ if [ -f "$hook" ]; then
+ . "$hook"
+ fi
+done
diff --git a/builder/modules.d/wlan-boot/chroot/environment/usr/bin/systemd-preserve-process-marker b/builder/modules.d/wlan-boot/chroot/environment/usr/bin/systemd-preserve-process-marker
new file mode 100755
index 00000000..99d1e0c4
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/usr/bin/systemd-preserve-process-marker
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/dhcpcd b/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/dhcpcd
new file mode 100755
index 00000000..933e4cc7
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/dhcpcd
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/wpa_supplicant b/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/wpa_supplicant
new file mode 100755
index 00000000..39ddd72d
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/environment/usr/sbin/wpa_supplicant
Binary files differ
diff --git a/builder/modules.d/wlan-boot/chroot/wpa_libs.lst b/builder/modules.d/wlan-boot/chroot/wpa_libs.lst
new file mode 100644
index 00000000..ed5fa99e
--- /dev/null
+++ b/builder/modules.d/wlan-boot/chroot/wpa_libs.lst
@@ -0,0 +1,21 @@
+/lib64/libnl-3.so.200
+/lib64/libnl-genl-3.so.200
+/lib64/libdl.so.2
+/lib64/libssl.so.10
+/lib64/libcrypto.so.10
+/lib64/libdbus-1.so.3
+/lib64/libc.so.6
+/lib64/libpthread.so.0
+/lib64/libm.so.6
+/lib64/libgssapi_krb5.so.2
+/lib64/libkrb5.so.3
+/lib64/libcom_err.so.2
+/lib64/libk5crypto.so.3
+/lib64/libz.so.1
+/lib64/librt.so.1
+/lib64/libkrb5support.so.0
+/lib64/libkeyutils.so.1
+/lib64/libresolv.so.2
+/lib64/libselinux.so.1
+/lib64/libpcre.so.1
+/lib64/liblzma.so.5
diff --git a/builder/modules.d/wlan-boot/debug/binaries/busybox.tar b/builder/modules.d/wlan-boot/debug/binaries/busybox.tar
new file mode 100755
index 00000000..b5ac4a64
--- /dev/null
+++ b/builder/modules.d/wlan-boot/debug/binaries/busybox.tar
Binary files differ
diff --git a/builder/modules.d/wlan-boot/debug/hooks/install_busybox.sh b/builder/modules.d/wlan-boot/debug/hooks/install_busybox.sh
new file mode 100755
index 00000000..3b763f0e
--- /dev/null
+++ b/builder/modules.d/wlan-boot/debug/hooks/install_busybox.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+#tar xf /root/busybox.tar -C /sysroot/usr/sbin/ usr/sbin/udhcpc
+#tar xf /root/busybox.tar -C /sysroot/usr/bin/ usr/bin/busybox
+tar xf /root/busybox.tar -C /sysroot/opt/openslx/
diff --git a/builder/modules.d/wlan-boot/debug/scripts/restart_wpa.sh b/builder/modules.d/wlan-boot/debug/scripts/restart_wpa.sh
new file mode 100755
index 00000000..3e284772
--- /dev/null
+++ b/builder/modules.d/wlan-boot/debug/scripts/restart_wpa.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+PID=$(pgrep wpa_supplicant)
+systemctl stop wpa_supplicant
+kill -9 "$PID"
+systemctl start wpa_supplicant
+ip route add default via 10.125.1.254 dev wlan0 &>> /tmp/wlan.log
diff --git a/builder/modules.d/wlan-boot/debug/services/debug-shell.service b/builder/modules.d/wlan-boot/debug/services/debug-shell.service
new file mode 100644
index 00000000..462694a6
--- /dev/null
+++ b/builder/modules.d/wlan-boot/debug/services/debug-shell.service
@@ -0,0 +1,33 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Early root shell on /dev/tty9 FOR DEBUGGING ONLY
+Documentation=man:sushell(8)
+DefaultDependencies=no
+IgnoreOnIsolate=yes
+
+[Service]
+Environment=TERM=linux
+ExecStart=/opt/openslx/usr/bin/busybox ash
+Restart=always
+RestartSec=0
+StandardInput=tty
+TTYPath=/dev/tty9
+TTYReset=yes
+TTYVHangup=yes
+KillMode=process
+IgnoreSIGPIPE=no
+# bash ignores SIGTERM
+KillSignal=SIGHUP
+
+# Unset locale for the console getty since the console has problems
+# displaying some internationalized messages.
+Environment=LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGES= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
+
+[Install]
+WantedBy=sysinit.target
diff --git a/builder/modules.d/wlan-boot/hooks/parse-wlan-kernel-command-line-parameter.sh b/builder/modules.d/wlan-boot/hooks/parse-wlan-kernel-command-line-parameter.sh
new file mode 100755
index 00000000..dbda284c
--- /dev/null
+++ b/builder/modules.d/wlan-boot/hooks/parse-wlan-kernel-command-line-parameter.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# this hook will be executed in cmdline as 10
+
+# generate the config file for wpa_supplicant from
+# the kernel commandline parameters
+
+WIFACE=wlan0
+CONFDIR=/etc/
+WPACONF="$CONFDIR"/wpa_supplicant.conf
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+SSID=$(getarg ssid=)
+PASSWORD=$(getarg pw=)
+USERNAME=$(getarg user=)
+
+if [ "$SSID" = "eduroam" ]; then
+ # write ssid and pw in wpa_supplicant.conf
+ cat > "$WPACONF" << EOF
+ # path to UNIX socket control interface
+ ctrl_interface=/var/run/wpa_supplicant
+ ap_scan=1
+ network={
+ ssid="$SSID"
+ proto=RSN
+ key_mgmt=WPA-EAP
+ eap=TTLS
+ identity="$USERNAME"
+ password="$PASSWORD"
+ ca_cert="$CONFDIR/ssl/certs/Deutsche_Telekom_Root_CA_2.pem"
+ phase2="auth=MSCHAPv2"
+ }
+EOF
+else
+ echo "ctrl_interface=/var/run/wpa_supplicant" > "$WPACONF"
+ wpa_passphrase "$SSID" "$PASSWORD" >> "$WPACONF"
+fi
diff --git a/builder/modules.d/wlan-boot/hooks/prepare-newroot.sh b/builder/modules.d/wlan-boot/hooks/prepare-newroot.sh
new file mode 100755
index 00000000..c58ea15c
--- /dev/null
+++ b/builder/modules.d/wlan-boot/hooks/prepare-newroot.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# copy the wpa_supplicant.service to the new system to prevent systemd
+# killing the wpa_supplicant process
+
+# this hook will be executed in pre-pivot as 00
+
+# get the systemd path on the new system
+systemd_system_unit_path="/etc/systemd/system"
+new_systemd_system_unit_path="${NEWROOT}""$systemd_system_unit_path"
+
+#### copy from the current to the new system
+cp "/usr/bin/systemd-preserve-process-marker" "${NEWROOT}/usr/bin/systemd-preserve-process-marker"
+#cp "/usr/bin/simple.script" "${NEWROOT}/usr/bin/simple.script"
+
+## dhcpcd
+cp "/etc/systemd/system/dhcp.service" "${new_systemd_system_unit_path}/dhcp.service"
+cp "/usr/sbin/dhcpcd" "/sysroot/usr/sbin/dhcpcd"
+mkdir -p /sysroot/libexec/
+#mount -t tmpfs tmpfs /sysroot/libexec/
+cp -r /libexec/* "${NEWROOT}/libexec/"
+
+## wpa_supplicant
+cp "/etc/systemd/system/wpa_supplicant.service" "${new_systemd_system_unit_path}/wpa_supplicant.service"
+mkdir --parents "${NEWROOT}/etc"
+cp /etc/wpa_supplicant.conf "${NEWROOT}/etc/wpa_supplicant.conf"
+
+## certificate
+mkdir --parents "${NEWROOT}/etc/ssl/certs"
+cp /etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem "${NEWROOT}/etc/ssl/certs"
+
+## linking in sysinit.target.wants
+mkdir --parents "${new_systemd_system_unit_path}/sysinit.target.wants"
+cd "${new_systemd_system_unit_path}/sysinit.target.wants"
+! ln --symbolic '../wpa_supplicant.service'
+! ln --symbolic '../dhcp.service'
+
+# disable NetworkManager.service
+rm /sysroot/etc/systemd/system/dbus-org.freedesktop.NetworkManager.service
+rm /sysroot/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
+rm /sysroot/etc/systemd/system/multi-user.target.wants/NetworkManager.service
+
+
+### DEBUG ###
+cp /root/debug-shell.service ${NEWROOT}/etc/systemd/system/debug-shell.service
+! ln --symbolic '../debug-shell.service'
+cp /usr/sbin/restart_wpa /sysroot/usr/sbin/restart_wpa
diff --git a/builder/modules.d/wlan-boot/hooks/start_wlan.sh b/builder/modules.d/wlan-boot/hooks/start_wlan.sh
new file mode 100755
index 00000000..c39b9161
--- /dev/null
+++ b/builder/modules.d/wlan-boot/hooks/start_wlan.sh
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+shell () {
+ if [ $# -eq 0 ] ; then
+ REASON="Unknown Reason"
+ else
+ REASON="$1"
+ fi
+ warn ''
+ warn "ERROR: $REASON"
+ warn ' Entering rescue shell.'
+ warn ' Exit shell to continue booting.'
+ emergency_shell
+}
+
+# wiface name should be wlan0, if not udev failed
+WIFACE=wlan0
+timeout=20
+#LEASES="/var/lib/dhcp/dhclient.leases"
+
+### OLD, now use dhcpcd
+## Install udhcpc (maybe do this in module-setup-sh)
+#[ -f /root/busybox.tar ] || shell "cant find /root/busybox.tar"
+#tar xf /root/busybox.tar usr/bin/busybox
+#tar xf /root/busybox.tar usr/sbin/udhcpc
+
+# require the 99base dracut module
+type strstr >/dev/null 2>&1 || . /lib/dracut-lib.sh || shell "/lib/dracut-lib.sh doesnt exist"
+
+# set interface up
+cnt=0
+while [ $cnt -lt $timeout ]; do
+ if [ -e /sys/class/net/wlan0 ] ; then
+ /sbin/ip link set dev "$WIFACE" up || shell "Could not set dev $WIFACE up"
+ break
+ fi
+ sleep 1
+ cnt=$(($cnt+1))
+ warn "waiting for wlan interface up ("$cnt"s / 20s)"
+ [ $cnt -eq $timeout ] && shell "Could not find a valid wlan interface, make sure its enabled by hardware side"
+done
+
+## start wpa_supplicant service
+#systemctl start wpa_supplicant.service || shell "Could not start wpa_supplicant.service"
+#
+## wait for wpa_supplicant, similair to the network dracut module 40network/net-lib.sh
+#cnt=0
+#while [ $cnt -lt $timeout ]; do
+# li=$(ip -o link show up dev "$WIFACE")
+# if ! strstr "$li" "NO-CARRIER"; then
+# if [ -n "$li" ]; then
+# case "$li" in
+# *\<UP*)
+# break;;
+# *\<*,UP\>*)
+# break;;
+# *\<*,UP,*\>*)
+# break;;
+# esac
+# fi
+# fi
+# sleep 1
+# cnt=$(($cnt+1))
+# warn "Waiting for wpa_supplicant. Make sure interface is up and the AP is reachable with the correct credentials ("$cnt"s / 20s)"
+# [ $cnt -eq $timeout ] && shell "Could not find a CARRIER please check the credentials and if the AP is active"
+#done
+
+systemctl start dhcp.service || shell "Could not start dhcp.service"
+
+## wait for dhcpcd
+SLXSRV=$(getarg slxsrv=)
+cnt=0
+while [ $cnt -lt $timeout ]; do
+ ping -c 1 -q "$SLXSRV"
+ if [ $? -eq 0 ] ; then
+ break
+ fi
+ sleep 1
+ cnt=$(($cnt+1))
+ warn "Waiting for dhcpcd. Make sure wpa_supplicant finished startup and slxserver $SLXSRV is reachable ("$cnt"s / 20s)"
+ [ $cnt -eq $timeout ] && shell "Could not ping slx server."
+done
+
+## dhclient didnt set route, now i use dhcpcd this works fine
+# set route
+#TODO: look into /sbin/dhclient-script why no route is set automaticly
+##ADDRESS=$(sed -n '/wlan0/,/}/p' $LEASES | grep 'fixed-address' | sort -u | awk -F' ' '{print $2}' | awk -F';' '{print $1}' | head -1)
+#ROUTE=$(sed -n '/wlan0/,/}/p' $LEASES | grep 'option routers' | sort -u | awk -F' ' '{print $3}' | awk -F';' '{print $1}'| head -1)
+#echo "ROUTE=$ROUTE" >> /tmp/wlan.log
+#
+##ip addr add "$ADDRESS/24" dev "$WIFACE"
+#ip route add default via "$ROUTE" dev "$WIFACE" &>> /tmp/wlan.log
+#echo $? >> /tmp/wlan.log
diff --git a/builder/modules.d/wlan-boot/module-setup.sh b/builder/modules.d/wlan-boot/module-setup.sh
new file mode 100755
index 00000000..d944c1a9
--- /dev/null
+++ b/builder/modules.d/wlan-boot/module-setup.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# called by dracut
+check() {
+ return 255
+}
+
+# called by dracut
+depends() {
+ return 0
+}
+
+installkernel() {
+ instmods cfg80211 mac80211 rtl8192cu iwlwifi iwldvm
+}
+
+# called by dracut
+install() {
+
+
+ # SYSTEMD PRESERVE SCRIPT
+ inst_script "$moddir/binaries/systemd-preserve-process-marker" /usr/bin/systemd-preserve-process-marker
+
+ # PARSE COMMAND LINE
+ inst_hook cmdline 10 "$moddir/hooks/parse-wlan-kernel-command-line-parameter.sh"
+
+ # PREPARE NEWROOT
+ inst_hook pre-pivot 00 "$moddir/hooks/prepare-newroot.sh"
+
+ # STARTSCRIPT WPA AND DHCP
+ inst_hook pre-mount 00 "$moddir/hooks/start_wlan.sh"
+ #inst_script "$moddir/scripts/start_wlan.sh" /usr/sbin/start_wlan
+
+ # UDEV
+ inst_script "$moddir/udev/80-net-wlan.rules" /etc/udev/rules.d/80-net-wlan.rules
+
+ # DHCP
+ mkdir -m 0755 -p ${initdir}"/libexec"
+ mkdir -m 0755 -p ${initdir}"/libexec/dhcpcd-hooks"
+ inst_script "$moddir/scripts/dhcpcd-run-hooks" /libexec/dhcpcd-run-hooks
+ inst_script "$moddir/binaries/dhcpcd" /usr/sbin/dhcpcd
+ inst_simple "$moddir/services/dhcp.service" "/etc/systemd/system/dhcp.service"
+ mkdir -m 0755 -p ${initdir}"/etc/dhcpcd.enter-hook"
+ inst_script "$moddir/scripts/dhcpcd-hooks/20-resolv.conf" /libexec/dhcpcd-hooks/20-resolv.conf
+ inst_script "$moddir/scripts/dhcpcd-hooks/10-wpa_supplicant" /libexec/dhcpcd-hooks/10-wpa_supplicant
+
+ # WPA
+ mkdir -m 0755 -p ${initdir}"/etc/ssl/certs"
+ inst_simple "$moddir/certs/Deutsche_Telekom_Root_CA_2.pem" /etc/ssl/certs/Deutsche_Telekom_Root_CA_2.pem
+ inst_simple "$moddir/services/wpa_supplicant.service" "/etc/systemd/system/wpa_supplicant.service"
+ inst_simple "$moddir/services/newroot_wpa_supplicant.service" "/root/newroot_wpa_supplicant.service"
+
+ # CHROOT ENVIRONMENT
+ inst_simple "$moddir/chroot/environment.tar" "/root/environment.tar"
+
+ #### DEBUG ####
+ inst_simple "$moddir/debug/binaries/busybox.tar" "/root/busybox.tar"
+ inst_simple "$moddir/debug/services/debug-shell.service" "/root/debug-shell.service"
+ inst_simple "$moddir/debug/services/test.service" "/etc/systemd/system/test.service"
+ inst_simple "$moddir/debug/scripts/test.sh" "/usr/bin/test"
+ inst_hook pre-pivot 10 "$moddir/debug/hooks/install_busybox.sh"
+ inst_script "$moddir/debug/scripts/restart_wpa.sh" /usr/sbin/restart_wpa
+
+ inst_multiple wpa_passphrase ip wpa_supplicant wpa_cli rfkill iw crda ps grep sort awk head dhclient vim ifconfig route pgrep wc chmod date
+}
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/01-test b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/01-test
new file mode 100755
index 00000000..d4cf8281
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/01-test
@@ -0,0 +1,8 @@
+# Echo the interface flags, reason and message options
+
+if [ "$reason" = "TEST" ]; then
+ set | grep "^\(interface\|pid\|reason\|profile\|skip_hooks\)=" | sort
+ set | grep "^if\(carrier\|flags\|mtu\|wireless\|ssid\)=" | sort
+ set | grep "^\(new_\|old_\|nd[0-9]*_\)" | sort
+ exit 0
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/02-dump b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/02-dump
new file mode 100755
index 00000000..0d515f78
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/02-dump
@@ -0,0 +1,8 @@
+# Just echo our DHCP options we have
+
+case "$reason" in
+DUMP|DUMP6)
+ set | sed -ne 's/^new_//p' | sort
+ exit 0
+ ;;
+esac
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/10-wpa_supplicant b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/10-wpa_supplicant
new file mode 100755
index 00000000..adea9957
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/10-wpa_supplicant
@@ -0,0 +1,118 @@
+# Start, reconfigure and stop wpa_supplicant per wireless interface.
+# This is needed because wpa_supplicant lacks hotplugging of any kind
+# and the user should not be expected to have to wire it into their system
+# if the base system doesn't do this itself.
+
+if [ -z "$wpa_supplicant_conf" ]; then
+ for x in \
+ /etc/wpa_supplicant/wpa_supplicant-"$interface".conf \
+ /etc/wpa_supplicant/wpa_supplicant.conf \
+ /etc/wpa_supplicant-"$interface".conf \
+ /etc/wpa_supplicant.conf \
+ ; do
+ if [ -s "$x" ]; then
+ wpa_supplicant_conf="$x"
+ break
+ fi
+ done
+fi
+: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}
+
+wpa_supplicant_ctrldir()
+{
+ local dir
+
+ dir=$(key_get_value "[[:space:]]*ctrl_interface=" \
+ "$wpa_supplicant_conf")
+ dir=$(trim "$dir")
+ case "$dir" in
+ DIR=*)
+ dir=${dir##DIR=}
+ dir=${dir%%[[:space:]]GROUP=*}
+ dir=$(trim "$dir")
+ ;;
+ esac
+ printf %s "$dir"
+}
+
+wpa_supplicant_start()
+{
+ local dir err errn
+
+ # If the carrier is up, don't bother checking anything
+ [ "$ifcarrier" = "up" ] && return 0
+
+ # Pre flight checks
+ if [ ! -s "$wpa_supplicant_conf" ]; then
+ syslog warn \
+ "$wpa_supplicant_conf does not exist"
+ syslog warn "not interacting with wpa_supplicant(8)"
+ return 1
+ fi
+ dir=$(wpa_supplicant_ctrldir)
+ if [ -z "$dir" ]; then
+ syslog warn \
+ "ctrl_interface not defined in $wpa_supplicant_conf"
+ syslog warn "not interacting with wpa_supplicant(8)"
+ return 1
+ fi
+
+ wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 && return 0
+ syslog info "starting wpa_supplicant"
+ driver=${wpa_supplicant_driver:+-D}$wpa_supplicant_driver
+ err=$(systemctl start wpa_supplicant 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to start wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+wpa_supplicant_reconfigure()
+{
+ local dir err errn
+
+ dir=$(wpa_supplicant_ctrldir)
+ [ -z "$dir" ] && return 1
+ if ! wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1; then
+ wpa_supplicant_start
+ return $?
+ fi
+ syslog info "reconfiguring wpa_supplicant"
+ err=$(wpa_cli -p "$dir" -i "$interface" reconfigure 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to reconfigure wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+wpa_supplicant_stop()
+{
+ local dir err errn
+
+ dir=$(wpa_supplicant_ctrldir)
+ [ -z "$dir" ] && return 1
+ wpa_cli -p "$dir" -i "$interface" status >/dev/null 2>&1 || return 0
+ syslog info "stopping wpa_supplicant"
+ err=$(wpa_cli -i"$interface" terminate 2>&1)
+ errn=$?
+ if [ $errn != 0 ]; then
+ syslog err "failed to start wpa_supplicant"
+ syslog err "$err"
+ fi
+ return $errn
+}
+
+if [ "$ifwireless" = "1" ] && \
+ type wpa_supplicant >/dev/null 2>&1 && \
+ type wpa_cli >/dev/null 2>&1
+then
+ case "$reason" in
+ PREINIT|NOCARRIER) wpa_supplicant_start;;
+ RECONFIGURE) wpa_supplicant_reconfigure;;
+ DEPARTED) wpa_supplicant_stop;;
+ esac
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone
new file mode 100755
index 00000000..0ccdc45b
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/15-timezone
@@ -0,0 +1,48 @@
+# Configure timezone
+
+: ${localtime:=/etc/localtime}
+
+set_zoneinfo()
+{
+ local zoneinfo_dir= zone_file=
+
+ [ -z "$new_tzdb_timezone" ] && return 0
+
+ for d in \
+ /usr/share/zoneinfo \
+ /usr/lib/zoneinfo \
+ /var/share/zoneinfo \
+ /var/zoneinfo \
+ ; do
+ if [ -d "$d" ]; then
+ zoneinfo_dir="$d"
+ break
+ fi
+ done
+
+ if [ -z "$zoneinfo_dir" ]; then
+ syslog warning "timezone directory not found"
+ return 1
+ fi
+
+ zone_file="$zoneinfo_dir/$new_tzdb_timezone"
+ if [ ! -e "$zone_file" ]; then
+ syslog warning "no timezone definition for $new_tzdb_timezone"
+ return 1
+ fi
+
+ if copy_file "$zone_file" "$localtime"; then
+ syslog info "timezone changed to $new_tzdb_timezone"
+ fi
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+ new_tzdb_timezone="$new_dhcp6_tzdb_timezone"
+ ;;
+esac
+
+if $if_up; then
+ set_zoneinfo
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/20-resolv.conf b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/20-resolv.conf
new file mode 100755
index 00000000..e4db368d
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/20-resolv.conf
@@ -0,0 +1,204 @@
+# Generate /etc/resolv.conf
+# Support resolvconf(8) if available
+# We can merge other dhcpcd resolv.conf files into one like resolvconf,
+# but resolvconf is preferred as other applications like VPN clients
+# can readily hook into it.
+# Also, resolvconf can configure local nameservers such as bind
+# or dnsmasq. This is important as the libc resolver isn't that powerful.
+
+resolv_conf_dir="$state_dir/resolv.conf"
+NL="
+"
+: ${resolvconf:=resolvconf}
+
+build_resolv_conf()
+{
+ local cf="$state_dir/resolv.conf.$ifname"
+ local interfaces= header= search= srvs= servers= x=
+
+ # Build a list of interfaces
+ interfaces=$(list_interfaces "$resolv_conf_dir")
+
+ # Build the resolv.conf
+ if [ -n "$interfaces" ]; then
+ # Build the header
+ for x in ${interfaces}; do
+ header="$header${header:+, }$x"
+ done
+
+ # Build the search list
+ domain=$(cd "$resolv_conf_dir"; \
+ key_get_value "domain " ${interfaces})
+ search=$(cd "$resolv_conf_dir"; \
+ key_get_value "search " ${interfaces})
+ set -- ${domain}
+ domain="$1"
+ [ -n "$2" ] && search="$search $*"
+ [ -n "$search" ] && search="$(uniqify $search)"
+ [ "$domain" = "$search" ] && search=
+ [ -n "$domain" ] && domain="domain $domain$NL"
+ [ -n "$search" ] && search="search $search$NL"
+
+ # Build the nameserver list
+ srvs=$(cd "$resolv_conf_dir"; \
+ key_get_value "nameserver " ${interfaces})
+ for x in $(uniqify ${srvs}); do
+ servers="${servers}nameserver $x$NL"
+ done
+ fi
+ header="$signature_base${header:+ $from }$header"
+
+ # Assemble resolv.conf using our head and tail files
+ [ -f "$cf" ] && rm -f "$cf"
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ echo "$header" > "$cf"
+ if [ -f /etc/resolv.conf.head ]; then
+ cat /etc/resolv.conf.head >> "$cf"
+ else
+ echo "# /etc/resolv.conf.head can replace this line" >> "$cf"
+ fi
+ printf %s "$domain$search$servers" >> "$cf"
+ if [ -f /etc/resolv.conf.tail ]; then
+ cat /etc/resolv.conf.tail >> "$cf"
+ else
+ echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
+ fi
+ if change_file /etc/resolv.conf "$cf"; then
+ chmod 644 /etc/resolv.conf
+ fi
+ rm -f "$cf"
+}
+
+# Extract any ND DNS options from the RA
+# For now, we ignore the lifetime of the DNS options unless they
+# are absent or zero.
+# In this case they are removed from consideration.
+# See draft-gont-6man-slaac-dns-config-issues-01 for issues
+# regarding DNS option lifetime in ND messages.
+eval_nd_dns()
+{
+
+ eval ltime=\$nd${i}_rdnss${j}_lifetime
+ if [ -z "$ltime" -o "$ltime" = 0 ]; then
+ rdnss=
+ else
+ eval rdnss=\$nd${i}_rdnss${j}_servers
+ fi
+ eval ltime=\$nd${i}_dnssl${j}_lifetime
+ if [ -z "$ltime" -o "$ltime" = 0 ]; then
+ dnssl=
+ else
+ eval dnssl=\$nd${i}_dnssl${j}_search
+ fi
+
+ [ -z "$rdnss" -a -z "$dnssl" ] && return 1
+
+ [ -n "$rdnss" ] && new_rdnss="$new_rdnss${new_rdnss:+ }$rdnss"
+ [ -n "$dnssl" ] && new_dnssl="$new_dnssl${new_dnssl:+ }$dnssl"
+ j=$(($j + 1))
+ return 0
+}
+
+add_resolv_conf()
+{
+ local x= conf="$signature$NL" warn=true
+ local i j ltime rdnss dnssl new_rdnss new_dnssl
+
+ # Loop to extract the ND DNS options using our indexed shell values
+ i=1
+ j=1
+ while true; do
+ while true; do
+ eval_nd_dns || break
+ done
+ i=$(($i + 1))
+ j=1
+ eval_nd_dns || break
+ done
+ [ -n "$new_rdnss" ] && \
+ new_domain_name_servers="$new_domain_name_servers${new_domain_name_servers:+ }$new_rdnss"
+ [ -n "$new_dnssl" ] && \
+ new_domain_search="$new_domain_search${new_domain_search:+ }$new_dnssl"
+
+ # Derive a new domain from our various hostname options
+ if [ -z "$new_domain_name" ]; then
+ if [ "$new_dhcp6_fqdn" != "${new_dhcp6_fqdn#*.}" ]; then
+ new_domain_name="${new_dhcp6_fqdn#*.}"
+ elif [ "$new_fqdn" != "${new_fqdn#*.}" ]; then
+ new_domain_name="${new_fqdn#*.}"
+ elif [ "$new_host_name" != "${new_host_name#*.}" ]; then
+ new_domain_name="${new_host_name#*.}"
+ fi
+ fi
+
+ # If we don't have any configuration, remove it
+ if [ -z "$new_domain_name_servers" -a \
+ -z "$new_domain_name" -a \
+ -z "$new_domain_search" ]; then
+ remove_resolv_conf
+ return $?
+ fi
+
+ if [ -n "$new_domain_name" ]; then
+ set -- $new_domain_name
+ if valid_domainname "$1"; then
+ conf="${conf}domain $1$NL"
+ else
+ syslog err "Invalid domain name: $1"
+ fi
+ # If there is no search this, make this one
+ if [ -z "$new_domain_search" ]; then
+ new_domain_search="$new_domain_name"
+ [ "$new_domain_name" = "$1" ] && warn=true
+ fi
+ fi
+ if [ -n "$new_domain_search" ]; then
+ if valid_domainname_list $new_domain_search; then
+ conf="${conf}search $new_domain_search$NL"
+ elif ! $warn; then
+ syslog err "Invalid domain name in list:" \
+ "$new_domain_search"
+ fi
+ fi
+ for x in ${new_domain_name_servers}; do
+ conf="${conf}nameserver $x$NL"
+ done
+ if type "$resolvconf" >/dev/null 2>&1; then
+ [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
+ printf %s "$conf" | "$resolvconf" -a "$ifname"
+ return $?
+ fi
+
+ if [ -e "$resolv_conf_dir/$ifname" ]; then
+ rm -f "$resolv_conf_dir/$ifname"
+ fi
+ [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
+ printf %s "$conf" > "$resolv_conf_dir/$ifname"
+ build_resolv_conf
+}
+
+remove_resolv_conf()
+{
+ if type "$resolvconf" >/dev/null 2>&1; then
+ "$resolvconf" -d "$ifname" -f
+ else
+ if [ -e "$resolv_conf_dir/$ifname" ]; then
+ rm -f "$resolv_conf_dir/$ifname"
+ fi
+ build_resolv_conf
+ fi
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+ new_domain_name_servers="$new_dhcp6_name_servers"
+ new_domain_search="$new_dhcp6_domain_search"
+ ;;
+esac
+
+if $if_up || [ "$reason" = ROUTERADVERT ]; then
+ add_resolv_conf
+elif $if_down; then
+ remove_resolv_conf
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/29-lookup-hostname b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/29-lookup-hostname
new file mode 100755
index 00000000..04ad275e
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/29-lookup-hostname
@@ -0,0 +1,40 @@
+# Lookup the hostname in DNS if not set
+
+lookup_hostname()
+{
+ [ -z "$new_ip_address" ] && return 1
+ local h=
+ # Silly ISC programs love to send error text to stdout
+ if type dig >/dev/null 2>&1; then
+ h=$(dig +short -x $new_ip_address)
+ if [ $? = 0 ]; then
+ echo "$h" | sed 's/\.$//'
+ return 0
+ fi
+ elif type host >/dev/null 2>&1; then
+ h=$(host $new_ip_address)
+ if [ $? = 0 ]; then
+ echo "$h" \
+ | sed 's/.* domain name pointer \(.*\)./\1/'
+ return 0
+ fi
+ elif type getent >/dev/null 2>&1; then
+ h=$(getent hosts $new_ip_address)
+ if [ $? = 0 ]; then
+ echo "$h" | sed 's/[^ ]* *\([^ ]*\).*/\1/'
+ return 0
+ fi
+ fi
+ return 1
+}
+
+set_hostname()
+{
+ if [ -z "$new_host_name" -a -z "$new_fqdn_name" ]; then
+ export new_host_name="$(lookup_hostname)"
+ fi
+}
+
+if $if_up; then
+ set_hostname
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/30-hostname b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/30-hostname
new file mode 100755
index 00000000..eea6a5ce
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/30-hostname
@@ -0,0 +1,155 @@
+# Set the hostname from DHCP data if required
+
+# A hostname can either be a short hostname or a FQDN.
+# hostname_fqdn=true
+# hostname_fqdn=false
+# hostname_fqdn=server
+
+# A value of server means just what the server says, don't manipulate it.
+# This could lead to an inconsistent hostname on a DHCPv4 and DHCPv6 network
+# where the DHCPv4 hostname is short and the DHCPv6 has an FQDN.
+# DHCPv6 has no hostname option.
+# RFC4702 section 3.1 says FQDN should be prefered over hostname.
+#
+# As such, the default is hostname_fqdn=true so that a consistent hostname
+# is always assigned.
+: ${hostname_fqdn:=true}
+
+# Some systems don't have hostname(1)
+_hostname()
+{
+ local name=
+
+ if [ -z "$1" ]; then
+ if type hostname >/dev/null 2>&1; then
+ hostname
+ elif [ -r /proc/sys/kernel/hostname ]; then
+ read name </proc/sys/kernel/hostname && echo "$name"
+ elif sysctl kern.hostname >/dev/null 2>&1; then
+ sysctl -n kern.hostname
+ elif sysctl kernel.hostname >/dev/null 2>&1; then
+ sysctl -n kernel.hostname
+ else
+ return 1
+ fi
+ return $?
+ fi
+
+ # Always prefer hostname(1) if we have it
+ if type hostname >/dev/null 2>&1; then
+ hostname "$1"
+ elif [ -w /proc/sys/kernel/hostname ]; then
+ echo "$1" >/proc/sys/kernel/hostname
+ elif sysctl kern.hostname >/dev/null 2>&1; then
+ sysctl -w "kern.hostname=$1"
+ elif sysctl kernel.hostname >/dev/null 2>&1; then
+ sysctl -w "kernel.hostname=$1"
+ else
+ # We know this will fail, but it will now fail
+ # with an error to stdout
+ hostname "$1"
+ fi
+}
+
+need_hostname()
+{
+ local hostname hfqdn=false hshort=false
+
+ case "$force_hostname" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) return 0;;
+ esac
+
+ hostname="$(_hostname)"
+ case "$hostname" in
+ ""|"(none)"|localhost|localhost.localdomain) return 0;;
+ esac
+
+ case "$hostname_fqdn" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
+ ""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
+ *) hshort=true;;
+ esac
+
+ if [ -n "$old_fqdn" ]; then
+ if ${hfqdn} || ! ${hsort}; then
+ [ "$hostname" = "$old_fqdn" ]
+ else
+ [ "$hostname" = "${old_fqdn%%.*}" ]
+ fi
+ elif [ -n "$old_host_name" ]; then
+ if ${hfqdn}; then
+ if [ -n "$old_domain_name" -a \
+ "$old_host_name" = "${old_host_name#*.}" ]
+ then
+ [ "$hostname" = \
+ "$old_host_name.$old_domain_name" ]
+ else
+ [ "$hostname" = "$old_host_name" ]
+ fi
+ elif ${hshort}; then
+ [ "$hostname" = "${old_host_name%%.*}" ]
+ else
+ [ "$hostname" = "$old_host_name" ]
+ fi
+ else
+ # No old hostname
+ false
+ fi
+}
+
+try_hostname()
+{
+
+ if valid_domainname "$1"; then
+ _hostname "$1"
+ else
+ syslog err "Invalid hostname: $1"
+ fi
+}
+
+set_hostname()
+{
+ local hfqdn=false hshort=false
+
+ need_hostname || return
+
+ case "$hostname_fqdn" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|1) hfqdn=true;;
+ ""|[Ss][Ee][Rr][Vv][Ee][Rr]) ;;
+ *) hshort=true;;
+ esac
+
+ if [ -n "$new_fqdn" ]; then
+ if ${hfqdn} || ! ${hshort}; then
+ try_hostname "$new_fqdn"
+ else
+ try_hostname "${new_fqdn%%.*}"
+ fi
+ elif [ -n "$new_host_name" ]; then
+ if ${hfqdn}; then
+ if [ -n "$new_domain_name" -a \
+ "$new_host_name" = "${new_host_name#*.}" ]
+ then
+ try_hostname "$new_host_name.$new_domain_name"
+ else
+ try_hostname "$new_host_name"
+ fi
+ elif ${hshort}; then
+ try_hostname "${new_host_name%%.*}"
+ else
+ try_hostname "$new_host_name"
+ fi
+ fi
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+ new_fqdn="$new_dhcp6_fqdn"
+ old_fqdn="$old_dhcp6_fqdn"
+ ;;
+esac
+
+if $if_up; then
+ set_hostname
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-dhcpcd-compat b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-dhcpcd-compat
new file mode 100755
index 00000000..0d6256e6
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-dhcpcd-compat
@@ -0,0 +1,41 @@
+# Compat enter hook shim for older dhcpcd versions
+
+IPADDR=$new_ip_address
+INTERFACE=$interface
+NETMASK=$new_subnet_mask
+BROADCAST=$new_broadcast_address
+NETWORK=$new_network_number
+DHCPSID=$new_dhcp_server_identifier
+GATEWAYS=$new_routers
+DNSSERVERS=$new_domain_name_servers
+DNSDOMAIN=$new_domain_name
+DNSSEARCH=$new_domain_search
+NISDOMAIN=$new_nis_domain
+NISSERVERS=$new_nis_servers
+NTPSERVERS=$new_ntp_servers
+
+GATEWAY=
+for x in $new_routers; do
+ GATEWAY="$GATEWAY${GATEWAY:+,}$x"
+done
+DNS=
+for x in $new_domain_name_servers; do
+ DNS="$DNS${DNS:+,}$x"
+done
+
+r="down"
+case "$reason" in
+RENEW) r="up";;
+BOUND|INFORM|REBIND|REBOOT|TEST|TIMEOUT|IPV4LL) r="new";;
+esac
+
+if [ "$r" != "down" ]; then
+ rm -f /var/lib/dhcpcd-"$INTERFACE".info
+ for x in IPADDR INTERFACE NETMASK BROADCAST NETWORK DHCPSID GATEWAYS \
+ DNSSERVERS DNSDOMAIN DNSSEARCH NISDOMAIN NISSERVERS \
+ NTPSERVERS GATEWAY DNS; do
+ eval echo "$x=\'\$$x\'" >> /var/lib/dhcpcd-"$INTERFACE".info
+ done
+fi
+
+set -- /var/lib/dhcpcd-"$INTERFACE".info "$r"
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ntp.conf b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ntp.conf
new file mode 100755
index 00000000..74805039
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ntp.conf
@@ -0,0 +1,141 @@
+# Sample dhcpcd hook script for NTP
+# It will configure either one of NTP, OpenNTP or Chrony (in that order)
+# and will default to NTP if no default config is found.
+
+# Like our resolv.conf hook script, we store a database of ntp.conf files
+# and merge into /etc/ntp.conf
+
+# You can set the env var NTP_CONF to override the derived default on
+# systems with >1 NTP client installed.
+# Here is an example for OpenNTP
+# dhcpcd -e NTP_CONF=/usr/pkg/etc/ntpd.conf
+# or by adding this to /etc/dhcpcd.conf
+# env NTP_CONF=/usr/pkg/etc/ntpd.conf
+# or by adding this to /etc/dhcpcd.enter-hook
+# NTP_CONF=/usr/pkg/etc/ntpd.conf
+# To use Chrony instead, simply change ntpd.conf to chrony.conf in the
+# above examples.
+
+: ${ntp_confs:=ntp.conf ntpd.conf chrony.conf}
+: ${ntp_conf_dirs=/etc /usr/pkg/etc /usr/local/etc}
+ntp_conf_dir="$state_dir/ntp.conf"
+
+# If NTP_CONF is not set, work out a good default
+if [ -z "$NTP_CONF" ]; then
+ for d in ${ntp_conf_dirs}; do
+ for f in ${ntp_confs}; do
+ if [ -e "$d/$f" ]; then
+ NTP_CONF="$d/$f"
+ break 2
+ fi
+ done
+ done
+ [ -e "$NTP_CONF" ] || NTP_CONF=/etc/ntp.conf
+fi
+
+# Derive service name from configuration
+if [ -z "$ntp_service" ]; then
+ case "$NTP_CONF" in
+ *chrony.conf) ntp_service=chronyd;;
+ *) ntp_service=ntpd;;
+ esac
+fi
+
+# Debian has a seperate file for DHCP config to avoid stamping on
+# the master.
+if [ "$ntp_service" = ntpd ] && type invoke-rc.d >/dev/null 2>&1; then
+ [ -e /var/lib/ntp ] || mkdir /var/lib/ntp
+ : ${ntp_service:=ntp}
+ : ${NTP_DHCP_CONF:=/var/lib/ntp/ntp.conf.dhcp}
+fi
+
+: ${ntp_restart_cmd:=service_condcommand $ntp_service restart}
+
+ntp_conf=${NTP_CONF}
+NL="
+"
+
+build_ntp_conf()
+{
+ local cf="$state_dir/ntp.conf.$ifname"
+ local interfaces= header= srvs= servers= x=
+
+ # Build a list of interfaces
+ interfaces=$(list_interfaces "$ntp_conf_dir")
+
+ if [ -n "$interfaces" ]; then
+ # Build the header
+ for x in ${interfaces}; do
+ header="$header${header:+, }$x"
+ done
+
+ # Build a server list
+ srvs=$(cd "$ntp_conf_dir";
+ key_get_value "server " $interfaces)
+ if [ -n "$srvs" ]; then
+ for x in $(uniqify $srvs); do
+ servers="${servers}server $x$NL"
+ done
+ fi
+ fi
+
+ # Merge our config into ntp.conf
+ [ -e "$cf" ] && rm -f "$cf"
+ [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
+
+ if [ -n "$NTP_DHCP_CONF" ]; then
+ [ -e "$ntp_conf" ] && cp "$ntp_conf" "$cf"
+ ntp_conf="$NTP_DHCP_CONF"
+ elif [ -e "$ntp_conf" ]; then
+ remove_markers "$signature_base" "$signature_base_end" \
+ "$ntp_conf" > "$cf"
+ fi
+
+ if [ -n "$servers" ]; then
+ echo "$signature_base${header:+ $from }$header" >> "$cf"
+ printf %s "$servers" >> "$cf"
+ echo "$signature_base_end${header:+ $from }$header" >> "$cf"
+ else
+ [ -e "$ntp_conf" -a -e "$cf" ] || return
+ fi
+
+ # If we changed anything, restart ntpd
+ if change_file "$ntp_conf" "$cf"; then
+ [ -n "$ntp_restart_cmd" ] && eval $ntp_restart_cmd
+ fi
+}
+
+add_ntp_conf()
+{
+ local cf="$ntp_conf_dir/$ifname" x=
+
+ [ -e "$cf" ] && rm "$cf"
+ [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
+ if [ -n "$new_ntp_servers" ]; then
+ for x in $new_ntp_servers; do
+ echo "server $x" >> "$cf"
+ done
+ fi
+ build_ntp_conf
+}
+
+remove_ntp_conf()
+{
+ if [ -e "$ntp_conf_dir/$ifname" ]; then
+ rm "$ntp_conf_dir/$ifname"
+ fi
+ build_ntp_conf
+}
+
+# For ease of use, map DHCP6 names onto our DHCP4 names
+case "$reason" in
+BOUND6|RENEW6|REBIND6|REBOOT6|INFORM6)
+ new_ntp_servers="$new_dhcp6_sntp_servers"
+;;
+esac
+
+if $if_up; then
+ add_ntp_conf
+elif $if_down; then
+ remove_ntp_conf
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-yp.conf b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-yp.conf
new file mode 100755
index 00000000..2da68ebc
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-yp.conf
@@ -0,0 +1,56 @@
+# Sample dhcpcd hook for ypbind
+# This script is only suitable for the Linux version.
+
+ypbind_pid()
+{
+ [ -s /var/run/ypbind.pid ] && cat /var/run/ypbind.pid
+}
+
+make_yp_conf()
+{
+ [ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0
+ local cf=/etc/yp.conf."$ifname" prefix= x= pid=
+ rm -f "$cf"
+ echo "$signature" > "$cf"
+ if [ -n "$new_nis_domain" ]; then
+ if ! valid_domainname "$new_nis_domain"; then
+ syslog err "Invalid NIS domain name: $new_nis_domain"
+ rm -f "$cf"
+ return 1
+ fi
+ domainname "$new_nis_domain"
+ if [ -n "$new_nis_servers" ]; then
+ prefix="domain $new_nis_domain server "
+ else
+ echo "domain $new_nis_domain broadcast" >> "$cf"
+ fi
+ else
+ prefix="ypserver "
+ fi
+ for x in $new_nis_servers; do
+ echo "$prefix$x" >> "$cf"
+ done
+ save_conf /etc/yp.conf
+ cat "$cf" > /etc/yp.conf
+ rm -f "$cf"
+ pid="$(ypbind_pid)"
+ if [ -n "$pid" ]; then
+ kill -HUP "$pid"
+ fi
+}
+
+restore_yp_conf()
+{
+ [ -n "$old_nis_domain" ] && domainname ""
+ restore_conf /etc/yp.conf || return 0
+ local pid="$(ypbind_pid)"
+ if [ -n "$pid" ]; then
+ kill -HUP "$pid"
+ fi
+}
+
+if $if_up; then
+ make_yp_conf
+elif $if_down; then
+ restore_yp_conf
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ypbind.in b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ypbind.in
new file mode 100755
index 00000000..a9ebbfa6
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-hooks/50-ypbind.in
@@ -0,0 +1,86 @@
+# Sample dhcpcd hook for ypbind
+# This script is only suitable for the BSD versions.
+
+: ${ypbind_restart_cmd:=service_command ypbind restart}
+: ${ypbind_stop_cmd:=service_condcommand ypbind stop}
+ypbind_dir="$state_dir/ypbind"
+: ${ypdomain_dir:=@YPDOMAIN_DIR@}
+: ${ypdomain_suffix:=@YPDOMAIN_SUFFIX@}
+
+
+best_domain()
+{
+ local i=
+
+ for i in "$ypbind_dir/$interface_order".*; do
+ if [ -f "$i" ]; then
+ cat "$i"
+ return 0
+ fi
+ done
+ return 1
+}
+
+make_yp_binding()
+{
+ [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
+ echo "$new_nis_domain" >"$ypbind_dir/$ifname"
+
+ if [ -z "$ypdomain_dir" ]; then
+ false
+ else
+ local cf="$ypdomain_dir/$new_nis_domain$ypdomain_suffix"
+ if [ -n "$new_nis_servers" ]; then
+ local ncf="$cf.$ifname" x=
+ rm -f "$ncf"
+ for x in $new_nis_servers; do
+ echo "$x" >>"$ncf"
+ done
+ change_file "$cf" "$ncf"
+ else
+ [ -e "$cf" ] && rm "$cf"
+ fi
+ fi
+
+ local nd="$(best_domain)"
+ if [ $? = 0 -a "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+restore_yp_binding()
+{
+
+ rm -f "$ypbind_dir/$ifname"
+ local nd="$(best_domain)"
+ # We need to stop ypbind if there is no best domain
+ # otherwise it will just stall as we cannot set domainname
+ # to blank :/
+ if [ -z "$nd" ]; then
+ if [ -n "$ypbind_stop_cmd" ]; then
+ eval $ypbind_stop_cmd
+ fi
+ elif [ "$nd" != "$(domainname)" ]; then
+ domainname "$nd"
+ if [ -n "$ypbind_restart_cmd" ]; then
+ eval $ypbind_restart_cmd
+ fi
+ fi
+}
+
+if [ "$reason" = PREINIT ]; then
+ rm -f "$ypbind_dir/$interface".*
+elif $if_up || $if_down; then
+ if [ -n "$new_nis_domain" ]; then
+ if valid_domainname "$new_nis_domain"; then
+ make_yp_binding
+ else
+ syslog err "Invalid NIS domain name: $new_nis_domain"
+ fi
+ elif [ -n "$old_nis_domain" ]; then
+ restore_yp_binding
+ fi
+fi
diff --git a/builder/modules.d/wlan-boot/scripts/dhcpcd-run-hooks b/builder/modules.d/wlan-boot/scripts/dhcpcd-run-hooks
new file mode 100755
index 00000000..8caf0dc9
--- /dev/null
+++ b/builder/modules.d/wlan-boot/scripts/dhcpcd-run-hooks
@@ -0,0 +1,387 @@
+#!/bin/sh
+# dhcpcd client configuration script
+
+# Handy variables and functions for our hooks to use
+case "$reason" in
+ ROUTERADVERT)
+ ifsuffix=".ra";;
+ INFORM6|BOUND6|RENEW6|REBIND6|REBOOT6|EXPIRE6|RELEASE6|STOP6)
+ ifsuffix=".dhcp6";;
+ IPV4LL)
+ ifsuffix=".ipv4ll";;
+ *)
+ ifsuffix=".dhcp";;
+esac
+ifname="$interface$ifsuffix"
+
+from=from
+signature_base="# Generated by dhcpcd"
+signature="$signature_base $from $ifname"
+signature_base_end="# End of dhcpcd"
+signature_end="$signature_base_end $from $ifname"
+state_dir=/var/run/dhcpcd
+_detected_init=false
+
+: ${if_up:=false}
+: ${if_down:=false}
+: ${syslog_debug:=false}
+
+# Ensure that all arguments are unique
+uniqify()
+{
+ local result= i=
+ for i do
+ case " $result " in
+ *" $i "*);;
+ *) result="$result $i";;
+ esac
+ done
+ echo "${result# *}"
+}
+
+# List interface config files in a directory.
+# If dhcpcd is running as a single instance then it will have a list of
+# interfaces in the preferred order.
+# Otherwise we just use what we have.
+list_interfaces()
+{
+ local i= x= ifaces=
+ for i in $interface_order; do
+ for x in "$1"/$i.*; do
+ [ -f "$x" ] && ifaces="$ifaces${ifaces:+ }${x##*/}"
+ done
+ done
+ for x in "$1"/*; do
+ [ -f "$x" ] && ifaces="$ifaces${ifaces:+ }${x##*/}"
+ done
+ uniqify $ifaces
+}
+
+# Trim function
+trim()
+{
+ local var="$*"
+
+ var=${var#"${var%%[![:space:]]*}"}
+ var=${var%"${var##*[![:space:]]}"}
+ if [ -z "$var" ]; then
+ # So it seems our shell doesn't support wctype(3) patterns
+ # Fall back to sed
+ var=$(echo "$*" | sed -e 's/^[[:space:]]*//;s/[[:space:]]*$//')
+ fi
+ printf %s "$var"
+}
+
+# We normally use sed to extract values using a key from a list of files
+# but sed may not always be available at the time.
+key_get_value()
+{
+ local key="$1" value= x= line=
+
+ shift
+ if type sed >/dev/null 2>&1; then
+ sed -n "s/^$key//p" $@
+ else
+ for x do
+ while read line; do
+ case "$line" in
+ "$key"*) echo "${line##$key}";;
+ esac
+ done < "$x"
+ done
+ fi
+}
+
+# We normally use sed to remove markers from a configuration file
+# but sed may not always be available at the time.
+remove_markers()
+{
+ local m1="$1" m2="$2" x= line= in_marker=0
+
+ shift; shift
+ if type sed >/dev/null 2>&1; then
+ sed "/^$m1/,/^$m2/d" $@
+ else
+ for x do
+ while read line; do
+ case "$line" in
+ "$m1"*) in_marker=1;;
+ "$m2"*) in_marker=0;;
+ *) [ $in_marker = 0 ] && echo "$line";;
+ esac
+ done < "$x"
+ done
+ fi
+}
+
+# Compare two files.
+comp_file()
+{
+
+ [ -e "$1" -a -e "$2" ] || return 1
+
+ if type cmp >/dev/null 2>&1; then
+ cmp -s "$1" "$2"
+ elif type diff >/dev/null 2>&1; then
+ diff -q "$1" "$2" >/dev/null
+ else
+ # Hopefully we're only working on small text files ...
+ [ "$(cat "$1")" = "$(cat "$2")" ]
+ fi
+}
+
+# Compare two files.
+# If different, replace first with second otherwise remove second.
+change_file()
+{
+
+ if [ -e "$1" ]; then
+ if comp_file "$1" "$2"; then
+ rm -f "$2"
+ return 1
+ fi
+ fi
+ cat "$2" > "$1"
+ rm -f "$2"
+ return 0
+}
+
+# Compare two files.
+# If different, copy or link depending on target type
+copy_file()
+{
+
+ if [ -h "$2" ]; then
+ [ "$(readlink "$2")" = "$1" ] && return 1
+ ln -sf "$1" "$2"
+ else
+ comp_file "$1" "$2" && return 1
+ cat "$1" >"$2"
+ fi
+}
+
+# Save a config file
+save_conf()
+{
+
+ if [ -f "$1" ]; then
+ rm -f "$1-pre.$interface"
+ cat "$1" > "$1-pre.$interface"
+ fi
+}
+
+# Restore a config file
+restore_conf()
+{
+
+ [ -f "$1-pre.$interface" ] || return 1
+ cat "$1-pre.$interface" > "$1"
+ rm -f "$1-pre.$interface"
+}
+
+# Write a syslog entry
+syslog()
+{
+ local lvl="$1"
+
+ if [ "$lvl" = debug ]; then
+ ${syslog_debug} || return 0
+ fi
+ [ -n "$lvl" ] && shift
+ [ -n "$*" ] || return 0
+ case "$lvl" in
+ err|error) echo "$interface: $*" >&2;;
+ *) echo "$interface: $*";;
+ esac
+ if type logger >/dev/null 2>&1; then
+ logger -i -p daemon."$lvl" -t dhcpcd-run-hooks "$interface: $*"
+ fi
+}
+
+# Check for a valid domain name as per RFC1123 with the exception of
+# allowing - and _ as they seem to be widely used.
+valid_domainname()
+{
+ local name="$1" label
+
+ [ -z "$name" -o ${#name} -gt 255 ] && return 1
+
+ while [ -n "$name" ]; do
+ label="${name%%.*}"
+ [ -z "$label" -o ${#label} -gt 63 ] && return 1
+ case "$label" in
+ -*|_*|*-|*_) return 1;;
+ # some sh require - as the first or last character in the class
+ # when matching it
+ *[![:alnum:]_-]*) return 1;;
+ esac
+ [ "$name" = "${name#*.}" ] && break
+ name="${name#*.}"
+ done
+ return 0
+}
+
+valid_domainname_list()
+{
+ local name
+
+ for name do
+ valid_domainname "$name" || return $?
+ done
+ return 0
+}
+
+# Check for a valid path
+valid_path()
+{
+
+ case "$@" in
+ *[![:alnum:]#%+-_:\.,@~\\/\[\]=\ ]*) return 1;;
+ esac
+ return 0
+}
+
+# With the advent of alternative init systems, it's possible to have
+# more than one installed. So we need to try and guess what one we're
+# using unless overriden by configure.
+detect_init()
+{
+ _service_exists=""
+ _service_cmd=""
+ _service_status=""
+
+ [ -n "$_service_cmd" ] && return 0
+
+ if ${_detected_init}; then
+ [ -n "$_service_cmd" ]
+ return $?
+ fi
+
+ # Detect the running init system.
+ # As systemd and OpenRC can be installed on top of legacy init
+ # systems we try to detect them first.
+ local status=""
+ : ${status:=status}
+ if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
+ _service_exists="/bin/systemctl --quiet is-enabled \$1.service"
+ _service_status="/bin/systemctl --quiet is-active \$1.service"
+ _service_cmd="/bin/systemctl \$2 \$1.service"
+ elif [ -x /usr/bin/systemctl -a -S /run/systemd/private ]; then
+ _service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
+ _service_status="/usr/bin/systemctl --quiet is-active \$1.service"
+ _service_cmd="/usr/bin/systemctl \$2 \$1.service"
+ elif [ -x /sbin/rc-service -a \
+ -s /libexec/rc/init.d/softlevel -o -s /run/openrc/softlevel ]
+ then
+ _service_exists="/sbin/rc-service -e \$1"
+ _service_cmd="/sbin/rc-service \$1 -- -D \$2"
+ elif [ -x /usr/sbin/invoke-rc.d ]; then
+ _service_exists="/usr/sbin/invoke-rc.d --query --quiet \$1 start >/dev/null 2>&1 || [ \$? = 104 ]"
+ _service_cmd="/usr/sbin/invoke-rc.d \$1 \$2"
+ elif [ -x /sbin/service ]; then
+ _service_exists="/sbin/service \$1 >/dev/null 2>&1"
+ _service_cmd="/sbin/service \$1 \$2"
+ elif [ -x /usr/sbin/service ]; then
+ _service_exists="/usr/sbin/service \$1 $status >/dev/null 2>&1"
+ _service_cmd="/usr/sbin/service \$1 \$2"
+ elif [ -x /bin/sv ]; then
+ _service_exists="/bin/sv status \1 >/dev/null 2>&1"
+ _service_cmd="/bin/sv \$1 \$2"
+ elif [ -x /usr/bin/sv ]; then
+ _service_exists="/usr/bin/sv status \1 >/dev/null 2>&1"
+ _service_cmd="/usr/bin/sv \$1 \$2"
+ elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
+ _service_exists="[ -x /etc/rc.d/rc.\$1 ]"
+ _service_cmd="/etc/rc.d/rc.\$1 \$2"
+ _service_status="/etc/rc.d/rc.\$1 status >/dev/null 2>&1"
+ else
+ for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
+ if [ -d $x ]; then
+ _service_exists="[ -x $x/\$1 ]"
+ _service_cmd="$x/\$1 \$2"
+ _service_status="$x/\$1 $status >/dev/null 2>&1"
+ break
+ fi
+ done
+ if [ -e /etc/arch-release ]; then
+ _service_status="[ -e /var/run/daemons/\$1 ]"
+ elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then
+ _service_status="$x/\$1 check >/dev/null 2>&1"
+ fi
+ fi
+
+ _detected_init=true
+ if [ -z "$_service_cmd" ]; then
+ syslog err "could not detect a useable init system"
+ return 1
+ fi
+ return 0
+}
+
+# Check a system service exists
+service_exists()
+{
+
+ if [ -z "$_service_exists" ]; then
+ detect_init || return 1
+ fi
+ eval $_service_exists
+}
+
+# Send a command to a system service
+service_cmd()
+{
+
+ if [ -z "$_service_cmd" ]; then
+ detect_init || return 1
+ fi
+ eval $_service_cmd
+}
+
+# Send a command to a system service if it is running
+service_status()
+{
+
+ if [ -z "$_service_cmd" ]; then
+ detect_init || return 1
+ fi
+ if [ -n "$_service_status" ]; then
+ eval $_service_status
+ else
+ service_command $1 status >/dev/null 2>&1
+ fi
+}
+
+# Handy macros for our hooks
+service_command()
+{
+
+ service_exists $1 && service_cmd $1 $2
+}
+service_condcommand()
+{
+
+ service_exists $1 && service_status $1 && service_cmd $1 $2
+}
+
+# We source each script into this one so that scripts run earlier can
+# remove variables from the environment so later scripts don't see them.
+# Thus, the user can create their dhcpcd.enter/exit-hook script to configure
+# /etc/resolv.conf how they want and stop the system scripts ever updating it.
+for hook in \
+ /etc/dhcpcd.enter-hook \
+ /libexec/dhcpcd-hooks/* \
+ /etc/dhcpcd.exit-hook
+do
+ for skip in $skip_hooks; do
+ case "$hook" in
+ */*~) continue 2;;
+ */"$skip") continue 2;;
+ */[0-9][0-9]"-$skip") continue 2;;
+ */[0-9][0-9]"-$skip.sh") continue 2;;
+ esac
+ done
+ if [ -f "$hook" ]; then
+ . "$hook"
+ fi
+done
diff --git a/builder/modules.d/wlan-boot/services/dhcp.service b/builder/modules.d/wlan-boot/services/dhcp.service
new file mode 100644
index 00000000..6f87ac53
--- /dev/null
+++ b/builder/modules.d/wlan-boot/services/dhcp.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=DHCP dhclient
+ConditionFileIsExecutable=/usr/sbin/dhcpcd
+ConditionFileIsExecutable=/usr/bin/systemd-preserve-process-marker
+IgnoreOnIsolate=true
+DefaultDependencies=no
+
+[Service]
+Type=forking
+ExecStart=/usr/bin/systemd-preserve-process-marker /usr/sbin/dhcpcd wlan0
+RemainAfterExit=yes
+Restart=always
+#KillMode=process
+#KillSignal=SIGTERM
diff --git a/builder/modules.d/wlan-boot/services/wpa_supplicant.service b/builder/modules.d/wlan-boot/services/wpa_supplicant.service
new file mode 100644
index 00000000..350e19de
--- /dev/null
+++ b/builder/modules.d/wlan-boot/services/wpa_supplicant.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=WPA supplicant
+Before=dhcp.service
+#Wants=dhcp.service
+ConditionFileIsExecutable=/usr/sbin/wpa_supplicant
+ConditionFileIsExecutable=/usr/bin/systemd-preserve-process-marker
+ConditionPathExists=/etc/wpa_supplicant.conf
+IgnoreOnIsolate=true
+DefaultDependencies=no
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/systemd-preserve-process-marker /usr/sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
+RemainAfterExit=yes
+KillMode=process
+#KillSignal=SIGTERM
diff --git a/builder/modules.d/wlan-boot/udev/80-net-wlan.rules b/builder/modules.d/wlan-boot/udev/80-net-wlan.rules
new file mode 100644
index 00000000..c2c17b3b
--- /dev/null
+++ b/builder/modules.d/wlan-boot/udev/80-net-wlan.rules
@@ -0,0 +1,2 @@
+# Set the name of the interface to wlan0
+SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"