summarylogtreecommitdiffstats
path: root/systemd-hook
blob: 6f2e899234cf3a25f8be92000a6407752bd3db88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh -e

systemd_live() {
  if [ ! -d /run/systemd/system ]; then
    echo >&2 "  Skipped: Current root is not booted."
    exit 0
  fi
}

udevd_live() {
  if [ ! -d /run/udev ]; then
    echo >&2 "  Skipped: Device manager is not running."
    exit 0
  fi
}

op="$1"; shift

case "$op" in
  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 ;;

  daemon-reload) systemd_live; /usr/bin/systemctl daemon-reload ;;
  udev-reload)   udevd_live;   /usr/bin/udevadm control --reload ;;
  binfmt)        systemd_live; /usr/lib/systemd/systemd-binfmt ;;
  sysctl)        systemd_live; /usr/lib/systemd/systemd-sysctl ;;

  # For use by other packages
  reload)        systemd_live; /usr/bin/systemctl try-reload-or-restart "$@" ;;

  *) echo >&2 "  Invalid operation '$op'"; exit 1 ;;
esac

exit 0