Package: nut
Version: 2.0.1-4angels2
Followup-For: Bug #327072
I am running sarge and encountered the same problem as maciekc but found
a different solution. I edited /etc/init.d/nut to not stop upsdrvctl if
the POWERDOWNFLAG flag was set (patch below).
I think maciekc solution is more elegant and I am using it but the only
point I would raise is that my sarge ttySx ports were configured by
default to hang up when upsdrvctl closes the port.
Since several of the UPSes defined in genericups.h receive a shutdown
by: "lower DTR" and "drop RTS", the UPS may incorrectly shutdown early
when upsdrvctl terminates for the first time.
I considered inserting an:
stty -F /dev/ttyS1 -hupcl
in /etc/init.d/ somewhere but this meant the serial port used by nut was
defined in two places.
Instead, I have modified upsdrv_initups() in genericups.c to clear the
HUPCL flag on the port (patch below).
I don't have the background knowledge of ttySx port usage to know if
this is the correct solution so attached it here for consideration.
--- nut 2006-04-15 17:45:53.000000000 +0800
+++ nut.new 2006-04-17 21:51:33.720963448 +0800
@@ -27,8 +27,13 @@
;;
stop)
start-stop-daemon -K -o -q -p $upsd_pid -n upsd >/dev/null 2>&1
- ! /sbin/upsdrvctl stop >/dev/null 2>&1 && \
- echo -n " (upsdrvctl failed)"
+ flag=`sed -ne 's#^ *POWERDOWNFLAG *\(.*\)$#\1#p' /etc/nut/upsmon.conf`
+ # Stop upsdrvctl if POWERDOWNFLAG is not defined or flag file absent
+ if [ -n "$flag" ] && [ ! -f "$flag" ] ; then
+ echo -n "Stopping upsdrvctl"
+ ! /sbin/upsdrvctl stop >/dev/null 2>&1 && \
+ echo -n " (upsdrvctl failed)"
+ fi
;;
esac
;;
--- genericups.c.old 2004-09-30 16:16:56.000000000 +0800
+++ genericups.c 2006-04-17 21:28:45.000000000 +0800
@@ -241,12 +241,26 @@
void upsdrv_initups(void)
{
+ struct termios serial_ios;
+
set_ups_type();
upsfd = ser_open(device_path);
if (ioctl(upsfd, TIOCMSET, &upstab[upstype].line_norm))
fatal("ioctl TIOCMSET");
+
+ /*
+ * Maintain the serial signal state after ser_close() to prevent
+ * UPS with active low shutdown signals from turning off early.
+ */
+ if (ioctl(upsfd, TCGETS, &serial_ios))
+ fatal("ioctl TCGETS, HUPCL");
+ else {
+ serial_ios.c_cflag &= ~HUPCL;
+ if (ioctl(upsfd, TCSETS, &serial_ios))
+ fatal("ioctl TCSETS, HUPCL");
+ }
}
void upsdrv_cleanup(void)
-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.10-angels
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Versions of packages nut depends on:
ii adduser 3.63 Add and remove users and groups
ii debconf [debconf-2.0] 1.4.30.13 Debian configuration management sy
ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an
-- debconf information:
nut/change_system_user:
nut/major_conf_changes:
nut/major_upstream_changes:
nut/remove_debian_conf:
nut/2_0_upstream_changes:
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]