diff options
Diffstat (limited to 'systemd-hook')
-rw-r--r-- | systemd-hook | 70 |
1 files changed, 57 insertions, 13 deletions
diff --git a/systemd-hook b/systemd-hook index 6f2e899234cf..d64341fd3ca6 100644 --- a/systemd-hook +++ b/systemd-hook @@ -1,6 +1,14 @@ #!/bin/sh -e +is_chrooted() { + if systemd-detect-virt --chroot; then + echo >&2 " Skipped: Running in chroot." + exit 0 + fi +} + systemd_live() { + is_chrooted if [ ! -d /run/systemd/system ]; then echo >&2 " Skipped: Current root is not booted." exit 0 @@ -8,7 +16,8 @@ systemd_live() { } udevd_live() { - if [ ! -d /run/udev ]; then + is_chrooted + if [ ! -S /run/udev/control ]; then echo >&2 " Skipped: Device manager is not running." exit 0 fi @@ -17,21 +26,56 @@ udevd_live() { op="$1"; shift case "$op" in - catalog) /usr/bin/journalctl --update-catalog ;; - hwdb) /usr/bin/systemd-hwdb --usr update ;; - update) touch -c /usr ;; - sysusers) /usr/bin/systemd-sysusers ;; - tmpfiles) /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; /usr/lib/systemd/systemd-binfmt ;; - sysctl) systemd_live; /usr/lib/systemd/systemd-sysctl ;; + binfmt) + systemd_live + /usr/lib/systemd/systemd-binfmt + ;; + catalog) + /usr/bin/journalctl --update-catalog + ;; + daemon-reload-system) + systemd_live + /usr/bin/systemctl --system daemon-reload + ;; + daemon-reload-user) + systemd_live + /usr/bin/systemctl kill --kill-whom='main' --signal='SIGHUP' 'user@*.service' + ;; + hwdb) + /usr/bin/systemd-hwdb --usr update + ;; + sysctl) + systemd_live + /usr/lib/systemd/systemd-sysctl + ;; + sysusers) + /usr/bin/systemd-sysusers + ;; + tmpfiles) + /usr/bin/systemd-tmpfiles --create + ;; + update) + touch -c /usr + ;; + udev-reload) + udevd_live + /usr/bin/udevadm control --reload + if [ ! -e /etc/systemd/do-not-udevadm-trigger-on-update ]; then + /usr/bin/udevadm trigger -c change + /usr/bin/udevadm settle + fi + ;; # For use by other packages - reload) systemd_live; /usr/bin/systemctl try-reload-or-restart "$@" ;; + reload) + systemd_live + /usr/bin/systemctl try-reload-or-restart "$@" + ;; - *) echo >&2 " Invalid operation '$op'"; exit 1 ;; + *) + echo >&2 " Invalid operation '$op'" + exit 1 + ;; esac exit 0 |