From cb42a762e69037502d0549d3a79a41e292af8aad Mon Sep 17 00:00:00 2001 From: Will Woods Date: Thu, 8 Mar 2012 15:13:03 -0500 Subject: add fedora-import-state.service This service imports the contents of /run/initramfs/state into the root filesystem, where the root filesystem is writeable. This allows dracut to hand the ifcfg file and dhclient lease over to NetworkManager on network-booted Live images. --- Makefile | 1 + systemd/fedora-import-state | 14 ++++++++++++++ systemd/system/fedora-import-state.service | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100755 systemd/fedora-import-state create mode 100644 systemd/system/fedora-import-state.service diff --git a/Makefile b/Makefile index 00e81b0c..3d1ae951 100644 --- a/Makefile +++ b/Makefile @@ -127,6 +127,7 @@ install: ln -s ../fedora-autorelabel.service $(ROOT)/lib/systemd/system/basic.target.wants ln -s ../fedora-autorelabel-mark.service $(ROOT)/lib/systemd/system/basic.target.wants ln -s ../fedora-readonly.service $(ROOT)/lib/systemd/system/local-fs.target.wants + ln -s ../fedora-import-state.service $(ROOT)/lib/systemd/system/local-fs.target.wants ln -s ../fedora-storage-init.service $(ROOT)/lib/systemd/system/local-fs.target.wants ln -s ../fedora-storage-init-late.service $(ROOT)/lib/systemd/system/local-fs.target.wants diff --git a/systemd/fedora-import-state b/systemd/fedora-import-state new file mode 100755 index 00000000..a853ab9c --- /dev/null +++ b/systemd/fedora-import-state @@ -0,0 +1,14 @@ +#!/bin/bash +# fedora-import-state: import state files from initramfs (e.g. network config) + +# exit early if root isn't writeable +[ -w / ] || exit 0 + +# copy state into root +cd /run/initramfs/state +cp -a -t / . + +# run restorecon on the copied files +if [ -e /sys/fs/selinux/enforce ]; then + find . | ( cd /; restorecon -i -f -; ) || : +fi diff --git a/systemd/system/fedora-import-state.service b/systemd/system/fedora-import-state.service new file mode 100644 index 00000000..5294fe17 --- /dev/null +++ b/systemd/system/fedora-import-state.service @@ -0,0 +1,13 @@ +[Unit] +Description=Import network configuration from initramfs +DefaultDependencies=no +ConditionDirectoryNotEmpty=/run/initramfs/state +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target systemd-tmpfiles-setup.service +After=remount-rootfs.service + +[Service] +ExecStart=/lib/systemd/fedora-import-state +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes -- cgit v1.2.1