Harald Hoyer 932373
From 56903458d7e67f805a7e484cd025a059a5621d73 Mon Sep 17 00:00:00 2001
Harald Hoyer 932373
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 932373
Date: Wed, 16 Oct 2013 11:47:01 +0200
Harald Hoyer 932373
Subject: [PATCH] mkdir basic dirs in /run
Harald Hoyer 932373
Harald Hoyer 932373
for systemd initramfs, /run is also mounted
Harald Hoyer 932373
for non-systemd the contents of /run is copied over, when mounting /run
Harald Hoyer 932373
---
Harald Hoyer 932373
 modules.d/98systemd/dracut-cmdline.sh |  5 -----
Harald Hoyer 932373
 modules.d/99base/dracut-lib.sh        |  7 +++++++
Harald Hoyer 932373
 modules.d/99base/init.sh              | 10 +++-------
Harald Hoyer 932373
 3 files changed, 10 insertions(+), 12 deletions(-)
Harald Hoyer 932373
Harald Hoyer 932373
diff --git a/modules.d/98systemd/dracut-cmdline.sh b/modules.d/98systemd/dracut-cmdline.sh
Harald Hoyer 932373
index 50b8d6c..aa8a02b 100755
Harald Hoyer 932373
--- a/modules.d/98systemd/dracut-cmdline.sh
Harald Hoyer 932373
+++ b/modules.d/98systemd/dracut-cmdline.sh
Harald Hoyer 932373
@@ -2,11 +2,6 @@
Harald Hoyer 932373
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer 932373
 # ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer 932373
 
Harald Hoyer 932373
-[ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT
Harald Hoyer 932373
-[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
Harald Hoyer 932373
-[ -d /run/lock ] || mkdir -p -m 0755 /run/lock
Harald Hoyer 932373
-[ -d /run/log ] || mkdir -p -m 0755 /run/log
Harald Hoyer 932373
-
Harald Hoyer 932373
 if [ -f /dracut-state.sh ]; then
Harald Hoyer 932373
     . /dracut-state.sh 2>/dev/null
Harald Hoyer 932373
 fi
Harald Hoyer 932373
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 932373
index 74d7d35..0670cf2 100755
Harald Hoyer 932373
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 932373
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 932373
@@ -4,6 +4,13 @@
Harald Hoyer 932373
 
Harald Hoyer 932373
 export DRACUT_SYSTEMD
Harald Hoyer 932373
 export NEWROOT
Harald Hoyer 932373
+if [ -n "$NEWROOT" ]; then
Harald Hoyer 932373
+    [ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT
Harald Hoyer 932373
+fi
Harald Hoyer 932373
+
Harald Hoyer 932373
+[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
Harald Hoyer 932373
+[ -d /run/lock ] || mkdir -p -m 0755 /run/lock
Harald Hoyer 932373
+[ -d /run/log ] || mkdir -p -m 0755 /run/log
Harald Hoyer 932373
 
Harald Hoyer 932373
 debug_off() {
Harald Hoyer 932373
     set +x
Harald Hoyer 932373
diff --git a/modules.d/99base/init.sh b/modules.d/99base/init.sh
Harald Hoyer 932373
index 3ba440a..2364f4f 100755
Harald Hoyer 932373
--- a/modules.d/99base/init.sh
Harald Hoyer 932373
+++ b/modules.d/99base/init.sh
Harald Hoyer 932373
@@ -56,17 +56,17 @@ fi
Harald Hoyer 932373
 
Harald Hoyer 932373
 if ! ismounted /dev/pts; then
Harald Hoyer 932373
     mkdir -m 0755 /dev/pts
Harald Hoyer 932373
-    mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null 
Harald Hoyer 932373
+    mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null
Harald Hoyer 932373
 fi
Harald Hoyer 932373
 
Harald Hoyer 932373
 if ! ismounted /dev/shm; then
Harald Hoyer 932373
     mkdir -m 0755 /dev/shm
Harald Hoyer 932373
-    mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null 
Harald Hoyer 932373
+    mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null
Harald Hoyer 932373
 fi
Harald Hoyer 932373
 
Harald Hoyer 932373
 if ! ismounted /run; then
Harald Hoyer 932373
     mkdir -m 0755 /newrun
Harald Hoyer 932373
-    mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null 
Harald Hoyer 932373
+    mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
Harald Hoyer 932373
     cp -a /run/* /newrun >/dev/null 2>&1
Harald Hoyer 932373
     mount --move /newrun /run
Harald Hoyer 932373
     rm -fr -- /newrun
Harald Hoyer 932373
@@ -88,10 +88,6 @@ fi
Harald Hoyer 932373
 
Harald Hoyer 932373
 trap "action_on_fail Signal caught!" 0
Harald Hoyer 932373
 
Harald Hoyer 932373
-[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
Harald Hoyer 932373
-[ -d /run/log ] || mkdir -p -m 0755 /run/log
Harald Hoyer 932373
-[ -d /run/lock ] || mkdir -p -m 0755 /run/lock
Harald Hoyer 932373
-
Harald Hoyer 932373
 export UDEVVERSION=$(udevadm --version)
Harald Hoyer 932373
 if [ $UDEVVERSION -gt 166 ]; then
Harald Hoyer 932373
     # newer versions of udev use /run/udev/rules.d