PKGBUILDs/core/systemd/systemd-hook

47 lines
1.1 KiB
Plaintext
Raw Normal View History

2018-03-08 01:30:53 +00:00
#!/bin/sh -e
2021-05-19 14:06:57 +00:00
is_chrooted() {
if systemd-detect-virt --chroot; then
echo >&2 " Skipped: Running in chroot."
exit 0
fi
}
2018-03-08 01:30:53 +00:00
systemd_live() {
2021-05-19 14:06:57 +00:00
is_chrooted
2018-03-08 01:30:53 +00:00
if [ ! -d /run/systemd/system ]; then
echo >&2 " Skipped: Current root is not booted."
exit 0
fi
}
udevd_live() {
2021-05-19 14:06:57 +00:00
is_chrooted
2018-03-08 01:30:53 +00:00
if [ ! -d /run/udev ]; then
echo >&2 " Skipped: Device manager is not running."
exit 0
fi
}
2019-08-17 14:29:45 +00:00
op="$1"; shift
case "$op" in
2018-03-08 01:30:53 +00:00
catalog) /usr/bin/journalctl --update-catalog ;;
hwdb) /usr/bin/systemd-hwdb --usr update ;;
update) touch -c /usr ;;
2018-06-14 13:09:05 +00:00
sysusers) /usr/bin/systemd-sysusers ;;
tmpfiles) /usr/bin/systemd-tmpfiles --create ;;
2018-03-08 01:30:53 +00:00
daemon-reload) systemd_live; /usr/bin/systemctl daemon-reload ;;
udev-reload) udevd_live; /usr/bin/udevadm control --reload ;;
2018-06-14 13:09:05 +00:00
binfmt) systemd_live; /usr/lib/systemd/systemd-binfmt ;;
sysctl) systemd_live; /usr/lib/systemd/systemd-sysctl ;;
2018-03-08 01:30:53 +00:00
2019-08-17 14:29:45 +00:00
# For use by other packages
reload) systemd_live; /usr/bin/systemctl try-reload-or-restart "$@" ;;
*) echo >&2 " Invalid operation '$op'"; exit 1 ;;
2018-03-08 01:30:53 +00:00
esac
exit 0