Add port sysutils/mgeupsd, a daemon to monitor MGE Pulsar brand UPS's.
This commit is contained in:
parent
7aeafab3fe
commit
f22db6a4ea
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=40002
@ -69,6 +69,7 @@
|
||||
SUBDIR += medusa
|
||||
SUBDIR += mei
|
||||
SUBDIR += memtest
|
||||
SUBDIR += mgeupsd
|
||||
SUBDIR += mkisofs
|
||||
SUBDIR += mksunbootcd
|
||||
SUBDIR += monitord
|
||||
|
24
sysutils/mgeupsd/Makefile
Normal file
24
sysutils/mgeupsd/Makefile
Normal file
@ -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>
|
1
sysutils/mgeupsd/distinfo
Normal file
1
sysutils/mgeupsd/distinfo
Normal file
@ -0,0 +1 @@
|
||||
MD5 (mgeupsd-0.3.tar.gz) = 63f1caf34c625f1043eb991f496e154c
|
15
sysutils/mgeupsd/files/mgeupsd.sh
Normal file
15
sysutils/mgeupsd/files/mgeupsd.sh
Normal file
@ -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
|
47
sysutils/mgeupsd/files/patch-aa
Normal file
47
sysutils/mgeupsd/files/patch-aa
Normal file
@ -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;
|
||||
}
|
21
sysutils/mgeupsd/files/patch-ab
Normal file
21
sysutils/mgeupsd/files/patch-ab
Normal file
@ -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
|
36
sysutils/mgeupsd/files/powerhandler
Normal file
36
sysutils/mgeupsd/files/powerhandler
Normal file
@ -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
|
1
sysutils/mgeupsd/pkg-comment
Normal file
1
sysutils/mgeupsd/pkg-comment
Normal file
@ -0,0 +1 @@
|
||||
monitor a state of MGE Pulsar UPS connected to RS-232 port
|
8
sysutils/mgeupsd/pkg-descr
Normal file
8
sysutils/mgeupsd/pkg-descr
Normal file
@ -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.
|
6
sysutils/mgeupsd/pkg-message
Normal file
6
sysutils/mgeupsd/pkg-message
Normal file
@ -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.
|
4
sysutils/mgeupsd/pkg-plist
Normal file
4
sysutils/mgeupsd/pkg-plist
Normal file
@ -0,0 +1,4 @@
|
||||
sbin/mgeupsd
|
||||
sbin/powerhandler
|
||||
etc/rc.d/mgeupsd.sh
|
||||
man/man8/mgeupsd.8
|
Loading…
Reference in New Issue
Block a user