]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
Imported nut changes from glotzi.
authorArne Fitzenreiter <arne_f@ipfire.org>
Sun, 25 Oct 2009 11:07:21 +0000 (12:07 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 25 Oct 2009 11:07:21 +0000 (12:07 +0100)
config/rootfiles/packages/nut
lfs/nut
src/initscripts/init.d/nut [new file with mode: 0644]
src/paks/nut/install.sh [new file with mode: 0644]
src/paks/nut/uninstall.sh [new file with mode: 0644]
src/paks/nut/update.sh [new file with mode: 0644]

index 694d2c3ab430f26f1f0c8afa61d2116d75bd6210..7e85fc1d380e76e503adeb0833d8d527c725028c 100644 (file)
@@ -1,11 +1,12 @@
-etc/nut.conf.sample
-etc/ups.conf.sample
-etc/upsd.conf.sample
-etc/upsd.users.sample
-etc/upsmon.conf.sample
-etc/upssched.conf.sample
-#lib/udev/rules.d
-lib/udev/rules.d/52-nut-usbups.rules
+etc/rc.d/init.d/nut
+#etc/nut
+etc/nut/nut.conf.sample
+etc/nut/ups.conf.sample
+etc/nut/upsd.conf.sample
+etc/nut/upsd.users.sample
+etc/nut/upsmon.conf.sample
+etc/nut/upssched.conf.sample
+etc/udev/rules.d/52-nut-usbups.rules
 usr/bin/apcsmart
 usr/bin/bcmxcp
 usr/bin/bcmxcp_usb
@@ -57,7 +58,7 @@ usr/bin/victronups
 #usr/cgi-bin
 #usr/html
 #usr/lib/libupsclient.la
-#usr/lib/libupsclient.so
+usr/lib/libupsclient.so
 usr/lib/libupsclient.so.1
 usr/lib/libupsclient.so.1.0.0
 usr/sbin/upsd
diff --git a/lfs/nut b/lfs/nut
index e2635050d011df4bac05b9013c01261872fee166..bb171846ab2e9f9bf291e4e43de6426ce669f29e 100644 (file)
--- a/lfs/nut
+++ b/lfs/nut
@@ -77,7 +77,7 @@ $(subst %,%_MD5,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        @$(PREBUILD)
        @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
-       cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/etc
+       cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/etc/nut --with-usb --with-user=root --with-group=nut --with-wrap=no --with-udev-dir=/etc/udev
        cd $(DIR_APP) && make $(MAKETUNING)
        cd $(DIR_APP) && make install
        @rm -rf $(DIR_APP)
diff --git a/src/initscripts/init.d/nut b/src/initscripts/init.d/nut
new file mode 100644 (file)
index 0000000..43f7092
--- /dev/null
@@ -0,0 +1,173 @@
+#! /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
+
+NAME=nut
+DESC="Network UPS Tools"
+DEFAULT=/etc/sysconfig/nut
+CONFIG=/etc/nut/nut.conf
+
+. /etc/sysconfig/rc
+. $rc_functions
+
+# set upsd specific options. use "man upsd" for more info
+UPSD_OPTIONS=""
+
+# set upsmon specific options. use "man upsmon" for more info
+UPSMON_OPTIONS=""
+
+# Include defaults if available (transition period)
+if [ -f $DEFAULT ] ; then
+       . $DEFAULT
+fi
+
+# Include NUT nut.conf
+if [ -f $CONFIG ] ; then
+       . $CONFIG
+fi
+
+# Explicitly require the configuration to be done in /etc/nut/nut.conf
+if [ "x$MODE" = "xnone" ] ; then
+    log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
+    log_failure_msg "and then set MODE to a suitable value in $CONFIG to enable it."
+    # exit success to avoid breaking the install process!
+    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)
+      case "$1" in
+        start)
+          ! $upsdrvctl start >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
+          $upsd $UPSD_OPTIONS >/dev/null 2>&1
+          ;;
+        stop)
+          $upsd -c stop >/dev/null 2>&1
+          ! $upsdrvctl stop >/dev/null 2>&1 && boot_mesg "(upsdrvctl failed)"
+          ;;
+      esac
+      ;;
+    none|netclient|*)
+      return 1
+      ;;
+  esac
+}
+
+start_stop_client () {
+  case "$MODE" in
+    standalone|netserver|netclient)
+      case "$1" in
+        start)
+          $upsmon $UPSMON_OPTIONS >/dev/null 2>&1
+          ;;
+        stop)
+          $upsmon -c stop >/dev/null 2>&1
+          ;;
+      esac
+      ;;
+    none|*)
+      return 1
+      ;;
+  esac
+}
+
+case "$1" in
+
+  start)
+    boot_mesg "Starting $DESC"
+    check_var_directory
+    start_stop_server start
+    start_stop_client start
+    ;;
+
+  stop)
+    boot_mesg "Stopping $DESC"
+    start_stop_server stop
+    start_stop_client stop
+    ;;
+
+  reload)
+    $upsd   -c reload >/dev/null 2>&1
+    $upsmon -c reload >/dev/null 2>&1
+    ;;
+
+  restart|force-reload)
+    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
+    ;;
+
+  poweroff)
+    flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf`
+    wait_delay=`sed -ne 's#^ *POWEROFF_WAIT= *\(.*\)$#\1#p' $CONFIG`
+    if [ -f "$flag" ] ; then
+      if $upsmon -K >/dev/null 2>&1 ; then
+       boot_mesg "Shutting down the UPS ..."
+       sleep 1
+       if $upsdrvctl shutdown ; then
+         sleep 5
+         boot_mesg "Waiting for UPS to cut the power"
+       else
+         boot_mesg "Shutdown failed."
+         boot_mesg "Waiting for UPS batteries to run down"
+       fi
+       if [ "$wait_delay" ] ; then
+         boot_mesg " (will reboot after $wait_delay) ..."
+         sleep "$wait_delay"
+         /etc/init.d/reboot stop
+       fi
+      else
+        boot_mesg "Power down flag is not set (UPS shutdown not needed)"
+      fi
+    else
+        if [ -z "$flag" ] ; then
+         boot_mesg "##########################################################"
+         boot_mesg "## POWERDOWNFLAG is not defined in /etc/nut/upsmon.conf ##"
+         boot_mesg "##                                                      ##"
+         boot_mesg "## Please read the Manual page upsmon.conf(5)           ##"
+         boot_mesg "##########################################################"
+       fi
+    fi
+    ;;
+
+  *)
+    N=/etc/init.d/$NAME
+    echo "Usage: $N {start|stop|reload|restart|force-reload|poweroff}" >&2
+    exit 1
+    ;;
+esac
+
+exit 0
diff --git a/src/paks/nut/install.sh b/src/paks/nut/install.sh
new file mode 100644 (file)
index 0000000..2a07532
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh 
+
+extract_files 
+restore_backup ${NAME}
+
+groupadd nut
+
+start_service --background ${NAME}
diff --git a/src/paks/nut/uninstall.sh b/src/paks/nut/uninstall.sh
new file mode 100644 (file)
index 0000000..a7b8a53
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+stop_service ${NAME}
+make_backup ${NAME}
+remove_files
diff --git a/src/paks/nut/update.sh b/src/paks/nut/update.sh
new file mode 100644 (file)
index 0000000..89c40d0
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+./uninstall.sh
+./install.sh