nut: Use 'real' procd for nut-cgi
authorDaniel F. Dickinson <redacted>
Tue, 28 Aug 2018 18:55:10 +0000 (14:55 -0400)
committerDaniel F. Dickinson <redacted>
Wed, 29 Aug 2018 04:16:33 +0000 (00:16 -0400)
Even though nut-cgi doesn't run a daemon, using procd triggers
is helpful for updating the generated config file when the
UCI config changes.  So implement this and 'modernize' nut-cgi initscript

Signed-off-by: Daniel F. Dickinson <redacted>
net/nut/files/nut-cgi.init

index 50301ccc97e7ad04610607049b0cc4f9f8b41781..c77e12afd8420f90f1e01b50d40a50653e254d5f 100755 (executable)
@@ -5,6 +5,7 @@
 # See /LICENSE for more information.
 #
 START=51
+USE_PROCD=1
 
 DEFAULT=/etc/default/nut
 UPSCGI_C=/var/etc/nut/hosts.conf
@@ -42,10 +43,10 @@ nut_upscgi_add() {
        echo "MONITOR $system \"$displayname\"" >> $UPSCGI_C
 }
 
-start() {
-       rm -f $UPSCGI_C
-       rm -f "$UPSCGI_S"
+service_reload() {
        mkdir -m 0755 -p "$(dirname "$UPSCGI_C")"
+       rm -f "$UPSCGI_C"
+       rm -f "$UPSCGI_S"
 
        config_load nut_cgi
 
@@ -55,9 +56,16 @@ start() {
        chmod 640 /var/etc/nut/hosts.conf
 }
 
-stop() {
-       rm -f $UPSCGI_C
+start_service() {
+       service_reload
+}
+
+stop_service() {
+       rm -f "$UPSCGI_C"
        rm -f "$UPSCGI_S"
        ln -sf /etc/nut/upsset.conf.disable "$UPSCGI_S"
 }
 
+service_triggers() {
+       procd_add_reload_trigger "nut_cgi"
+}
git clone https://git.99rst.org/PROJECT