systemd.install 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. sd_booted() {
  3. [[ -d run/systemd/system && ! -L run/systemd/system ]]
  4. }
  5. add_journal_acls() {
  6. # ignore errors, since the filesystem might not support ACLs
  7. setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx var/log/journal/ 2>/dev/null
  8. :
  9. }
  10. post_common() {
  11. systemd-sysusers
  12. journalctl --update-catalog
  13. if ! grep -qe '^/usr/bin/systemd-home-fallback-shell$' etc/shells; then
  14. echo '/usr/bin/systemd-home-fallback-shell' >> etc/shells
  15. fi
  16. }
  17. post_install() {
  18. systemd-machine-id-setup
  19. post_common "$@"
  20. add_journal_acls
  21. # enable some services by default, but don't track them
  22. systemctl enable \
  23. getty@tty1.service \
  24. remote-fs.target \
  25. systemd-userdbd.socket
  26. # group 'systemd-journal-remote' is created by systemd-sysusers
  27. mkdir -m2755 var/log/journal/remote
  28. chgrp systemd-journal-remote var/log/journal/remote
  29. }
  30. post_upgrade() {
  31. post_common "$@"
  32. if sd_booted; then
  33. systemctl --system daemon-reexec
  34. systemctl kill --kill-whom='main' --signal='SIGRTMIN+25' 'user@*.service'
  35. fi
  36. # show for feature release: 255 -> 256 -> 257 -> ...
  37. if [ $(vercmp "${1%%[!0-9]*}" "${2%%[!0-9]*}") -ne 0 ]; then
  38. cat <<-EOM
  39. :: This is a systemd feature update. You may want to have a look at
  40. NEWS for what changed, or if you observe unexpected behavior:
  41. /usr/share/doc/systemd/NEWS
  42. EOM
  43. fi
  44. local v upgrades=(
  45. )
  46. for v in "${upgrades[@]}"; do
  47. if [[ $(vercmp "$v" "$2") -eq 1 ]]; then
  48. "_${v//[.-]/_}_changes"
  49. fi
  50. done
  51. }
  52. post_remove() {
  53. sed -i -r '/^\/usr\/bin\/systemd-home-fallback-shell$/d' etc/shells
  54. }
  55. # vim:set ts=2 sw=2 et: