]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
nut: Added status option, some installation fixed
authorDirk Wagner <glotzi@ipfire.org>
Mon, 9 Nov 2009 20:22:19 +0000 (21:22 +0100)
committerDirk Wagner <glotzi@ipfire.org>
Mon, 9 Nov 2009 20:22:19 +0000 (21:22 +0100)
config/rootfiles/packages/nut
lfs/nut
src/initscripts/init.d/nut [changed mode: 0644->0755]
src/paks/nut/install.sh
src/paks/nut/uninstall.sh

index 146d320a323e2967fbf226adfdaccf89d2ad5efd..c4ebe19921ea5cb2a77adf7bf0d0be7f472fdb64 100644 (file)
@@ -1,4 +1,5 @@
 var/ipfire/backup/addons/includes/nut
+var/state/ups
 etc/rc.d/init.d/nut
 #etc/nut
 etc/nut/nut.conf.sample
diff --git a/lfs/nut b/lfs/nut
index 3ecf78de9cc9846dae9f9589131530ab0f78fd9b..93672d93741399e884a4e9f7ac6d65fc5641753d 100644 (file)
--- a/lfs/nut
+++ b/lfs/nut
@@ -82,6 +82,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
                        --with-wrap=no --with-udev-dir=/etc/udev
        cd $(DIR_APP) && make $(MAKETUNING)
        cd $(DIR_APP) && make install
+       -mkdir -p /var/state/ups
        install -v -m 644 $(DIR_SRC)/config/backup/includes/nut \
                         /var/ipfire/backup/addons/includes/nut
        @rm -rf $(DIR_APP)
old mode 100644 (file)
new mode 100755 (executable)
index 43f7092..8aba4ff
@@ -1,17 +1,4 @@
 #! /bin/sh
-### BEGIN INIT INFO
-# Provides:          nut
-# Required-Start:    $local_fs $syslog $network
-# Required-Stop:     $local_fs $syslog $network
-# Default-Start:     2 3 4 5
-# Default-Stop:      0 1 6
-# Short-Description: Network UPS Tools initscript
-# Description:       This script take care of starting and stopping the
-#                    Network UPS Tools components. When needed, it also
-#                    handle the UPS hardware shutdown.
-### END INIT INFO
-
-# Author: Arnaud Quette <aquette@debian.org>
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin
 
@@ -47,21 +34,11 @@ if [ "x$MODE" = "xnone" ] ; then
     exit 0
 fi
 
-pid_dir=/var/run/nut
-upsmon_pid=${pid_dir}/upsmon.pid
-upsd_pid=${pid_dir}/upsd.pid
 upsd=/usr/sbin/upsd
 upsdrvctl=/usr/bin/upsdrvctl
 upsmon=/usr/sbin/upsmon
 log=">/dev/null 2>/dev/null"
 
-# Check if /var/run/nut exists and has the correct perms
-check_var_directory() {
-       [ ! -d ${pid_dir} ] && mkdir -p ${pid_dir} \
-               && chown root:nut ${pid_dir} \
-               && chmod 770 ${pid_dir}
-}
-
 start_stop_server () {
   case "$MODE" in
     standalone|netserver)
@@ -69,9 +46,11 @@ start_stop_server () {
         start)
           ! $upsdrvctl start >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
           $upsd $UPSD_OPTIONS >/dev/null 2>&1
+          evaluate_retval
           ;;
         stop)
           $upsd -c stop >/dev/null 2>&1
+          evaluate_retval
           ! $upsdrvctl stop >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
           ;;
       esac
@@ -88,9 +67,11 @@ start_stop_client () {
       case "$1" in
         start)
           $upsmon $UPSMON_OPTIONS >/dev/null 2>&1
+          evaluate_retval
           ;;
         stop)
           $upsmon -c stop >/dev/null 2>&1
+          evaluate_retval
           ;;
       esac
       ;;
@@ -100,17 +81,39 @@ start_stop_client () {
   esac
 }
 
+status_server () {
+  case "$MODE" in
+    standalone|netserver)
+      statusproc $upsd
+      statusproc $upsmon
+      ;;
+    none|netclient|*)
+      return 1
+      ;;
+  esac
+}
+
+status_client () {
+  case "$MODE" in
+    standalone|netclient)
+      statusproc $upsmon
+      ;;
+    none|*)
+      return 1
+      ;;
+  esac
+}
+
 case "$1" in
 
   start)
-    boot_mesg "Starting $DESC"
-    check_var_directory
+    boot_mesg "Starting $DESC ..."
     start_stop_server start
     start_stop_client start
     ;;
 
   stop)
-    boot_mesg "Stopping $DESC"
+    boot_mesg "Stopping $DESC ..."
     start_stop_server stop
     start_stop_client stop
     ;;
@@ -120,12 +123,16 @@ case "$1" in
     $upsmon -c reload >/dev/null 2>&1
     ;;
 
+  status)
+    status_server
+    status_client
+    ;;
+
   restart|force-reload)
-    boot_mesg "Restarting $DESC"
+    boot_mesg "Restarting $DESC ..."
     start_stop_client stop
     start_stop_server stop
     sleep 5
-    check_var_directory
     start_stop_server start
     start_stop_client start
     ;;
@@ -165,7 +172,7 @@ case "$1" in
 
   *)
     N=/etc/init.d/$NAME
-    echo "Usage: $N {start|stop|reload|restart|force-reload|poweroff}" >&2
+    echo "Usage: $N {start|stop|status|reload|restart|force-reload|poweroff}" >&2
     exit 1
     ;;
 esac
index 2a07532f7a0c2e8aa9dfcce11a64495cb3bd5a9d..d117ad88fc740ed3241781768b12d1c2d200ce3d 100644 (file)
@@ -28,4 +28,8 @@ restore_backup ${NAME}
 
 groupadd nut
 
+ln -svf  ../init.d/nut /etc/rc.d/rc0.d/K20nut
+ln -svf  ../init.d/nut /etc/rc.d/rc3.d/S20nut
+ln -svf  ../init.d/nut /etc/rc.d/rc6.d/K20nut
+
 start_service --background ${NAME}
index a7b8a5370f68e23809d3bd94083f0150545980cb..2cce35973882c9abfef74a3bed317498dba33577 100644 (file)
@@ -25,3 +25,5 @@
 stop_service ${NAME}
 make_backup ${NAME}
 remove_files
+
+rm -rf /etc/rc.d/rc*.d/*nut
\ No newline at end of file