nut: nut-cgi: Add support for upsset
This allows config for setting variables and/or running commands from the CGI. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
This commit is contained in:
parent
918a62f919
commit
2fca922cf0
3 changed files with 25 additions and 1 deletions
|
@ -329,12 +329,15 @@ define Package/nut-web-cgi/install
|
||||||
$(INSTALL_CONF) ./files/add_nut_httpd_conf $(1)/etc/uci-defaults/add_nut_httpd_conf
|
$(INSTALL_CONF) ./files/add_nut_httpd_conf $(1)/etc/uci-defaults/add_nut_httpd_conf
|
||||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats.html.sample $(1)/etc/nut/upsstats.html
|
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats.html.sample $(1)/etc/nut/upsstats.html
|
||||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats-single.html.sample $(1)/etc/nut/upsstats-single.html
|
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsstats-single.html.sample $(1)/etc/nut/upsstats-single.html
|
||||||
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf
|
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf.disable
|
||||||
|
$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/nut/upsset.conf.sample $(1)/etc/nut/upsset.conf.enable
|
||||||
|
$(SED) 's/### \?//' $(1)/etc/nut/upsset.conf.enable
|
||||||
$(INSTALL_DIR) $(1)/etc/config
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
$(INSTALL_CONF) ./files/nut_cgi $(1)/etc/config/nut_cgi
|
$(INSTALL_CONF) ./files/nut_cgi $(1)/etc/config/nut_cgi
|
||||||
$(INSTALL_DIR) $(1)/etc/init.d
|
$(INSTALL_DIR) $(1)/etc/init.d
|
||||||
$(INSTALL_BIN) ./files/nut-cgi.init $(1)/etc/init.d/nut-cgi
|
$(INSTALL_BIN) ./files/nut-cgi.init $(1)/etc/init.d/nut-cgi
|
||||||
ln -sf /var/etc/nut/hosts.conf $(1)/etc/nut/hosts.conf
|
ln -sf /var/etc/nut/hosts.conf $(1)/etc/nut/hosts.conf
|
||||||
|
ln -sf /var/etc/nut/upsset.conf $(1)/etc/nut/upsset.conf
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/nut-avahi-service
|
define Package/nut-avahi-service
|
||||||
|
|
|
@ -8,6 +8,20 @@ START=51
|
||||||
|
|
||||||
DEFAULT=/etc/default/nut
|
DEFAULT=/etc/default/nut
|
||||||
UPSCGI_C=/var/etc/nut/hosts.conf
|
UPSCGI_C=/var/etc/nut/hosts.conf
|
||||||
|
UPSCGI_S=/var/etc/nut/upsset.conf
|
||||||
|
|
||||||
|
nut_upscgi_upsset() {
|
||||||
|
local cfg="$1"
|
||||||
|
local enable
|
||||||
|
|
||||||
|
config_get_bool enable "$cfg" enable 0
|
||||||
|
|
||||||
|
[ $enable -eq 1 ] && {
|
||||||
|
ln -sf /etc/nut/upsset.conf.enable "$UPSCGI_S"
|
||||||
|
} || {
|
||||||
|
ln -sf /etc/nut/upsset.conf.disable "$UPSCGI_S"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nut_upscgi_add() {
|
nut_upscgi_add() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
|
@ -30,15 +44,20 @@ nut_upscgi_add() {
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
rm -f $UPSCGI_C
|
rm -f $UPSCGI_C
|
||||||
|
rm -f "$UPSCGI_S"
|
||||||
|
mkdir -m 0755 -p "$(dirname "$UPSCGI_C")"
|
||||||
|
|
||||||
config_load nut_cgi
|
config_load nut_cgi
|
||||||
|
|
||||||
config_foreach nut_upscgi_add host
|
config_foreach nut_upscgi_add host
|
||||||
|
config_foreach nut_upscgi_upsset upsset
|
||||||
|
|
||||||
chmod 640 /var/etc/nut/hosts.conf
|
chmod 640 /var/etc/nut/hosts.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
rm -f $UPSCGI_C
|
rm -f $UPSCGI_C
|
||||||
|
rm -f "$UPSCGI_S"
|
||||||
|
ln -sf /etc/nut/upsset.conf.disable "$UPSCGI_S"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,5 @@
|
||||||
# option port # optional port number
|
# option port # optional port number
|
||||||
# option displayname "Display Name"
|
# option displayname "Display Name"
|
||||||
|
|
||||||
|
config upsset
|
||||||
|
option enable 0
|
||||||
|
|
Loading…
Reference in a new issue