summaryrefslogtreecommitdiff
path: root/libre/systemd/udev-hook
blob: 659463af7d694dca54c02f5cdc99eb37fd35dd98 (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
#!/bin/sh -e

is_chrooted() {
  if systemd-detect-virt --chroot; then
    echo >&2 "  Skipped: Running in chroot."
    exit 0
  fi
}

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

case $1 in
  hwdb)     /usr/bin/systemd-hwdb --usr update ;;

  udev-reload)   udevd_live;   /usr/bin/udevadm control --reload ;;

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

exit 0