PKGBUILDs/core/systemd/systemd-hook

77 lines
1.2 KiB
Text
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
2023-04-11 17:38:16 +00:00
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
;;
2018-03-08 01:30:53 +00:00
2023-04-11 17:38:16 +00:00
daemon-reload)
systemd_live
/usr/bin/systemctl daemon-reload
;;
udev-reload)
udevd_live
/usr/bin/udevadm control --reload
/usr/bin/udevadm trigger
/usr/bin/udevadm settle
;;
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
2023-04-11 17:38:16 +00:00
reload)
systemd_live
/usr/bin/systemctl try-reload-or-restart "$@"
;;
2019-08-17 14:29:45 +00:00
2023-04-11 17:38:16 +00:00
*)
echo >&2 " Invalid operation '$op'"
exit 1
;;
2018-03-08 01:30:53 +00:00
esac
exit 0