summaryrefslogtreecommitdiff
path: root/sysutils/mgeupsd
diff options
context:
space:
mode:
authorDonald Burr <dburr@FreeBSD.org>2001-03-18 08:04:56 +0000
committerDonald Burr <dburr@FreeBSD.org>2001-03-18 08:04:56 +0000
commitf22db6a4eaf5105c8790b5acaebb30f5c6e74773 (patch)
tree51b91e07ba9c00ef97b7036d7afc2f599b3f826f /sysutils/mgeupsd
parentUpdate to use Tcl/Tk 8.3 (diff)
Add port sysutils/mgeupsd, a daemon to monitor MGE Pulsar brand UPS's.
Notes
Notes: svn path=/head/; revision=40002
Diffstat (limited to 'sysutils/mgeupsd')
-rw-r--r--sysutils/mgeupsd/Makefile24
-rw-r--r--sysutils/mgeupsd/distinfo1
-rw-r--r--sysutils/mgeupsd/files/mgeupsd.sh15
-rw-r--r--sysutils/mgeupsd/files/patch-aa47
-rw-r--r--sysutils/mgeupsd/files/patch-ab21
-rw-r--r--sysutils/mgeupsd/files/powerhandler36
-rw-r--r--sysutils/mgeupsd/pkg-comment1
-rw-r--r--sysutils/mgeupsd/pkg-descr8
-rw-r--r--sysutils/mgeupsd/pkg-message6
-rw-r--r--sysutils/mgeupsd/pkg-plist4
10 files changed, 163 insertions, 0 deletions
diff --git a/sysutils/mgeupsd/Makefile b/sysutils/mgeupsd/Makefile
new file mode 100644
index 000000000000..d9480203ae6f
--- /dev/null
+++ b/sysutils/mgeupsd/Makefile
@@ -0,0 +1,24 @@
+# Ports collection makefile for: sono
+# Date created: 12 Aug 1999
+# Whom: Andreas Dobloug <andreasd@ifi.uio.no>
+#
+# $FreeBSD$
+#
+
+PORTNAME= mgeupsd
+PORTVERSION= 0.3
+CATEGORIES= sysutils
+MASTER_SITES= ${MASTER_SITE_SUNSITE}
+MASTER_SITE_SUBDIR= system/ups
+
+MAINTAINER= andreasd@ifi.uio.no
+
+USE_GMAKE= YES
+WRKSRC= ${WRKDIR}/MGE
+
+post-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/mgeupsd.sh ${PREFIX}/etc/rc.d
+ ${INSTALL_SCRIPT} ${FILESDIR}/powerhandler ${PREFIX}/sbin
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.mk>
diff --git a/sysutils/mgeupsd/distinfo b/sysutils/mgeupsd/distinfo
new file mode 100644
index 000000000000..58ec71fc1c86
--- /dev/null
+++ b/sysutils/mgeupsd/distinfo
@@ -0,0 +1 @@
+MD5 (mgeupsd-0.3.tar.gz) = 63f1caf34c625f1043eb991f496e154c
diff --git a/sysutils/mgeupsd/files/mgeupsd.sh b/sysutils/mgeupsd/files/mgeupsd.sh
new file mode 100644
index 000000000000..dfaa7794f965
--- /dev/null
+++ b/sysutils/mgeupsd/files/mgeupsd.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+if [ "X${1}" = "Xstart" ]
+then
+ /usr/local/sbin/mgeupsd -run /usr/local/sbin/powerhandler /dev/cuaa0
+ echo -n ' mgeupsd'
+elif [ "X${1}" = "Xstop" ]
+then
+ kill `cat /var/run/mgeupsd.pid`
+ rm -f /var/run/mgeupsd.pid
+ rm -f /var/run/powerstatus
+ echo -n ' mgeupsd'
+else
+ echo "Usage: `basename $0` { start | stop }"
+ exit 1
+fi
diff --git a/sysutils/mgeupsd/files/patch-aa b/sysutils/mgeupsd/files/patch-aa
new file mode 100644
index 000000000000..1b73dbd127bd
--- /dev/null
+++ b/sysutils/mgeupsd/files/patch-aa
@@ -0,0 +1,47 @@
+--- mgeupsd.c.old Sat Dec 26 02:42:52 1998
++++ mgeupsd.c Sat Mar 17 23:59:09 2001
+@@ -33,9 +33,9 @@
+ #define BS_TDP 12
+
+ /* status file for init */
+-#define PWRFILE "/etc/powerstatus"
++#define PWRFILE "/var/run/powerstatus"
+ /* Linux usual */
+-#define LOCKDIR "/var/lock"
++#define LOCKDIR "/var/run"
+ #define RUNDIR "/var/run"
+ char lockfile[40] = {0,};
+ char pidfile[40] = {0,};
+@@ -640,7 +640,7 @@
+ else
+ {
+ #ifndef TEST
+- if (kill (init_pid, SIGPWR))
++ if (kill (init_pid, SIGUSR2))
+ syslog (LOG_CRIT, "Process %u doesn not exist! Can't send SIGPWR", init_pid);
+ #endif
+ }
+@@ -677,7 +677,7 @@
+ else
+ {
+ #ifndef TEST
+- if (kill (init_pid, SIGPWR))
++ if (kill (init_pid, SIGINT))
+ syslog (LOG_CRIT, "Process %u doesn not exist! Can't send SIGPWR", init_pid);
+ #endif
+ }
+@@ -711,7 +711,7 @@
+ else
+ {
+ #ifndef TEST
+- if (kill (init_pid, SIGPWR))
++ if (kill (init_pid, SIGHUP))
+ syslog (LOG_CRIT, "Process %u doesn not exist! Can't send SIGPWR", init_pid);
+ #endif
+ }
+@@ -758,4 +758,5 @@
+ }
+ } /* while(1) */
+ }
++ return 0;
+ }
diff --git a/sysutils/mgeupsd/files/patch-ab b/sysutils/mgeupsd/files/patch-ab
new file mode 100644
index 000000000000..d472e7cce2cf
--- /dev/null
+++ b/sysutils/mgeupsd/files/patch-ab
@@ -0,0 +1,21 @@
+*** Makefile.orig Fri Dec 25 10:10:57 1998
+--- Makefile Tue Aug 10 23:36:12 1999
+***************
+*** 8,15 ****
+ $(CC) $(LDFLAGS) -o $@ $<
+
+ install: mgeupsd
+! install mgeupsd /sbin
+! install mgeupsd.8 /usr/man/man8
+
+ clean:
+ rm -f *.o mgeupsd
+--- 8,15 ----
+ $(CC) $(LDFLAGS) -o $@ $<
+
+ install: mgeupsd
+! install -c mgeupsd ${PREFIX}/sbin
+! install -c mgeupsd.8 ${PREFIX}/man/man8
+
+ clean:
+ rm -f *.o mgeupsd
diff --git a/sysutils/mgeupsd/files/powerhandler b/sysutils/mgeupsd/files/powerhandler
new file mode 100644
index 000000000000..5f47600d4ebc
--- /dev/null
+++ b/sysutils/mgeupsd/files/powerhandler
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+PATH=${PATH}:/sbin:/usr/sbin:/usr/local/sbin;export PATH
+
+STATUS=`cat ${1}`
+L="logger -i -t powerhandler"
+
+${L} "Status message received: ${STATUS}"
+
+if [ "X${STATUS}" = "XFAIL" ]
+then
+ ${L} "Power loss detected, initiating shutdown"
+ # we are shutting down... give users some warning
+ shutdown -h +5 "POWER FAILURE DETECTED... initiating emergency shutdown... SAVE YOUR WORK NOW AND LOGOFF!!!"
+elif [ "X${STATUS}" = "XLOWBATT" ]
+then
+ ${L} "Battery is critical, initiating IMMEDIATE shutdown"
+ # battery is low.. shut down NOW!
+ # first nix any shutdown processes
+ killall shutdown
+ shutdown -h now "BATTERY IS LOW... SHUTTING DOWN **IMMEDIATELY**..."
+elif [ "X${STATUS}" = "XOK" ]
+then
+ ${L} "Power has been restored, canceling shutdown"
+ # everything's ok... cancel the shutdown
+ killall shutdown
+ rm -f /var/run/nologin
+ wall << _EOF_
+System power has been restored.
+The shutdown procedure has been canceled.
+_EOF_
+else
+ # unknown state... help!
+ ${L} "this shouldn't be happening!"
+ exit 1
+fi
diff --git a/sysutils/mgeupsd/pkg-comment b/sysutils/mgeupsd/pkg-comment
new file mode 100644
index 000000000000..a3686d0fbd50
--- /dev/null
+++ b/sysutils/mgeupsd/pkg-comment
@@ -0,0 +1 @@
+monitor a state of MGE Pulsar UPS connected to RS-232 port
diff --git a/sysutils/mgeupsd/pkg-descr b/sysutils/mgeupsd/pkg-descr
new file mode 100644
index 000000000000..8a7e139ad632
--- /dev/null
+++ b/sysutils/mgeupsd/pkg-descr
@@ -0,0 +1,8 @@
+mgeupsd is a daemon process that sits in the background and check
+state of the UPS every 10 (by default) seconds. As soon as mgeupsd
+senses that the power is failing it notifies init(8) and init will
+execute the powerwait and powerfail entries. If mgeupsd senses that
+the power has been restored, it notifies init again and init will exe-
+cute the powerokwait entries. If mgeupsd senses that the UPS batteries
+has less than 20% of its energy it notifies init again and init will
+execute the powerfailnow entries.
diff --git a/sysutils/mgeupsd/pkg-message b/sysutils/mgeupsd/pkg-message
new file mode 100644
index 000000000000..6b7ebc3d95ce
--- /dev/null
+++ b/sysutils/mgeupsd/pkg-message
@@ -0,0 +1,6 @@
+A configuration file has been installed in ${PREFIX}/etc/rc.d/mgeupsd.sh.
+Examine it to make sure it is suitable for your system.
+
+A sample script that handles the various power messages has been placed in
+${PREFIX}/sbin/powerhandler. You will probably want to edit it to suit
+your particular needs.
diff --git a/sysutils/mgeupsd/pkg-plist b/sysutils/mgeupsd/pkg-plist
new file mode 100644
index 000000000000..828a80368cf9
--- /dev/null
+++ b/sysutils/mgeupsd/pkg-plist
@@ -0,0 +1,4 @@
+sbin/mgeupsd
+sbin/powerhandler
+etc/rc.d/mgeupsd.sh
+man/man8/mgeupsd.8