]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dmsquash-live: install a sysroot.mount generator for systemd
authorHarald Hoyer <harald@redhat.com>
Wed, 10 Jun 2015 17:28:31 +0000 (19:28 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 11 Jun 2015 15:39:31 +0000 (17:39 +0200)
otherwise systemd uses its own sysroot.mount line

modules.d/90dmsquash-live/dmsquash-live-root.sh
modules.d/90dmsquash-live/module-setup.sh
modules.d/90dmsquash-live/parse-dmsquash-live.sh
modules.d/98dracut-systemd/rootfs-generator.sh

index b632f6a41e1ee82fc98ccd405d4ce4845821218a..a0a9ab98b3eb180f3c535d0ab49ac445e093dcf8 100755 (executable)
@@ -268,7 +268,10 @@ if [ -n "$ROOTFLAGS" ]; then
 fi
 
 ln -s /dev/mapper/live-rw /dev/root
-printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
+
+if [ -z "$DRACUT_SYSTEMD" ]; then
+    printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
+fi
 
 need_shutdown
 
index a113c3ff7568a2aa726f6155784477c614fb3c85..19396a736bb5093f8c1e3563e41850e535289db5 100755 (executable)
@@ -31,6 +31,7 @@ install() {
     inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
     inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
     inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
+    inst_script "$moddir/dmsquash-generator.sh" $systemdutildir/system-generators/dracut-dmsquash-generator
     # should probably just be generally included
     inst_rules 60-cdrom_id.rules
     inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
index bcd42984ada281d3aea3ce418ed8f46cd559fef4..0386d3427a144a3520d051070d4dd6bd80ae24ef 100755 (executable)
@@ -13,7 +13,7 @@ if [ "${root%%:*}" = "live" ] ; then
     liveroot=$root
 fi
 
-[ "${liveroot%%:*}" = "live" ] || return
+[ "${liveroot%%:*}" = "live" ] || return 1
 
 modprobe -q loop
 
@@ -49,9 +49,14 @@ case "$liveroot" in
     live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
         [ -f "${root#live:}" ] && rootok=1 ;;
 esac
+
+[ "$rootok" = "1" ] || return 1
+
 info "root was $liveroot, is now $root"
 
 # make sure that init doesn't complain
 [ -z "$root" ] && root="live"
 
 wait_for_dev -n /dev/mapper/live-rw
+
+return 0
index 2589919d604152e36b926072294f234fa19d6fa6..5910ce75f56ef923aa58326652504ef74a8e1652 100755 (executable)
@@ -22,17 +22,17 @@ generator_wait_for_dev()
     fi
 
     _name=$(dev_unit_name "$1")
-    if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
-        [ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
-        ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
+    if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then
+        [ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
+        ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device
     fi
 
-    if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
-        mkdir -p /run/systemd/generator/${_name}.device.d
+    if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
+        mkdir -p "$GENERATOR_DIR"/${_name}.device.d
         {
             echo "[Unit]"
             echo "JobTimeoutSec=$_timeout"
-        } > /run/systemd/generator/${_name}.device.d/timeout.conf
+        } > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
     fi
 }
 
@@ -45,8 +45,8 @@ generator_mount_rootfs()
     [ -z "$1" ] && return 0
 
     _name=$(dev_unit_name "$1")
-    [ -d /run/systemd/generator ] || mkdir -p /run/systemd/generator
-    if ! [ -f /run/systemd/generator/sysroot.mount ]; then
+    [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
+    if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
         {
             echo "[Unit]"
             echo "Before=initrd-root-fs.target"
@@ -57,11 +57,11 @@ generator_mount_rootfs()
             echo "What=$1"
             echo "Options=${_flags}"
             echo "Type=${_type}"
-        } > /run/systemd/generator/sysroot.mount
+        } > "$GENERATOR_DIR"/sysroot.mount
     fi
-    if ! [ -L /run/systemd/generator/initrd-root-fs.target.requires/sysroot.mount ]; then
-        [ -d /run/systemd/generator/initrd-root-fs.target.requires ] || mkdir -p /run/systemd/generator/initrd-root-fs.target.requires
-        ln -s ../sysroot.mount /run/systemd/generator/initrd-root-fs.target.requires/sysroot.mount
+    if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
+        [ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
+        ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
     fi
 }
 
@@ -91,6 +91,8 @@ case "$root" in
         rootok=1 ;;
 esac
 
+GENERATOR_DIR="$1"
+
 if [ "${root%%:*}" = "block" ]; then
    generator_wait_for_dev "${root#block:}" "$RDRETRY"
    strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"