[Midnightbsd-cvs] mports: mports/sysutils: add upsd
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Aug 24 18:00:58 EDT 2008
Log Message:
-----------
add upsd
Modified Files:
--------------
mports/sysutils:
Makefile (r1.77 -> r1.78)
Added Files:
-----------
mports/sysutils/upsd:
Makefile (r1.1)
distinfo (r1.1)
pkg-descr (r1.1)
mports/sysutils/upsd/files:
patch-aa (r1.1)
patch-ab (r1.1)
patch-ac (r1.1)
patch-ad (r1.1)
patch-misc.c (r1.1)
upsd.conf (r1.1)
upsd.sh (r1.1)
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/cvs/mports/sysutils/Makefile,v
retrieving revision 1.77
retrieving revision 1.78
diff -L sysutils/Makefile -L sysutils/Makefile -u -r1.77 -r1.78
--- sysutils/Makefile
+++ sysutils/Makefile
@@ -75,6 +75,7 @@
SUBDIR += ucspi-tcp
SUBDIR += ufs_copy
SUBDIR += uif2iso
+ SUBDIR += upsd
SUBDIR += upsmon
SUBDIR += wmbsdbatt
SUBDIR += yawho
--- /dev/null
+++ sysutils/upsd/pkg-descr
@@ -0,0 +1,3 @@
+upsd is a daemon with flexible configuration which lets you to
+shutdown your system properly when source power line fails and
+measure its frequency, voltage etc
--- /dev/null
+++ sysutils/upsd/Makefile
@@ -0,0 +1,36 @@
+# New ports collection makefile for: upsd
+# Date created: 11 Jul 1996
+# Whom: alexis
+#
+# $MidnightBSD: mports/sysutils/upsd/Makefile,v 1.1 2008/08/24 22:00:56 laffer1 Exp $
+# $FreeBSD: ports/sysutils/upsd/Makefile,v 1.18 2008/06/24 07:11:00 az Exp $
+#
+
+PORTNAME= upsd
+PORTVERSION= 2.0.1.6
+CATEGORIES= sysutils
+MASTER_SITES= http://www.mavetju.org/download/adopted/
+
+MAINTAINER= ports at MidnightBSD.org
+COMMENT= APC Smart UPS Monitoring Daemon
+LICENSE= unknown
+
+WRKSRC= ${WRKDIR}/upsd-2.0
+
+PLIST_FILES= sbin/upsd etc/upsd.conf etc/rc.d/upsd.sh
+
+pre-build:
+ @${MV} ${WRKSRC}/config.h ${WRKSRC}/conf.h.orig
+ @${SED} -e "s!@prefix@!${PREFIX}!g" ${WRKSRC}/conf.h.orig > ${WRKSRC}/conf.h
+
+post-install:
+ @if [ ! -f ${PREFIX}/etc/rc.d/upsd.sh ]; then \
+ ${ECHO_MSG} "Installing ${PREFIX}/etc/rc.d/upsd.sh startup file."; \
+ ${INSTALL_SCRIPT} -m 751 ${FILESDIR}/upsd.sh ${PREFIX}/etc/rc.d/upsd.sh; \
+ fi
+ if [ ! -f ${PREFIX}/etc/upsd.conf ] ; then \
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \
+ ${FILESDIR}/upsd.conf ${PREFIX}/etc/upsd.conf; \
+ fi
+
+.include <bsd.port.mk>
--- /dev/null
+++ sysutils/upsd/distinfo
@@ -0,0 +1,3 @@
+MD5 (upsd-2.0.1.6.tar.gz) = 98e46c6f86a87cb441931e1e4bf355c5
+SHA256 (upsd-2.0.1.6.tar.gz) = e31103b9a895f95b1b1b0f50d3e25a431578374c821ab4f80a6e9ab45f8e3ab3
+SIZE (upsd-2.0.1.6.tar.gz) = 23757
--- /dev/null
+++ sysutils/upsd/files/patch-misc.c
@@ -0,0 +1,47 @@
+--- misc.c.orig Sat Aug 3 01:44:24 1996
++++ misc.c Mon Dec 18 21:03:19 2006
+@@ -27,7 +27,7 @@
+ pathname);
+ return -1;
+ }
+- fprintf(f, "%ld\n", getpid());
++ fprintf(f, "%u\n", getpid());
+ fclose(f);
+ umask(oldmask);
+ return 0;
+@@ -60,7 +60,7 @@
+ {
+ register char *p;
+ if((p = malloc(size)) == NULL) {
+- syslog(LOG_ERR, "xalloc: cannot allocate %ls bytes: %m", size);
++ syslog(LOG_ERR, "xalloc: cannot allocate %u bytes: %m", size);
+ return NULL;
+ }
+ return p;
+@@ -105,7 +105,7 @@
+ if(((struct ident *)list)->id == 0) {
+ return NULL;
+ }
+- (char *)list += size;
++ list += size;
+ }
+ return list;
+ }
+@@ -122,7 +122,7 @@
+ register void *list;
+ register size_t size;
+ {
+- for(;((struct ident *)list)->id != 0;(char *)list += size) {
++ for(;((struct ident *)list)->id != 0;list += size) {
+ if(((struct ident *)list)->name == name) {
+ return list;
+ }
+@@ -255,7 +255,7 @@
+ int
+ getcurrenttime(void)
+ {
+- if(time(¤t_time) == NULL) {
++ if(time(¤t_time) == -1) {
+ syslog(LOG_ERR, "cannot get current time: %m");
+ return -1;
+ }
--- /dev/null
+++ sysutils/upsd/files/patch-ac
@@ -0,0 +1,9 @@
+--- upsd.h.orig Fri Jul 3 13:52:01 1998
++++ upsd.h Fri Jul 3 13:52:21 1998
+@@ -206,5 +206,5 @@
+
+ #define TERMINATE kill(getpid(), SIGTERM)
+
+-#include "config.h"
++#include "conf.h"
+ #include "proto.h"
--- /dev/null
+++ sysutils/upsd/files/patch-ab
@@ -0,0 +1,11 @@
+--- config.h.orig Mon Feb 23 17:50:34 1998
++++ config.h Mon Feb 23 17:50:49 1998
+@@ -8,7 +8,7 @@
+ */
+
+ #ifndef DEBUG
+-#define _PATH_UPSD_CONF "/etc/upsd.conf"
++#define _PATH_UPSD_CONF "@prefix@/etc/upsd.conf"
+ #define _PATH_UPSD_PID "/var/run/upsd.pid"
+ #else
+ #define _PATH_UPSD_CONF "sample/upsd.conf"
--- /dev/null
+++ sysutils/upsd/files/patch-ad
@@ -0,0 +1,32 @@
+--- apc.c.orig Fri Aug 2 23:44:22 1996
++++ apc.c Tue Dec 8 16:59:03 1998
+@@ -164,12 +164,12 @@
+ }
+ if((r->type & T_TYPE) == T_BINARY) {
+ if(!bcmp(v1.val.binary, v0.val.binary, r->size)) {
+- syslog(LOG_WARNING, "apc_tune: toggle wraparound");
++ syslog(LOG_WARNING, "apc_tune: toggle wraparound register %s", r->name);
+ return 1;
+ }
+ } else {
+ if(v1.val.number == v0.val.number) {
+- syslog(LOG_WARNING, "apc_tune: toggle wraparound");
++ syslog(LOG_WARNING, "apc_tune: toggle wraparound register %s", r->name);
+ return 1;
+ }
+ }
+--- apc_static.c.orig Fri Aug 2 23:44:23 1996
++++ apc_static.c Tue Dec 8 16:56:57 1998
+@@ -91,9 +91,12 @@
+ {SMART_LOWBATDUR, {number: 7}},
+ {SMART_LOWBATDUR, {number: 10}},
+
++ /* several models accept different values here */
+ {SMART_WAKEUPBCAP, {number: 0}},
+ {SMART_WAKEUPBCAP, {number: 10}},
++ {SMART_WAKEUPBCAP, {number: 15}},
+ {SMART_WAKEUPBCAP, {number: 25}},
++ {SMART_WAKEUPBCAP, {number: 50}},
+ {SMART_WAKEUPBCAP, {number: 90}},
+ {SMART_WAKEUPBCAP, {number: 100}},
+
--- /dev/null
+++ sysutils/upsd/files/upsd.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
+ echo "$0: Cannot determine the PREFIX" >&2
+ exit 1
+fi
+
+case "$1" in
+ start)
+ [ -x ${PREFIX}/sbin/upsd ] && ${PREFIX}/sbin/upsd && echo -n ' upsd'
+ ;;
+ stop)
+ [ -f /var/run/upsd.pid ] && kill -QUIT `cat /var/run/upsd.pid` && echo -n ' upsd'
+ ;;
+ *)
+ echo "Usage: `basename $0` {start|stop}" >&2
+ ;;
+ esac
+
+exit 0
--- /dev/null
+++ sysutils/upsd/files/upsd.conf
@@ -0,0 +1,100 @@
+# $FreeBSD: ports/sysutils/upsd/files/upsd.conf,v 1.2 1999/08/31 02:00:16 peter Exp $
+#
+# UPS Daemon
+# The Wild Wind Communications, 1995, 1996
+#
+# See file LICENSE for the distribution terms of this software.
+#
+
+ups "smart-ups" (230) proto "apc-smart" {
+ device "/dev/cuaa0"
+ speed 2400
+ read-timeout 2
+ write-block-size 1
+ write-block-delay 50
+ queue-size 64
+}
+
+every 5 { # check events every 5 seconds
+ nop
+}
+
+on "initialize" != "SM" {
+ poll "initialize"
+ after 60 every 60 {
+ log emerg "Cannot put the UPS into smart mode!"
+ }
+}
+
+every 600 {
+ tune "high-transfer-point" 264
+ tune "low-transfer-point" 196
+ tune "line-alarm" "0"
+ tune "line-sensitivity" "L"
+ tune "low-batteries-duration" 2
+ tune "nominal-voltage" 220
+ tune "shutdown-delay" 20
+ tune "wakeup-batteries-capacity" 25
+ tune "wakeup-delay" 0
+# tune "batteries-replaced" "01/01/77"
+# tune "label" "WildWind"
+}
+
+every 300 { # poll the UPS
+ poll "last-test"
+# poll "light-test"
+ poll "line-frequency"
+ poll "line-maxvac"
+ poll "line-minvac"
+ poll "line-voltage"
+ poll "load"
+ poll "recharge"
+ poll "temperature"
+ poll "vdc"
+ poll "voltage"
+
+ log notice "last test: %last-test%, light test: %light-test%"
+ log notice "frequency: %line-frequency%, maxvac: %line-maxvac%, minvac: %line-minvac%, voltage: %line-voltage%"
+ log notice "load: %load%, recharge: %recharge%, temp: %temperature%, vdc: %vdc%, output voltage: %voltage%"
+
+ on "load" > 95 {
+ log alert "UPS load is too high: %load%"
+ }
+}
+
+on "line-fail" {
+ log emerg "*** ALERT! Source power line failed, save your work! ***"
+}
+
+on "line-fail" after 30 {
+ log emerg "*** ALERT! System shutdown in 30 seconds, LOGOUT NOW! ***"
+}
+
+on "line-restore" {
+ log emerg "Source power line restored, you may continue your work."
+}
+
+on "line-fail" after 60 {
+ log emerg "*** ALERT! THE SYSTEM IS SHUTTING DOWN! ***"
+
+ poll "shutdown"
+ poll "shutdown"
+ poll "power-test"
+ poll "power-test"
+ poll "shutdown"
+ poll "shutdown"
+
+ sleep 2
+
+ exec "/sbin/halt &"
+
+ poll "power-test"
+ poll "shutdown"
+ poll "power-test"
+ poll "shutdown"
+ poll "power-test"
+ poll "shutdown"
+ poll "power-test"
+
+ sleep 1000 # let us wait peacefully
+}
--- /dev/null
+++ sysutils/upsd/files/patch-aa
@@ -0,0 +1,12 @@
+--- Makefile.orig Mon Feb 23 17:32:56 1998
++++ Makefile Mon Feb 23 17:33:50 1998
+@@ -8,8 +8,7 @@
+
+ PROG= upsd
+
+-BINDIR= /usr/local/sbin
+-MANDIR= /usr/local/share/man
++BINDIR= ${PREFIX}/sbin
+ NOMAN= noway
+
+ #DEBUG= -g -DDEBUG
More information about the Midnightbsd-cvs
mailing list