PKGBUILDs/core/systemd/systemd-hook

79 lines
1.3 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
2023-09-28 02:30:42 +00:00
if [ ! -S /run/udev/control ]; then
2018-03-08 01:30:53 +00:00
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
2023-09-28 02:30:42 +00:00
if [ ! -e /etc/systemd/do-not-udevadm-trigger-on-update ]; then
/usr/bin/udevadm trigger -c change
/usr/bin/udevadm settle
fi
2023-04-11 17:38:16 +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
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