Files
packages/net/nut/files/nut-cgi.init
T
Daniel F. Dickinson bb1b12733e nut: Backport fixes from master
Backport and squash the following commits from master:

  5790053eb nut: Add missing conffiles
  ceff68837 nut: Reorganize nut-server to clarify nut-driver
  f6a2a97d2 nut: Use 'real' procd init for nut-monitor
  918a62f91 nut: Make FSD really work
  a2f64b3ba nut: Reduce user error with POWERDOWNFLAG
  461393810 nut: Use quotes around filenames
  1b6dbe7a7 nut: Remove duplicate/extraneous lines
  0a49d0ffb nut: Fix checking for path before it exists
  3b5a8eee8 nut: Various startup fixes for monitor and server
  44e57d4bd nut: Fix variables for NUT drivers
  36fd59dc7 nut: Fix extraneous config_get
  192b0f164 nut: Fix a typo in setting a driver parameter
  f48b060fa nut: Fix upsd runs as root

And bump PKG_RELEASE

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-11 07:19:15 -05:00

45 lines
827 B
Bash
Executable File

#!/bin/sh /etc/rc.common
# Copyright © 2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
START=51
DEFAULT=/etc/default/nut
UPSCGI_C=/var/etc/nut/hosts.conf
nut_upscgi_add() {
local cfg="$1"
local upsname
local hostname
local port
local displayname
config_get upsname "$cfg" upsname
config_get hostname "$cfg" hostname localhost
config_get port "$cfg" port
config_get pass "$cfg" password
system="$upsname@$hostname"
if [ -n "$port" ]; then
system="$system:$port";
fi
config_get displayname "$cfg" displayname
echo "MONITOR $system \"$displayname\"" >> "$UPSCGI_C"
}
start() {
rm -f $UPSCGI_C
config_load nut_cgi
config_foreach nut_upscgi_add host
chmod 640 /var/etc/nut/hosts.conf
}
stop() {
rm -f $UPSCGI_C
}