From bef2fd9722c6f2fd972515c41963639e3bae0bc7 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 10 Jul 2012 16:20:23 +0200 Subject: [PATCH] systemd: install all dracut units in /etc and let the generator cp to /run All custom units, which should appear in the system later on should be installed in /etc/systemd. They should have a guard like: ConditionPathExists=/etc/initrd-release So, we can later query via systemctl: $ systemctl status dracut-initqueue.service dracut-initqueue.service - Dracut initqueue hook Loaded: loaded (/run/systemd/system/dracut-initqueue.service; enabled-runtime) Active: inactive (dead) since Tue, 10 Jul 2012 16:01:22 +0200; 1min 37s ago start condition failed at Tue, 10 Jul 2012 16:01:23 +0200; 1min 36s ago Main PID: 173 (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/dracut-initqueue.service Jul 10 16:01:22 lenovo dracut-initqueue[173]: Checking, if btrfs device complete Jul 10 16:01:22 lenovo dracut-initqueue[173]: Remounting /dev/disk/by-uuid/ade13292-d23f-45be-b732-fa9a391a56b0 with -o compress=lzo,ssd,rw Jul 10 16:01:22 lenovo dracut-initqueue[173]: Mounted root filesystem /dev/sda3 --- modules.d/98systemd/module-setup.sh | 41 ++++++++++++++++----------------- modules.d/98systemd/service-to-run.sh | 6 ++--- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh index f9bb799..5cb236c 100755 --- a/modules.d/98systemd/module-setup.sh +++ b/modules.d/98systemd/module-setup.sh @@ -112,42 +112,41 @@ install() { ln -fs $systemdutildir/systemd "$initdir/init" - rm -f "${initdir}${systemdsystemunitdir}/emergency.service" inst_simple "$moddir/emergency.service" ${systemdsystemunitdir}/emergency.service - - rm -f "${initdir}${systemdsystemunitdir}/rescue.service" inst_simple "$moddir/rescue.service" ${systemdsystemunitdir}/rescue.service + ln -fs "basic.target" "${initdir}${systemdsystemunitdir}/default.target" + + dracutsystemunitdir="/etc/systemd/system" - inst_simple "$moddir/initrd-switch-root.target" ${systemdsystemunitdir}/initrd-switch-root.target - inst_simple "$moddir/initrd-switch-root.service" ${systemdsystemunitdir}/initrd-switch-root.service - ln -fs basic.target "${initdir}${systemdsystemunitdir}/default.target" + mkdir -p "${initdir}${dracutsystemunitdir}/basic.target.wants" - mkdir -p "${initdir}${systemdsystemunitdir}/basic.target.wants" + inst_simple "$moddir/initrd-switch-root.target" ${dracutsystemunitdir}/initrd-switch-root.target + inst_simple "$moddir/initrd-switch-root.service" ${dracutsystemunitdir}/initrd-switch-root.service inst_script "$moddir/dracut-cmdline.sh" /bin/dracut-cmdline - inst_simple "$moddir/dracut-cmdline.service" ${systemdsystemunitdir}/dracut-cmdline.service - ln -fs ../dracut-cmdline.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-cmdline.service" + inst_simple "$moddir/dracut-cmdline.service" ${dracutsystemunitdir}/dracut-cmdline.service + ln -fs ../dracut-cmdline.service "${initdir}${dracutsystemunitdir}/basic.target.wants/dracut-cmdline.service" inst_script "$moddir/dracut-pre-udev.sh" /bin/dracut-pre-udev - inst_simple "$moddir/dracut-pre-udev.service" ${systemdsystemunitdir}/dracut-pre-udev.service - ln -fs ../dracut-pre-udev.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-udev.service" + inst_simple "$moddir/dracut-pre-udev.service" ${dracutsystemunitdir}/dracut-pre-udev.service + ln -fs ../dracut-pre-udev.service "${initdir}${dracutsystemunitdir}/basic.target.wants/dracut-pre-udev.service" inst_script "$moddir/dracut-pre-trigger.sh" /bin/dracut-pre-trigger - inst_simple "$moddir/dracut-pre-trigger.service" ${systemdsystemunitdir}/dracut-pre-trigger.service - ln -fs ../dracut-pre-trigger.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-trigger.service" + inst_simple "$moddir/dracut-pre-trigger.service" ${dracutsystemunitdir}/dracut-pre-trigger.service + ln -fs ../dracut-pre-trigger.service "${initdir}${dracutsystemunitdir}/basic.target.wants/dracut-pre-trigger.service" inst_script "$moddir/dracut-initqueue.sh" /bin/dracut-initqueue - inst_simple "$moddir/dracut-initqueue.service" ${systemdsystemunitdir}/dracut-initqueue.service - ln -fs ../dracut-initqueue.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-initqueue.service" + inst_simple "$moddir/dracut-initqueue.service" ${dracutsystemunitdir}/dracut-initqueue.service + ln -fs ../dracut-initqueue.service "${initdir}${dracutsystemunitdir}/basic.target.wants/dracut-initqueue.service" inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot - inst_simple "$moddir/dracut-pre-pivot.service" ${systemdsystemunitdir}/dracut-pre-pivot.service - ln -fs ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-pivot.service" + inst_simple "$moddir/dracut-pre-pivot.service" ${dracutsystemunitdir}/dracut-pre-pivot.service + ln -fs ../dracut-pre-pivot.service "${initdir}${dracutsystemunitdir}/basic.target.wants/dracut-pre-pivot.service" - inst_simple "$moddir/udevadm-cleanup-db.service" ${systemdsystemunitdir}/udevadm-cleanup-db.service - mkdir -p "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.requires" - ln -fs ../udevadm-cleanup-db.service "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.requires/udevadm-cleanup-db.service" + inst_simple "$moddir/udevadm-cleanup-db.service" ${dracutsystemunitdir}/udevadm-cleanup-db.service + mkdir -p "${initdir}${dracutsystemunitdir}/initrd-switch-root.target.requires" + ln -fs ../udevadm-cleanup-db.service "${initdir}${dracutsystemunitdir}/initrd-switch-root.target.requires/udevadm-cleanup-db.service" - inst_script "$moddir/service-to-run.sh" $systemdutildir/system-generators/service-to-run + inst_script "$moddir/service-to-run.sh" "${systemdutildir}/system-generators/service-to-run" } diff --git a/modules.d/98systemd/service-to-run.sh b/modules.d/98systemd/service-to-run.sh index 3e46ba4..797958e 100755 --- a/modules.d/98systemd/service-to-run.sh +++ b/modules.d/98systemd/service-to-run.sh @@ -1,6 +1,4 @@ #!/bin/sh - -cp -a /lib/systemd/system/dracut*.service /run/systemd/system/ -cp -a /lib/systemd/system/initrd-* /run/systemd/system/ -cp -a /lib/systemd/system/udevadm*.service /run/systemd/system/ +mkdir -p /run/systemd/system/ +cp -a -t /run/systemd/system/ /etc/systemd/system/*