summarylogtreecommitdiffstats
path: root/systemd-hook
diff options
context:
space:
mode:
authorRanieri Althoff2019-11-06 16:42:05 -0300
committerRanieri Althoff2019-11-06 21:01:11 -0300
commit72313ffd52f59617a9285dc403e4b8e40e5e952a (patch)
treecb87763f6d888603bc8381967cc9fb6aec7f9eb9 /systemd-hook
downloadaur-72313ffd52f59617a9285dc403e4b8e40e5e952a.tar.gz
Initial commit
Diffstat (limited to 'systemd-hook')
-rw-r--r--systemd-hook37
1 files changed, 37 insertions, 0 deletions
diff --git a/systemd-hook b/systemd-hook
new file mode 100644
index 000000000000..6f2e899234cf
--- /dev/null
+++ b/systemd-hook
@@ -0,0 +1,37 @@
+#!/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
+}
+
+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 ;;
+
+ # For use by other packages
+ reload) systemd_live; /usr/bin/systemctl try-reload-or-restart "$@" ;;
+
+ *) echo >&2 " Invalid operation '$op'"; exit 1 ;;
+esac
+
+exit 0