]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
systemd service cleanup
authorHarald Hoyer <harald@redhat.com>
Mon, 9 Jul 2012 18:46:20 +0000 (20:46 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 10 Jul 2012 10:22:51 +0000 (12:22 +0200)
13 files changed:
modules.d/95rootfs-block/block-genrules.sh
modules.d/98systemd/dracut-cmdline.service
modules.d/98systemd/dracut-initqueue.service
modules.d/98systemd/dracut-initqueue.sh
modules.d/98systemd/dracut-pre-pivot.service
modules.d/98systemd/dracut-pre-pivot.sh
modules.d/98systemd/dracut-pre-trigger.service
modules.d/98systemd/dracut-pre-udev.service
modules.d/98systemd/initrd-switch-root.service
modules.d/98systemd/initrd-switch-root.target
modules.d/98systemd/module-setup.sh
modules.d/98systemd/service-to-run.sh [new file with mode: 0755]
modules.d/98systemd/udevadm-cleanup-db.service [new file with mode: 0644]

index fe6e331ac0055988f0c2ff4bb36e0ad2133558e4..7f894ee28fa65f367148d37a25d23efa7dcd36df 100755 (executable)
@@ -13,22 +13,22 @@ if [ "${root%%:*}" = "block" ]; then
     printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
         "${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
 
-    if [ -d /lib/systemd/system/ ]; then
-        echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
-        {
-           echo '[Unit]'
-           echo 'Description=New Root File System'
-           echo 'DefaultDependencies=no'
-           echo 'Before=switch-root.service'
-           echo '[Mount]'
-           echo "What=${root#block:}"
-           echo "Where=$NEWROOT"
+    if [ -d /lib/systemd/system/ ]; then
+        echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
+        {
+           echo '[Unit]'
+           echo 'Description=New Root File System'
+           echo 'DefaultDependencies=no'
+    #        echo 'Before=initrd-switch-root.service'
+           echo '[Mount]'
+           echo "What=${root#block:}"
+           echo "Where=$NEWROOT"
 
-       } >/lib/systemd/system/${NEWROOT#/}.mount
+       } >/lib/systemd/system/${NEWROOT#/}.mount
 
-       mkdir -p /lib/systemd/system/switch-root.target.wants
-       ln -s ../${NEWROOT#/}.mount /lib/systemd/system/switch-root.target.wants/${NEWROOT#/}.mount
-    fi
+    #    mkdir -p /lib/systemd/system/initrd-switch-root.target.requires
+    #    ln -s ../${NEWROOT#/}.mount /lib/systemd/system/initrd-switch-root.target.requires/${NEWROOT#/}.mount
+    fi
 
     wait_for_dev "${root#block:}"
 fi
index 13671e4abc069cf410138959696a019d19bb6e04..1ed50a91faccaa08a41ec19829e9c05342ca6943 100644 (file)
@@ -16,10 +16,8 @@ Wants=systemd-journald.socket
 ConditionPathExists=/etc/initrd-release
 
 [Service]
-Environment=HOME=/
-WorkingDirectory=/
-ExecStart=-/bin/dracut-cmdline
 Type=oneshot
+ExecStart=-/bin/dracut-cmdline
 StandardInput=null
 StandardOutput=syslog
 StandardError=syslog+console
index 5168677a6bbec5078eea240de1d4c18a6689a16d..e611e93e058582d0268c72859dc31d4aaa8d886c 100644 (file)
@@ -15,10 +15,8 @@ Wants=systemd-udev-trigger.service
 ConditionPathExists=/etc/initrd-release
 
 [Service]
-Environment=HOME=/
-WorkingDirectory=/
+Type=oneshot
 ExecStart=-/bin/dracut-initqueue
-Type=simple
 StandardInput=null
 StandardOutput=syslog
 StandardError=syslog+console
index bc6358239c5a1b0663220671f47df5b2c56db77d..cfdb12d050ac14e4d4adce58345d2c78002f1ce9 100755 (executable)
@@ -106,5 +106,4 @@ done
 
 export -p > /dracut-state.sh
 
-systemctl isolate initrd-switch-root.target
 exit 0
index 27cb7de072ee6379293f7cb633d6b96fa05b87c5..61257cf0c16b75e750e01dcad1cea1230888c7ae 100644 (file)
 [Unit]
 Description=Dracut pre-pivot and cleanup hook
 DefaultDependencies=no
-Before=initrd-switch-root.service
+After=dracut-initqueue.service
 ConditionPathExists=/etc/initrd-release
 
 [Service]
-Environment=HOME=/
-WorkingDirectory=/
-ExecStart=-/bin/dracut-pre-pivot
 Type=oneshot
+ExecStart=-/bin/dracut-pre-pivot
+ExecStopPost=-/usr/bin/systemctl isolate initrd-switch-root.target
 StandardInput=null
 StandardOutput=syslog
 StandardError=syslog+console
index 06642d0959d029dc7878f1bc374868908de3cb7c..31dded50581640615dbbd89138d9a92fdbaad39d 100755 (executable)
@@ -34,20 +34,9 @@ done
 
 echo "NEWROOT=\"$NEWROOT\"" >> /run/initramfs/switch-root.conf
 
-udevadm control --stop-exec-queue
-
-for i in systemd-udevd.service; do
-    systemctl is-active $i >/dev/null 2>&1 && systemctl stop $i
-done
-
-udevadm info --cleanup-db
-
 # remove helper symlink
 [ -h /dev/root ] && rm -f /dev/root
 
 getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
 
-cp -avr /lib/systemd/system/dracut*.service /run/systemd/system/
-
-export -p > /dracut-state.sh
 exit 0
index 86c7c5e36a404465b5d33c44e3a38c5d7ad4baf1..b2dcf68152362f2c2b80e8b8d0c7c646f3f2a055 100644 (file)
@@ -16,10 +16,8 @@ Wants=dracut-pre-udev.service systemd-udevd.service
 ConditionPathExists=/etc/initrd-release
 
 [Service]
-Environment=HOME=/
-WorkingDirectory=/
-ExecStart=-/bin/dracut-pre-trigger
 Type=oneshot
+ExecStart=-/bin/dracut-pre-trigger
 StandardInput=null
 StandardOutput=syslog
 StandardError=syslog+console
index a320498b80402ad45a7a6ef04385a7eb6047ce01..cc14f88dfdb1d3751d691c6347e334f185ec4f19 100644 (file)
@@ -16,10 +16,8 @@ Wants=dracut-cmdline.service
 ConditionPathExists=/etc/initrd-release
 
 [Service]
-Environment=HOME=/
-WorkingDirectory=/
-ExecStart=-/bin/dracut-pre-udev
 Type=oneshot
+ExecStart=-/bin/dracut-pre-udev
 StandardInput=null
 StandardOutput=syslog
 StandardError=syslog+console
index b00292f310a58e90370281540301cb25b96d2433..84fc11ed32f834c1846f634a391af5742b85f2af 100644 (file)
@@ -9,9 +9,13 @@
 Description=Switch Root
 DefaultDependencies=no
 ConditionPathExists=/etc/initrd-release
+OnFailure=emergency.service
 
 [Service]
 Type=oneshot
 EnvironmentFile=/run/initramfs/switch-root.conf
 ExecStart=/usr/bin/systemctl --force switch-root ${NEWROOT} ${NEWINIT}
-ExecStopPost=-/usr/bin/systemctl isolate default.target
+ExecStopPost=-/usr/bin/systemctl restart systemd-journald.service
+StandardInput=null
+StandardOutput=null
+StandardError=null
index 5f397119944f20f23686e0e5f5d7468297531547..feb716260a34260870b32109e776aa51abe8fe82 100644 (file)
@@ -13,4 +13,4 @@ DefaultDependencies=no
 Requires=initrd-switch-root.service
 Before=initrd-switch-root.service
 AllowIsolate=yes
-
+Wants=systemd-journald.service
index 0387ec4299c28a22c669389c5c162348f21c94a2..f9bb7996fbdc3b90e0ac0a3743503c4fd63379f3 100755 (executable)
@@ -63,7 +63,7 @@ install() {
         $systemdsystemunitdir/systemd-ask-password-console.service \
         $systemdsystemunitdir/halt.service \
         $systemdsystemunitdir/poweroff.service \
-        $systemdsystemunitdir/reboot.service \
+        $systemdsystemunitdir/systemd-reboot.service \
         $systemdsystemunitdir/kexec.service \
         $systemdsystemunitdir/fsck@.service \
         $systemdsystemunitdir/systemd-udevd.service \
@@ -142,8 +142,12 @@ install() {
 
     inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot
     inst_simple "$moddir/dracut-pre-pivot.service" ${systemdsystemunitdir}/dracut-pre-pivot.service
-    mkdir -p "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants"
-    ln -fs ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants/dracut-pre-pivot.service"
+    ln -fs ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/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_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
new file mode 100755 (executable)
index 0000000..3e46ba4
--- /dev/null
@@ -0,0 +1,6 @@
+#!/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/
+
diff --git a/modules.d/98systemd/udevadm-cleanup-db.service b/modules.d/98systemd/udevadm-cleanup-db.service
new file mode 100644 (file)
index 0000000..368a0dd
--- /dev/null
@@ -0,0 +1,20 @@
+#  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=Cleanup udevd DB
+DefaultDependencies=no
+ConditionPathExists=/etc/initrd-release
+Conflicts=systemd-udevd.service systemd-udevd-control.socket systemd-udevd-kernel.socket
+Before=initrd-switch-root.service
+
+[Service]
+Type=oneshot
+ExecStart=-/usr/bin/udevadm info --cleanup-db
+StandardInput=null
+StandardOutput=null
+StandardError=null