From f4429e978c8a828b6beaf1f01cf395d22e1ea799 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 9 Feb 2024 16:34:05 +0100 Subject: Use slx_service helper to create service files --- modules.d/busybox/module-setup.sh | 20 +++++----- .../services/s3-install-busybox-stage4.service | 11 ------ .../busybox/services/s3-install-busybox.service | 11 ------ modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh | 43 ++++++++++++++++++++++ modules.d/conf-tgz/module-setup.sh | 24 +++++++----- .../conf-tgz/services/s3-fetch-config-tgz.service | 13 ------- .../conf-tgz/services/s3-fetch-config.service | 13 ------- .../conf-tgz/services/s3-unpack-config-tgz.service | 12 ------ .../dnbd3-rootfs/hooks/s3-copy-openslx-config.sh | 43 ---------------------- modules.d/dnbd3-rootfs/module-setup.sh | 40 +++++--------------- .../services/s3-copy-openslx-config.service | 11 ------ .../dnbd3-rootfs/services/s3-dnbd3root.service | 15 -------- .../dnbd3-rootfs/services/s3-mount-root.service | 12 ------ modules.d/slx-addons/module-setup.sh | 14 +++---- .../slx-addons/services/s3-setup-addons.service | 14 ------- modules.d/slx-clock/module-setup.sh | 18 ++++----- .../services/s3-configure-timesyncd.service | 12 ------ modules.d/slx-clock/services/s3-ntp-sync.service | 13 ------- modules.d/slx-drm/module-setup.sh | 18 ++++----- .../services/s3-activate-nvidia-drivers.service | 13 ------- .../services/s3-copy-nvidia-drivers.service | 12 ------ modules.d/slx-network/module-setup.sh | 38 ++++++------------- .../services/s3-copy-network-files.service | 12 ------ .../services/s3-parse-network-kcl.service | 15 -------- .../services/s3-setup-bootif-network.service | 11 ------ modules.d/slx-runmode/module-setup.sh | 11 +----- .../slx-runmode/services/s3-enable-runmode.service | 12 ------ modules.d/slx-splash/hooks/s3-splash-stage4.sh | 25 +++++++++++++ modules.d/slx-splash/module-setup.sh | 6 ++- modules.d/slx-splash/scripts/slx-splash-stage4.sh | 25 ------------- modules.d/slx-ssl/module-setup.sh | 13 ++----- modules.d/slx-ssl/services/s3-ssl-sat.service | 12 ------ modules.d/slx-uuid/module-setup.sh | 12 ++---- .../slx-uuid/services/s3-get-system-uuid.service | 13 ------- 34 files changed, 146 insertions(+), 441 deletions(-) delete mode 100644 modules.d/busybox/services/s3-install-busybox-stage4.service delete mode 100644 modules.d/busybox/services/s3-install-busybox.service create mode 100755 modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh delete mode 100644 modules.d/conf-tgz/services/s3-fetch-config-tgz.service delete mode 100644 modules.d/conf-tgz/services/s3-fetch-config.service delete mode 100644 modules.d/conf-tgz/services/s3-unpack-config-tgz.service delete mode 100755 modules.d/dnbd3-rootfs/hooks/s3-copy-openslx-config.sh delete mode 100644 modules.d/dnbd3-rootfs/services/s3-copy-openslx-config.service delete mode 100644 modules.d/dnbd3-rootfs/services/s3-dnbd3root.service delete mode 100644 modules.d/dnbd3-rootfs/services/s3-mount-root.service delete mode 100644 modules.d/slx-addons/services/s3-setup-addons.service delete mode 100644 modules.d/slx-clock/services/s3-configure-timesyncd.service delete mode 100644 modules.d/slx-clock/services/s3-ntp-sync.service delete mode 100644 modules.d/slx-drm/services/s3-activate-nvidia-drivers.service delete mode 100644 modules.d/slx-drm/services/s3-copy-nvidia-drivers.service delete mode 100644 modules.d/slx-network/services/s3-copy-network-files.service delete mode 100644 modules.d/slx-network/services/s3-parse-network-kcl.service delete mode 100644 modules.d/slx-network/services/s3-setup-bootif-network.service delete mode 100644 modules.d/slx-runmode/services/s3-enable-runmode.service create mode 100755 modules.d/slx-splash/hooks/s3-splash-stage4.sh delete mode 100755 modules.d/slx-splash/scripts/slx-splash-stage4.sh delete mode 100644 modules.d/slx-ssl/services/s3-ssl-sat.service delete mode 100644 modules.d/slx-uuid/services/s3-get-system-uuid.service diff --git a/modules.d/busybox/module-setup.sh b/modules.d/busybox/module-setup.sh index 99e7574d..b068eabc 100755 --- a/modules.d/busybox/module-setup.sh +++ b/modules.d/busybox/module-setup.sh @@ -35,15 +35,13 @@ install() { derror "Failed to find busybox binary in build directory!" return 1 fi - inst "${moddir}/src/busybox" "/bin/busybox" - for _name in "s3-install-busybox" "s3-install-busybox-stage4"; do - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.requires" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.requires/${_name}.service" - done + if ! inst "${moddir}/src/busybox" "/bin/busybox"; then + derror "Could not install busybox" + return 1 + fi + slx_service "s3-install-busybox" "Install busybox applet symlinks" \ + --wbefore "dracut-cmdline.service" + slx_service "s3-install-busybox-stage4" "Install busybox into stage 4" \ + --wafter "initrd-root-fs.target" \ + --after "s3-install-busybox.service" } diff --git a/modules.d/busybox/services/s3-install-busybox-stage4.service b/modules.d/busybox/services/s3-install-busybox-stage4.service deleted file mode 100644 index b9ed87f0..00000000 --- a/modules.d/busybox/services/s3-install-busybox-stage4.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Install busybox into stage 4 -After=initrd-root-fs.target -Wants=initrd-root-fs.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-install-busybox-stage4.sh diff --git a/modules.d/busybox/services/s3-install-busybox.service b/modules.d/busybox/services/s3-install-busybox.service deleted file mode 100644 index b52500db..00000000 --- a/modules.d/busybox/services/s3-install-busybox.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Install busybox applet symlinks -Before=dracut-cmdline.service -Wants=dracut-cmdline.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-install-busybox.sh diff --git a/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh b/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh new file mode 100755 index 00000000..bedceb85 --- /dev/null +++ b/modules.d/conf-tgz/hooks/s3-copy-openslx-config.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# -*- coding: utf-8 -*- +type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh + +source "/etc/openslx" + +# Merge search domain from server and from dhcp +( + search="$SLX_NET_SEARCH" + source /run/openslx/network.conf + search="$SLX_NET_SEARCH $search" # DHCP > config vars + declare -a uniq + declare -A dups # Don't use keys for output later as order is undefined + for i in $search; do + [ -n "${dups["$i"]}" ] && continue + dups["$i"]=1 + uniq+=( "$i" ) + done + sed -i 's/^SLX_NET_SEARCH=/# &/' "/etc/openslx" "/run/openslx/network.conf" + echo "SLX_NET_SEARCH='${uniq[*]}'" >> "/run/openslx/network.conf" + if grep -q '^search' "/etc/resolv.conf"; then + sed -i "s/^search.*$/search ${uniq[*]}/" "/etc/resolv.conf" + else + echo "search ${uniq[*]}" "/etc/resolv.conf" + fi +) + + +mkdir --parents "${NEWROOT}/opt/openslx" +{ + cat "/etc/openslx" + echo "## Generated by '$0' in stage3" + cat "/run/openslx/network.conf" +} > "${NEWROOT}/opt/openslx/config" +ln -nfs "${NEWROOT}/opt/openslx/config" "/etc/openslx" + +# Set root/demo password for stage4, if set +if [ -n "${SLX_ROOT_PASS}" ]; then + sed -i "s#^root:[^:]*:#root:$SLX_ROOT_PASS:#" "$NEWROOT/etc/shadow" +fi +if [ -n "${SLX_DEMO_PASS}" ] && grep -q '^demo:' "$NEWROOT/etc/shadow"; then + sed -i "s#^demo:[^:]*:#demo:$SLX_DEMO_PASS:#" "$NEWROOT/etc/shadow" +fi diff --git a/modules.d/conf-tgz/module-setup.sh b/modules.d/conf-tgz/module-setup.sh index 936d4356..cf2ba088 100755 --- a/modules.d/conf-tgz/module-setup.sh +++ b/modules.d/conf-tgz/module-setup.sh @@ -9,14 +9,18 @@ depends() { install() { inst_multiple tar mktemp gzip - for _name in "s3-fetch-config" "s3-fetch-config-tgz" "s3-unpack-config-tgz"; do - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" - done + slx_service "s3-fetch-config" "Download text-based config" \ + --wafter "s3-setup-bootif-network.service" \ + --wafter "s3-get-system-uuid.service" + slx_service "s3-copy-openslx-config" "Copy final /opt/openslx/config to /sysroot" \ + --wafter "initrd-root-fs.target" \ + --wafter "s3-fetch-config.service" + + slx_service "s3-fetch-config-tgz" "Download config.tgz" \ + --after "s3-fetch-config.service" \ + --requires "s3-fetch-config.service" + slx_service "s3-unpack-config-tgz" "Unpack config.tgz to stage 4" \ + --after "initrd-root-fs.target" \ + --after "s3-fetch-config-tgz.service" \ + --requires "s3-fetch-config-tgz.service" } diff --git a/modules.d/conf-tgz/services/s3-fetch-config-tgz.service b/modules.d/conf-tgz/services/s3-fetch-config-tgz.service deleted file mode 100644 index 60d2b774..00000000 --- a/modules.d/conf-tgz/services/s3-fetch-config-tgz.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Download config.tgz -Requires=s3-setup-bootif-network.service -After=s3-setup-bootif-network.service -Wants=s3-fetch-config.service -After=s3-fetch-config.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-fetch-config-tgz.sh diff --git a/modules.d/conf-tgz/services/s3-fetch-config.service b/modules.d/conf-tgz/services/s3-fetch-config.service deleted file mode 100644 index 9d602899..00000000 --- a/modules.d/conf-tgz/services/s3-fetch-config.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Download config -Requires=s3-setup-bootif-network.service -After=s3-setup-bootif-network.service -Wants=s3-get-system-uuid.service -After=s3-get-system-uuid.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-fetch-config.sh diff --git a/modules.d/conf-tgz/services/s3-unpack-config-tgz.service b/modules.d/conf-tgz/services/s3-unpack-config-tgz.service deleted file mode 100644 index d3b9a3e0..00000000 --- a/modules.d/conf-tgz/services/s3-unpack-config-tgz.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Unpack config.tgz to stage 4 -After=initrd-root-fs.target -Requires=s3-fetch-config-tgz.service -After=s3-fetch-config-tgz.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-unpack-config-tgz.sh diff --git a/modules.d/dnbd3-rootfs/hooks/s3-copy-openslx-config.sh b/modules.d/dnbd3-rootfs/hooks/s3-copy-openslx-config.sh deleted file mode 100755 index bedceb85..00000000 --- a/modules.d/dnbd3-rootfs/hooks/s3-copy-openslx-config.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -# -*- coding: utf-8 -*- -type emergency_shell >/dev/null 2>&1 || source /lib/dracut-lib.sh - -source "/etc/openslx" - -# Merge search domain from server and from dhcp -( - search="$SLX_NET_SEARCH" - source /run/openslx/network.conf - search="$SLX_NET_SEARCH $search" # DHCP > config vars - declare -a uniq - declare -A dups # Don't use keys for output later as order is undefined - for i in $search; do - [ -n "${dups["$i"]}" ] && continue - dups["$i"]=1 - uniq+=( "$i" ) - done - sed -i 's/^SLX_NET_SEARCH=/# &/' "/etc/openslx" "/run/openslx/network.conf" - echo "SLX_NET_SEARCH='${uniq[*]}'" >> "/run/openslx/network.conf" - if grep -q '^search' "/etc/resolv.conf"; then - sed -i "s/^search.*$/search ${uniq[*]}/" "/etc/resolv.conf" - else - echo "search ${uniq[*]}" "/etc/resolv.conf" - fi -) - - -mkdir --parents "${NEWROOT}/opt/openslx" -{ - cat "/etc/openslx" - echo "## Generated by '$0' in stage3" - cat "/run/openslx/network.conf" -} > "${NEWROOT}/opt/openslx/config" -ln -nfs "${NEWROOT}/opt/openslx/config" "/etc/openslx" - -# Set root/demo password for stage4, if set -if [ -n "${SLX_ROOT_PASS}" ]; then - sed -i "s#^root:[^:]*:#root:$SLX_ROOT_PASS:#" "$NEWROOT/etc/shadow" -fi -if [ -n "${SLX_DEMO_PASS}" ] && grep -q '^demo:' "$NEWROOT/etc/shadow"; then - sed -i "s#^demo:[^:]*:#demo:$SLX_DEMO_PASS:#" "$NEWROOT/etc/shadow" -fi diff --git a/modules.d/dnbd3-rootfs/module-setup.sh b/modules.d/dnbd3-rootfs/module-setup.sh index ce1b4b36..594e3380 100755 --- a/modules.d/dnbd3-rootfs/module-setup.sh +++ b/modules.d/dnbd3-rootfs/module-setup.sh @@ -149,45 +149,25 @@ install() { inst_hook cmdline 90 "$moddir/hooks/set-dracut-environment-variables.sh" # make the final blockdevice for the root system (dnbd3 -> xmount -> # device-mapper) - inst "$moddir/hooks/s3-dnbd3root.sh" \ - /usr/local/bin/s3-dnbd3root.sh - inst_simple "${moddir}/services/s3-dnbd3root.service" \ - "${systemdsystemunitdir}/s3-dnbd3root.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd-root-device.target.requires" - ln_r "${systemdsystemunitdir}/s3-dnbd3root.service" \ - "${systemdsystemunitdir}/initrd-root-device.target.requires/s3-dnbd3root.service" + slx_service "s3-dnbd3root" "Setup dnbd3-based block device of rootfs" \ + --after "s3-fetch-config.service" \ + --after "dracut-pre-mount.service" \ + --wbefore "dracut-mount.service" \ + --wbefore "initrd-root-device.target" # Mount the root file system - inst "$moddir/hooks/s3-mount-root.sh" \ - /usr/local/bin/s3-mount-root.sh - inst_simple "${moddir}/services/s3-mount-root.service" \ - "${systemdsystemunitdir}/s3-mount-root.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd-root-fs.target.requires" - ln_r "${systemdsystemunitdir}/s3-mount-root.service" \ - "${systemdsystemunitdir}/initrd-root-fs.target.requires/s3-mount-root.service" - # Copy /opt/openslx/config to newroot - inst "$moddir/hooks/s3-copy-openslx-config.sh" \ - /usr/local/bin/s3-copy-openslx-config.sh - inst_simple "${moddir}/services/s3-copy-openslx-config.service" \ - "${systemdsystemunitdir}/s3-copy-openslx-config.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.requires" - ln_r "${systemdsystemunitdir}/s3-copy-openslx-config.service" \ - "${systemdsystemunitdir}/initrd.target.requires/s3-copy-openslx-config.service" + slx_service "s3-mount-root" "Mount /dev/mapper/root as /sysroot" \ + --after "initrd-root-device.target" \ + --requires "initrd-root-device.target" \ + --wbefore "initrd-root-fs.target" # Copy systemd services to new root (so they don't get killed after # switch_root) inst_hook pre-pivot 90 \ "$moddir/hooks/copy-dracut-systemd-files-into-newroot.sh" - #inst_hook pre-shutdown 00 "$moddir/hooks/shutdown-umount.sh" - #inst_hook pre-pivot 00 \ - # "$moddir/hooks/copy-openslx-configuration-into-newroot.sh" - # endregion - # region scripts # endregion # region configuration files mkdir --parents \ "${initdir}/etc/systemd/system.conf.d" + # Make sure all services know about NEWROOT=/sysroot inst "$moddir/configuration/systemd-newroot.conf" \ "/etc/systemd/system.conf.d/systemd-newroot.conf" # Use terminal readline settings from the template system. diff --git a/modules.d/dnbd3-rootfs/services/s3-copy-openslx-config.service b/modules.d/dnbd3-rootfs/services/s3-copy-openslx-config.service deleted file mode 100644 index 41de7fe3..00000000 --- a/modules.d/dnbd3-rootfs/services/s3-copy-openslx-config.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Copy final /opt/openslx/config to /sysroot -Requires=initrd-root-fs.target -After=initrd-root-fs.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-copy-openslx-config.sh diff --git a/modules.d/dnbd3-rootfs/services/s3-dnbd3root.service b/modules.d/dnbd3-rootfs/services/s3-dnbd3root.service deleted file mode 100644 index 3197a9cc..00000000 --- a/modules.d/dnbd3-rootfs/services/s3-dnbd3root.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=root fs on dnbd3 (distributed network block device) -Requires=s3-fetch-config.service -After=s3-fetch-config.service -After=dracut-pre-mount.service -Wants=dracut-mount.service -Before=dracut-mount.service -Before=initrd-root-device.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-dnbd3root.sh diff --git a/modules.d/dnbd3-rootfs/services/s3-mount-root.service b/modules.d/dnbd3-rootfs/services/s3-mount-root.service deleted file mode 100644 index 626e21f4..00000000 --- a/modules.d/dnbd3-rootfs/services/s3-mount-root.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Mount dnbd3/devmapped device to /sysroot -Requires=initrd-root-device.target -After=initrd-root-device.target -Before=initrd-root-fs.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-mount-root.sh diff --git a/modules.d/slx-addons/module-setup.sh b/modules.d/slx-addons/module-setup.sh index ed1ad89e..db186ab7 100755 --- a/modules.d/slx-addons/module-setup.sh +++ b/modules.d/slx-addons/module-setup.sh @@ -11,13 +11,9 @@ install() { inst "${moddir}/services/ldconfig-stage4.service" \ "/opt/openslx/services/ldconfig-stage4.service" # Install service that enables addons - _name="s3-setup-addons" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + # Order after busybox-stage4, as the addon-required check script + # depends on ash being available in stage4 + slx_service "s3-setup-addons" "Enable SLX addons" \ + --after "initrd-root-fs.target" \ + --wafter "s3-install-busybox-stage4.service" } diff --git a/modules.d/slx-addons/services/s3-setup-addons.service b/modules.d/slx-addons/services/s3-setup-addons.service deleted file mode 100644 index 3c5a7fb4..00000000 --- a/modules.d/slx-addons/services/s3-setup-addons.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Enable SLX addons -After=initrd-root-fs.target -Before=initrd-switch-root.target -# Ugly: the addon-required script of vmware needs ash in stage 4 -After=s3-install-busybox-stage4.service -Wants=s3-install-busybox-stage4.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-setup-addons.sh diff --git a/modules.d/slx-clock/module-setup.sh b/modules.d/slx-clock/module-setup.sh index 0977522e..f47086e6 100755 --- a/modules.d/slx-clock/module-setup.sh +++ b/modules.d/slx-clock/module-setup.sh @@ -10,14 +10,12 @@ depends() { install() { inst_multiple "/etc/services" "/usr/share/zoneinfo/Europe/Berlin" inst "/usr/share/zoneinfo/Europe/Berlin" "/etc/localtime" - for _name in "s3-ntp-sync" "s3-configure-timesyncd"; do - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" - done + + slx_service "s3-ntp-sync" "Sync time via NTP" \ + --wafter "s3-fetch-config.service" \ + --requires "s3-setup-bootif-network.service" \ + --after "s3-setup-bootif-network.service" + slx_service "s3-configure-timesync" "Configure timesyncd in stage 4" \ + --wafter "s3-ntp-sync.service" \ + --wafter "initrd-root-fs.target" } diff --git a/modules.d/slx-clock/services/s3-configure-timesyncd.service b/modules.d/slx-clock/services/s3-configure-timesyncd.service deleted file mode 100644 index c370859a..00000000 --- a/modules.d/slx-clock/services/s3-configure-timesyncd.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Configure timesyncd in stage 4 -After=initrd-root-fs.target -After=s3-ntp-sync.service -Before=initrd-switch-root.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-configure-timesyncd.sh diff --git a/modules.d/slx-clock/services/s3-ntp-sync.service b/modules.d/slx-clock/services/s3-ntp-sync.service deleted file mode 100644 index 6cb9eccd..00000000 --- a/modules.d/slx-clock/services/s3-ntp-sync.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Sync time via NTP -Requires=s3-setup-bootif-network.service -After=s3-setup-bootif-network.service -Requires=s3-fetch-config.service -After=s3-fetch-config.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-ntp-sync.sh diff --git a/modules.d/slx-drm/module-setup.sh b/modules.d/slx-drm/module-setup.sh index 13c15b9e..6f4b9ac7 100755 --- a/modules.d/slx-drm/module-setup.sh +++ b/modules.d/slx-drm/module-setup.sh @@ -17,14 +17,12 @@ install() { mkdir -p "${initdir}/${dir%/*}" cp -ar "$dir" "${initdir}/${dir%/*}" done - for _name in "s3-activate-nvidia-drivers" "s3-copy-nvidia-drivers"; do - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" - done + # Prepare /lib/modules and depmod for nvidia if applicable + slx_service "s3-activate-nvidia-drivers" "Enable loading of nVidia drivers if a suitable GPU is found" \ + --wafter "dracut-cmdline.service" \ + --wbefore "dracut-pre-udev.service" + # Copy nVidia drivers to stage 4 if they're loaded + slx_service "s3-copy-nvidia-drivers" "Copy nVidia drivers to stage 4 if in use" \ + --wafter "initrd-root-fs.target" \ + --wafter "s3-activate-nvidia-drivers.service" } diff --git a/modules.d/slx-drm/services/s3-activate-nvidia-drivers.service b/modules.d/slx-drm/services/s3-activate-nvidia-drivers.service deleted file mode 100644 index 4ea86525..00000000 --- a/modules.d/slx-drm/services/s3-activate-nvidia-drivers.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Enable loading of nVidia drivers if a suitable GPU is found -Requires=dracut-cmdline.service -After=dracut-cmdline.service -Before=dracut-pre-udev.service -Wants=dracut-pre-udev.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-activate-nvidia-drivers.sh diff --git a/modules.d/slx-drm/services/s3-copy-nvidia-drivers.service b/modules.d/slx-drm/services/s3-copy-nvidia-drivers.service deleted file mode 100644 index 587a1175..00000000 --- a/modules.d/slx-drm/services/s3-copy-nvidia-drivers.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Copy nVidia drivers to stage 4 if in use -After=dracut-mount.service -After=s3-activate-nvidia-drivers.service -Before=initrd-switch-root.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-copy-nvidia-drivers.sh diff --git a/modules.d/slx-network/module-setup.sh b/modules.d/slx-network/module-setup.sh index 498c7102..d907da51 100755 --- a/modules.d/slx-network/module-setup.sh +++ b/modules.d/slx-network/module-setup.sh @@ -33,36 +33,20 @@ install() { inst "${moddir}/services/udhcpc-bootif-stage4.service" "/opt/openslx/services/udhcpc-bootif.service" # Parse IP config etc. from KCL - _name="s3-parse-network-kcl" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + # After cmdline, we need the extracted MAC + # Before udev, as we generate a udev rule for naming the iface + slx_service "s3-parse-network-kcl" "Extract network config from KCL" \ + --wafter "dracut-cmdline.service" \ + --wbefore "systemd-udevd.service" # Setup bootif network: bridge, vlan, dhcp, ... - _name="s3-setup-bootif-network" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + slx_service "s3-setup-bootif-network" "Configure main network link" \ + --wafter "s3-parse-network-kcl.service" # Copy files related to networking. Must be the very last thing before switchroot to # make sure nothing else tries to meddle with these after copying, e.g. slx-ssl. - _name="s3-copy-network-files" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + slx_service "s3-copy-network-files" "Copy networking-related files to stage 4" \ + --after "s3-ssl-sat.service" \ + --wafter "initrd-root-fs.target" \ + --after "s3-setup-bootif-network.service" # hooks inst_hook pre-pivot 10 "${moddir}/hooks/configure-jumbo-frames.sh" diff --git a/modules.d/slx-network/services/s3-copy-network-files.service b/modules.d/slx-network/services/s3-copy-network-files.service deleted file mode 100644 index 24325cef..00000000 --- a/modules.d/slx-network/services/s3-copy-network-files.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Copy networking-related files to stage 4 -After=s3-ssl-sat.service -After=initrd-root-fs.target -Before=initrd-switch-root.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-copy-network-files.sh diff --git a/modules.d/slx-network/services/s3-parse-network-kcl.service b/modules.d/slx-network/services/s3-parse-network-kcl.service deleted file mode 100644 index 89ffcecf..00000000 --- a/modules.d/slx-network/services/s3-parse-network-kcl.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Extract network config from KCL -DefaultDependencies=no -# Need MAC extracted from cmdline -Wants=dracut-cmdline.service -After=dracut-cmdline.service -# We generate a naming rule for the boot interface -Wants=systemd-udevd.service -Before=systemd-udevd.service -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-parse-network-kcl.sh diff --git a/modules.d/slx-network/services/s3-setup-bootif-network.service b/modules.d/slx-network/services/s3-setup-bootif-network.service deleted file mode 100644 index 4b0ed4b2..00000000 --- a/modules.d/slx-network/services/s3-setup-bootif-network.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Configure main network link -DefaultDependencies=no -IgnoreOnIsolate=true -Wants=s3-parse-network-kcl.service -After=s3-parse-network-kcl.service - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-setup-bootif-network.sh diff --git a/modules.d/slx-runmode/module-setup.sh b/modules.d/slx-runmode/module-setup.sh index 82b56262..d9c991b7 100755 --- a/modules.d/slx-runmode/module-setup.sh +++ b/modules.d/slx-runmode/module-setup.sh @@ -8,13 +8,6 @@ depends() { echo dnbd3-rootfs } install() { - _name="s3-enable-runmode" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + slx_service "s3-enable-runmode" "Set up proper default target" \ + --wafter "s3-fetch-config.service" } diff --git a/modules.d/slx-runmode/services/s3-enable-runmode.service b/modules.d/slx-runmode/services/s3-enable-runmode.service deleted file mode 100644 index 3df162c7..00000000 --- a/modules.d/slx-runmode/services/s3-enable-runmode.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Set up proper default target -After=s3-fetch-config.service -After=initrd-root-fs.target -Before=initrd-switch-root.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-enable-runmode.sh diff --git a/modules.d/slx-splash/hooks/s3-splash-stage4.sh b/modules.d/slx-splash/hooks/s3-splash-stage4.sh new file mode 100755 index 00000000..b88a6a90 --- /dev/null +++ b/modules.d/slx-splash/hooks/s3-splash-stage4.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +grep -qw 'splash' "/proc/cmdline" || return 0 + +# Set option that we want splash + +echo "SLX_SPLASH='yes'" >> "$NEWROOT/opt/openslx/config" + +# The console cursor is disabled when starting the splash screen. +# This will add a drop-in to getty@.service to ensure the cursor +# is restored when starting gettys. + +mkdir -p "$NEWROOT/etc/systemd/system/getty@.service.d/" +cat <<- EOF > "$NEWROOT/etc/systemd/system/getty@.service.d/restore-cursor.conf" + [Service] + ExecStartPre=-/usr/bin/env bash -c "echo -en '\033c' > /dev/%I" +EOF + +# Copy icons and tools, so we can trigger the HDD icon in +# setup-partitions.service + +cp -n "$( which splashtool )" "$NEWROOT/opt/openslx/bin/splashtool" +cp -n -r "/opt/openslx/icons" -t "$NEWROOT/opt/openslx/" + +: diff --git a/modules.d/slx-splash/module-setup.sh b/modules.d/slx-splash/module-setup.sh index 00b51f5a..c5447adc 100755 --- a/modules.d/slx-splash/module-setup.sh +++ b/modules.d/slx-splash/module-setup.sh @@ -26,11 +26,13 @@ install() { slx_service "s3-splash-init" "Initialize bootsplash" \ --wafter "dracut-pre-trigger.service" + # Copy splashtool and icons to stage4, add service drop-in to reset console + slx_service "s3-splash-stage4" "Copy splashtool and icons to stage 4" \ + --wafter "s3-copy-openslx-config.service" \ + --wafter "initrd-root-fs.target" # Change boot splash depending on boot mode = exam inst_hook pre-pivot 00 "${moddir}/scripts/slx-splash-exam.sh" - # Copy splashtool and icons to stage4, add service drop-in to reset console - inst_hook pre-pivot 20 "${moddir}/scripts/slx-splash-stage4.sh" # Done in stage 4 by setup-partitions #inst_hook pre-mount 00 "${moddir}/scripts/slx-splash-icon-hdd.sh" diff --git a/modules.d/slx-splash/scripts/slx-splash-stage4.sh b/modules.d/slx-splash/scripts/slx-splash-stage4.sh deleted file mode 100755 index b88a6a90..00000000 --- a/modules.d/slx-splash/scripts/slx-splash-stage4.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -grep -qw 'splash' "/proc/cmdline" || return 0 - -# Set option that we want splash - -echo "SLX_SPLASH='yes'" >> "$NEWROOT/opt/openslx/config" - -# The console cursor is disabled when starting the splash screen. -# This will add a drop-in to getty@.service to ensure the cursor -# is restored when starting gettys. - -mkdir -p "$NEWROOT/etc/systemd/system/getty@.service.d/" -cat <<- EOF > "$NEWROOT/etc/systemd/system/getty@.service.d/restore-cursor.conf" - [Service] - ExecStartPre=-/usr/bin/env bash -c "echo -en '\033c' > /dev/%I" -EOF - -# Copy icons and tools, so we can trigger the HDD icon in -# setup-partitions.service - -cp -n "$( which splashtool )" "$NEWROOT/opt/openslx/bin/splashtool" -cp -n -r "/opt/openslx/icons" -t "$NEWROOT/opt/openslx/" - -: diff --git a/modules.d/slx-ssl/module-setup.sh b/modules.d/slx-ssl/module-setup.sh index 6e35b16f..618b8f80 100755 --- a/modules.d/slx-ssl/module-setup.sh +++ b/modules.d/slx-ssl/module-setup.sh @@ -9,13 +9,8 @@ depends() { } install() { # config.tgz unpacking happens in pre-pivot/90 - # TODO: BEFORE "copy network files", as we modify /etc/hosts - inst "$moddir/hooks/s3-ssl-sat.sh" \ - /usr/local/bin/s3-ssl-sat.sh - inst_simple "${moddir}/services/s3-ssl-sat.service" \ - "${systemdsystemunitdir}/s3-ssl-sat.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/s3-ssl-sat.service" \ - "${systemdsystemunitdir}/initrd.target.wants/s3-ssl-sat.service" + slx_service "s3-ssl-sat" "Enable SSL communication with Satellite Server" \ + --after "s3-unpack-config-tgz.service" \ + --requires "s3-unpack-config-tgz.service" \ + --before "s3-copy-network-files.service" } diff --git a/modules.d/slx-ssl/services/s3-ssl-sat.service b/modules.d/slx-ssl/services/s3-ssl-sat.service deleted file mode 100644 index 95645334..00000000 --- a/modules.d/slx-ssl/services/s3-ssl-sat.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Enable SSL communication with Satellite Server -After=s3-unpack-config-tgz.service -Requires=s3-unpack-config-tgz.service -Before=initrd-switch-root.target -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-ssl-sat.sh diff --git a/modules.d/slx-uuid/module-setup.sh b/modules.d/slx-uuid/module-setup.sh index 9208c307..c89daae9 100755 --- a/modules.d/slx-uuid/module-setup.sh +++ b/modules.d/slx-uuid/module-setup.sh @@ -24,13 +24,7 @@ install() { inst_multiple dmidecode inst_hook pre-pivot 10 "$moddir/hooks/copy-system-uuid-to-newroot.sh" - _name="s3-get-system-uuid" - inst "$moddir/hooks/${_name}.sh" \ - "/usr/local/bin/${_name}.sh" - inst_simple "${moddir}/services/${_name}.service" \ - "${systemdsystemunitdir}/${_name}.service" - mkdir --parents \ - "${initdir}/${systemdsystemunitdir}/initrd.target.wants" - ln_r "${systemdsystemunitdir}/${_name}.service" \ - "${systemdsystemunitdir}/initrd.target.wants/${_name}.service" + slx_service "s3-get-system-uuid" "Get system UUID" \ + --wafter "s3-parse-network-kcl.service" \ + --wafter "dracut-cmdline.service" } diff --git a/modules.d/slx-uuid/services/s3-get-system-uuid.service b/modules.d/slx-uuid/services/s3-get-system-uuid.service deleted file mode 100644 index b726cd2b..00000000 --- a/modules.d/slx-uuid/services/s3-get-system-uuid.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Get system UUID -Requires=dracut-cmdline.service -After=dracut-cmdline.service -Wants=s3-parse-network-kcl.service -After=s3-parse-network-kcl.service -DefaultDependencies=no -IgnoreOnIsolate=true - -[Service] -Type=oneshot -RemainAfterExit=true -ExecStart=/usr/local/bin/s3-get-system-uuid.sh -- cgit v1.2.3-55-g7522