OT:Any (Linux) UPS experts ?

Stuck at the last stage of setting up my server, and that is getting the (Eaton NV400) UPS configured.

Server is running Debian Wheezy. I have installed and configured NUT, and so far everything works. It connects to the USB port, reads the UPS, and reacts to a power off event.

However, in my config, I want the following:

Power cut: - send SMS, start 10 minute timer

10 minutes elapse:- shut down UPS (it has a 30 second grace period, allowing computer to shutdown); then: Shutdown PC.

It's this last step that I can't make happen. I'm using the upssched module, and have put "/sbin/shutdown -h 0" in upssched.sh, but it's just being ignored. Tried googling, but nothing jumped out.

In the NUT docs, it does seem to hint that the NUT system won't actually go to shutdown till the UPS sends a "battery low" signal. If this is the case, then I can live with it. However I don't really like the idea of pulling the plug and running down the battery to find out.

All this is to avoid what happened when I *didn't* have any UPS software configured. We had a longish outage - the PC didn't shutdown, and the UPS battery doubled in size. I was lucky to be able to replace it.

Reply to
Jethro_uk
Loading thread data ...

Does that work from the comamnd line? The man page for shutdown on my linux box would have a + before the 0 or use "now".

That's the default configuration, you can have any of the signalled events trigger a shutdown. Mine starts the moment the power goes (ONBATT) as the UPS also has to keep other, far more important, things up. I can't remember the exact way to change it, it might just be a case of moving the shutdown bit in upsshed.conf from one signal to another.

Reply to
Dave Liquorice

On Friday 24 May 2013 10:41 Jethro_uk wrote in uk.d-i-y:

Is nut running as root (ps axu) ? shutdown cannot run as non root by default. If I'm right then you need some /etc/sudoers magic to allow nut to run shutdown with no password.

Reply to
Tim Watts

Sorry, me being sloppy. Ideally the command I would like to use is:

/etc/init.d/nut-client poweroff

however this returns:

[info] Power down flag is not set (UPS poweroff not needed).

even if I try it when on battery. So then I try:

/sbin/shutdown now

which is just being ignored. I put a log message before and after it in the upssched.sh script, and they are run.

no, the events are being triggered ... shutdown should work from any of them.

Reply to
Jethro_uk

to be fair NUT is very paranoid about security. Digging further, I see that non-root users can be allowed to use shutdown if they are in /etc/ shutdown.allow and you pass the username to shutdown. I'll try that.

My Unix is rusty, but wasn't there a way to run a process as another user, so you can test permissions and the like ?

Reply to
Jethro_uk

sudo

Reply to
Huge

problem is that requires a users password ... the nut user isn't an interactive one, so has no password ...

Reply to
Jethro_uk

If in doubt sync; sync; halt; effectively pulls the plug on the linux.

Reply to
The Natural Philosopher

yes, as root simply do su - user

to become that user completely.

Reply to
The Natural Philosopher

No it doesn't.

Reply to
Clive George

On Friday 24 May 2013 13:12 Jethro_uk wrote in uk.d-i-y:

That's why /etc/sudoers has the NOPASSWD directive :)

Reply to
Tim Watts

Then set it. It's merely an empty file, name specified in upsmon.conf. Create it.

Or use: upsmon -c fsd

Reply to
Bob Eager

I have just learned that ;)

I think this is definitely a permissions issue ... I shall play around with etc/sudoers. Now I have the sense it's a permissions issue, all of a sudden there's no end to the guides :

formatting link

my problem was thinking it was purely a *UPS* issue.

Reply to
Jethro_uk

in order to be able to run shutdown, I had to put the "nut" group into the sudoers file:

formatting link

and then had to use "sudo /sbin/shutdown ...."

my problem was that I was googling "how to shut linux down from a script", rather than "how to shut linux down as user other than root".

Hopefully others here will find this useful ;)

Reply to
Jethro_uk

No it doesn't.

Look at the NOPASSWD parameter for sudoers.

Reply to
Huge

Thanks ... never had to mess with sudoers before. As I have stated elsewhere it was the trick I needed.

Reply to
Jethro_uk

Yeah, sorry, I should have read the whole thread before posting.

Reply to
Huge

I would have thought the UPS would shut down anyway, without any software configured, when its battery got low?

Reply to
Timothy Murphy

I think he wants to keep the UPS/PC alive only long enough to achieve an orderly shutdown.

Not to keep computing through the powercut...

Reply to
The Natural Philosopher

no disrespect ... I'm too old (and ugly) to have faith in "I would have thought ..." ;

I *did* think that, which is why after the last 2+ hour powercut I needed to buy a new battery.

Reply to
Jethro_uk

HomeOwnersHub website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.