systemd-hook 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh -e
  2. is_chrooted() {
  3. if systemd-detect-virt --chroot; then
  4. echo >&2 " Skipped: Running in chroot."
  5. exit 0
  6. fi
  7. }
  8. systemd_live() {
  9. is_chrooted
  10. if [ ! -d /run/systemd/system ]; then
  11. echo >&2 " Skipped: Current root is not booted."
  12. exit 0
  13. fi
  14. }
  15. udevd_live() {
  16. is_chrooted
  17. if [ ! -S /run/udev/control ]; then
  18. echo >&2 " Skipped: Device manager is not running."
  19. exit 0
  20. fi
  21. }
  22. op="$1"; shift
  23. case "$op" in
  24. binfmt)
  25. systemd_live
  26. /usr/lib/systemd/systemd-binfmt
  27. ;;
  28. catalog)
  29. /usr/bin/journalctl --update-catalog
  30. ;;
  31. daemon-reload-system)
  32. systemd_live
  33. /usr/bin/systemctl --system daemon-reload
  34. ;;
  35. daemon-reload-user)
  36. systemd_live
  37. /usr/bin/systemctl kill --kill-whom='main' --signal='SIGHUP' 'user@*.service'
  38. ;;
  39. hwdb)
  40. /usr/bin/systemd-hwdb --usr update
  41. ;;
  42. sysctl)
  43. systemd_live
  44. /usr/lib/systemd/systemd-sysctl
  45. ;;
  46. sysusers)
  47. /usr/bin/systemd-sysusers
  48. ;;
  49. tmpfiles)
  50. /usr/bin/systemd-tmpfiles --create
  51. ;;
  52. update)
  53. touch -c /usr
  54. ;;
  55. udev-reload)
  56. udevd_live
  57. /usr/bin/udevadm control --reload
  58. if [ ! -e /etc/systemd/do-not-udevadm-trigger-on-update ]; then
  59. /usr/bin/udevadm trigger -c change
  60. /usr/bin/udevadm settle
  61. fi
  62. ;;
  63. # For use by other packages
  64. reload)
  65. systemd_live
  66. /usr/bin/systemctl try-reload-or-restart "$@"
  67. ;;
  68. *)
  69. echo >&2 " Invalid operation '$op'"
  70. exit 1
  71. ;;
  72. esac
  73. exit 0