[arch-projects] [mkinitcpio] [PATCH 3/3] Add mkinitcpio-generate-shutdown-ramfs.service
Dave Reisner
d at falconindy.com
Mon Nov 18 22:19:57 EST 2013
On Mon, Nov 18, 2013 at 08:21:48PM +0100, Thomas Bächler wrote:
> When enabled, this service generates an "initramfs" that systemd
> pivots to on shutdown to ensure clean umounting and shutdown of
> loop and dm devices.
>
> The actual work is done by systemd-shutdown.
> ---
No code comments here, but....
I love how simple this was all to implement with existing mkinitcpio
machinery...
> Makefile | 4 +++-
> install/sd-shutdown | 14 ++++++++++++++
> mkinitcpio-generate-shutdown-ramfs.service | 15 +++++++++++++++
> 3 files changed, 32 insertions(+), 1 deletion(-)
> create mode 100644 install/sd-shutdown
> create mode 100644 mkinitcpio-generate-shutdown-ramfs.service
>
> diff --git a/Makefile b/Makefile
> index 1b933c9..38a7111 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -14,7 +14,8 @@ DIRS = \
> /usr/share/man/man8 \
> /usr/share/man/man5 \
> /usr/share/man/man1 \
> - /usr/share/mkinitcpio
> + /usr/share/mkinitcpio \
> + /usr/lib/systemd/system
>
> all: doc
>
> @@ -48,6 +49,7 @@ install: all
>
> cp -at $(DESTDIR)/usr/lib/initcpio hooks install
> install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/*
> + install -m644 mkinitcpio-generate-shutdown-ramfs.service $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service
>
> install -m755 50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install
>
> diff --git a/install/sd-shutdown b/install/sd-shutdown
> new file mode 100644
> index 0000000..7e86dad
> --- /dev/null
> +++ b/install/sd-shutdown
> @@ -0,0 +1,14 @@
> +#!/bin/bash
> +
> +build() {
> + add_binary /usr/lib/systemd/systemd-shutdown /shutdown
> +}
> +
> +help() {
> + cat <<HELPEOF
> +This hook adds systemd-shutdown to the initramfs. This is only
> +if the image is extracted to /run/initramfs before shutdown.
> +HELPEOF
> +}
> +
> +# vim: set ft=sh ts=4 sw=4 et:
> diff --git a/mkinitcpio-generate-shutdown-ramfs.service b/mkinitcpio-generate-shutdown-ramfs.service
> new file mode 100644
> index 0000000..4a147be
> --- /dev/null
> +++ b/mkinitcpio-generate-shutdown-ramfs.service
> @@ -0,0 +1,15 @@
> +[Unit]
> +Description=Generate shutdown-ramfs
> +DefaultDependencies=no
> +Before=shutdown.target
> +ConditionFileIsExecutable=!/run/initramfs/shutdown
> +
> +[Service]
> +Type=oneshot
> +# /tmp could be umounted at this point
> +# use /run as temporary directory
> +Environment=TMPDIR=/run
> +ExecStart=/usr/bin/mkinitcpio -A sd-shutdown -c /dev/null -T /run/initramfs
> +
> +[Install]
> +WantedBy=shutdown.target
> --
> 1.8.4.2
>
More information about the arch-projects
mailing list