summaryrefslogtreecommitdiffstats
path: root/source/a/nut/rc.nut-upsd
blob: 3ca7cdc0bdeb67f36022bfb7c7aa7fc5fbdc2739 (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
#!/bin/sh
# NUT upsd start-up and shutdown script.
# This should be started after rc.nut-drvctl on the machine connected to the
# UPS's control port. See /etc/nut/ for configuration files.

# Start upsd:
upsd_start() {
  # Make sure the runtime directory is there:
  mkdir -p /run/nut
  chown -R nut:nut /run/nut
  chmod 0770 /run/nut
  # Start the UPS daemon:
  echo "Starting the NUT UPS information server:  upsd -u nut"
  upsd -u nut
}

# Stop upsd:
upsd_stop() {
  echo "Stopping the NUT UPS information server."
  upsd -c stop
}

# Reload configuration files for upsd:
upsd_reload() {
  echo "Reloading configuration files for the NUT UPS information server:  upsd -c reload"
  upsd -c reload
}

case "$1" in
'start')
  upsd_start
  ;;
'stop')
  upsd_stop
  ;;
'reload')
  upsd_reload
  ;;
*)
  echo "usage $0 start|stop|reload"
esac