summaryrefslogtreecommitdiffstats
path: root/source/a/nut/rc.nut-upsmon
blob: 8fc5ec8f87da8e4e664aadb13c5e3d53c9a2356d (plain) (blame)
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
38
39
40
41
42
43
44
45
46
#!/bin/sh
# NUT upsmon start-up and shutdown script.
# upsmon is the client process that is responsible for the most important part
# of UPS monitoring--shutting down the system when the power goes out.
#
# upsmon should be run on every machine that is powered by the UPS if you wish
# to support automatic shutdown on battery power.
#
# See /etc/nut/ for configuration files.

# Start upsmon:
upsmon_start() {
  # Make sure the runtime directory is there:
  mkdir -p /run/nut
  chown -R nut:nut /run/nut
  chmod 0770 /run/nut
  # Start the NUT UPS monitor and shutdown controller:
  echo "Starting the NUT UPS monitor and shutdown controller:  upsmon -u nut"
  upsmon -u nut
}

# Stop upsmon:
upsmon_stop() {
  echo "Stopping the NUT UPS monitor and shutdown controller."
  upsmon -c stop
}

# Reload configuration files for upsmon:
upsmon_reload() {
  echo "Reloading configuration files for the NUT UPS monitor and shutdown controller:  upsmon -c reload"
  upsmon -c reload
}

case "$1" in
'start')
  upsmon_start
  ;;
'stop')
  upsmon_stop
  ;;
'reload')
  upsmon_reload
  ;;
*)
  echo "usage $0 start|stop|reload"
esac