I have an old, but serviceable Best Patriot dumb UPS that I want to run at here at home. I have a 6.0b3 server.
I have tested it with the INT 51 cable on a W2K workstation and everything workls as it should.
I am having a devil of a job trying to find anything concise about reconfiguring nut to work. I have read just about every post on UPS, NUT and anything else I can find here, and all (the little that there is) of the manuals at the nut site, along with trawling though anything else I can find online.
I am stuck on trying to set the right configuration options.
I know that I need the following config in ups.conf :
[UPS]
driver = genericups
port = /dev/ttyS0
upstype = 6
I added a property to db configuration nut called Options and set it to 6
I enabled nut, and have had a bit of a hack at the templates and can generate the above with the following custom ups.conf template :
{
my $model = $nut{Model} || "hidups";
my $device = $nut{Device} || "/var/lib/ups/hiddev0";
my $upstype = $nut{Options}; ####Added this line
$OUT .= "[UPS]\n";
$OUT .= "\tdriver = $model\n";
$OUT .= "\tport = $device\n";
$OUT .= "\tupstype = $upstype\n"; ####Added this line
}
First question is about the ||hidups and ||/var.lib/ups/hiddev0 - dooes this mean 'default to these settings in the absence of another setting ?
However, I know that this isn't all there is too it as it kept reporting that
the line was stale. Having had another recce, I tried the following on the command line too see what would happen:
/sbin/genericups -x upstype=6 /dev/ttyS0
and got the followjng failure :
Network UPS Tools - Generic UPS driver 0.60 (1.2.0)
UPS type: Best Patriot (INT51 cable)
This program is currently running as nutups (UID 420)
/dev/ttyS0 is owned by user root (UID 0), mode 0660
Change the port name, or fix the permissions or ownership of /dev/ttyS0 and try again.
Unable to open /dev/ttyS0: Permission denied
This would be the correct config for my UPS.
I then had a bit more of a hunt round and found /etc/sysconfig/ups
As the original property I had in ups.conf and db configuration was called upstype, I discover that here it is called Options. So I changed the ups.conf fragment and the configuration entry to read Options and now I have two files that look vaguley as I would expect. But when I start the service it shows
Poll UPS [localhost] failed - Data stale
But then if I stop the ups service I get the following :
Stopping UPS: UPS
Can't open /var/lib/ups/genericups-ttyS0.pid: No such file or directory
So I guess the root of the problem is that UPS doesn't seem to be able to grab the ttyS0 and hence can't tell what's on the other end of it.
Couple of other things I noticed whilst writing - man ups.conf doesn't mention about having a upstype, but I am sure I read it somewhere around - possibly regarding the genericups driver.
I have also tried a nolock option in the file and get the following :
Starting upsd: Network UPS Tools upsd 1.2.0
Can't bind to socket: Address already in use
[ FAILED ]
Hmm. Nothing else connected to either port. Presumably it's a permissions thing, but well beyond me,
If I remove no lock and the upstrype from the ups.conf file I get a file called upsd.pid with a pid appear in the /var/lib/ups
So that's as far as I have got and I'm stuck well and truly, and know that but for a couple of bits of code I would be away.
Anyway, if anyone can tell me what I have done right or wrong, where to go next etc I would be grateful. After 3 nights of this my brain is totally frazzed. Just wish there was a bit more documentation around about implemetation/configuration of this on my server.
B. Rgds
John
Epilogue - just for fun I chmoded ttyS0 from 660 to 666. And away it went - connected up and running. Still get a complaint about the genericups-ttyS0.pid - no such file or directory.
I guess that there must be a more secure way of doing this so what have I missed, and what about the pid file ?
Aaaahhhhh. A pid file has now appeared and all seems well on this front. So. What about the permissions ? Is this a securtiy risk ? Why does it happen, and how do I stop it ?