diff options
| author | Yurii Kolesnykov <yurikoles@gmail.com> | 2018-03-27 16:13:43 +0300 |
|---|---|---|
| committer | Yurii Kolesnykov <yurikoles@gmail.com> | 2018-03-27 16:13:43 +0300 |
| commit | 32bfc2a68a92ce414fe400b7f40b731745ad383f (patch) | |
| tree | 47894b92d984f0197bc59f928c7245db7eb416cf /systemd-hook | |
| parent | 8f1da96a9df35a43ae1417cb72c49c8201a58ea8 (diff) | |
| download | systemd-git-32bfc2a68a92ce414fe400b7f40b731745ad383f.tar.gz systemd-git-32bfc2a68a92ce414fe400b7f40b731745ad383f.tar.bz2 | |
238
Diffstat (limited to 'systemd-hook')
| -rw-r--r-- | systemd-hook | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/systemd-hook b/systemd-hook new file mode 100644 index 0000000..4fdee8e --- /dev/null +++ b/systemd-hook @@ -0,0 +1,38 @@ +#!/bin/sh -e + +systemd_live() { + if [ ! -d /run/systemd/system ]; then + echo >&2 " Skipped: Current root is not booted." + exit 0 + fi +} + +udevd_live() { + if [ ! -d /run/udev ]; then + echo >&2 " Skipped: Device manager is not running." + exit 0 + fi +} + +each_conf() { + while read -r f; do + "$@" "$(basename "$f")" + done +} + +case $1 in + catalog) /usr/bin/journalctl --update-catalog ;; + hwdb) /usr/bin/systemd-hwdb --usr update ;; + update) touch -c /usr ;; + sysusers) each_conf /usr/bin/systemd-sysusers ;; + tmpfiles) each_conf /usr/bin/systemd-tmpfiles --create ;; + + daemon-reload) systemd_live; /usr/bin/systemctl daemon-reload ;; + udev-reload) udevd_live; /usr/bin/udevadm control --reload ;; + binfmt) systemd_live; each_conf /usr/lib/systemd/systemd-binfmt ;; + sysctl) systemd_live; each_conf /usr/lib/systemd/systemd-sysctl ;; + + *) echo >&2 " Invalid operation '$1'"; exit 1 ;; +esac + +exit 0 |
