openrc-hook 804 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh -e
  2. openrc_live() {
  3. if [ ! -f /run/openrc/softlevel ]; then
  4. echo >&2 " Skipped: Current root is not booted."
  5. exit 0
  6. fi
  7. }
  8. reexec_init() {
  9. local init="$(pacman -Qsq ^init$)"
  10. if [ $init = openrc-init ]; then
  11. /usr/bin/openrc-shutdown -R
  12. elif [ $init = sysvinit ]; then
  13. /usr/bin/init u
  14. else
  15. echo >&2 " WARNING: Unidentified init."
  16. exit 0
  17. fi
  18. }
  19. each_conf() {
  20. while read -r f; do
  21. "$@" "/$f"
  22. done
  23. }
  24. op="$1"; shift
  25. case $op in
  26. sysctl) openrc_live; each_conf /usr/bin/sysctl -q -p ;;
  27. binfmt) openrc_live; each_conf /usr/lib/rc/sh/binfmt.sh ;;
  28. reexec) openrc_live; reexec_init ;;
  29. # For use by other packages
  30. reload) openrc_live; /usr/bin/rc-service "$@" reload ;;
  31. *) echo >&2 " Invalid operation '$op'"; exit 1 ;;
  32. esac
  33. exit 0