Thanks, Roger, I thought I was replying to the list, but apparently not. So perhaps this will help someone else who has a similar situation. I wasn't clear enough in my initial question...it isn't so much that I want the status of the UPS, rather I want to know that the Pi is operational again after upsmon has shutdown the Pi and then the UPS has had power restored to it. I created a script called "reboot_notify" and saved it in usr/local/bin, and it looks like this: #!/bin/sh echo ?Rpi has booted into operation? | mail -s "Alert from Peppermill RPi" [my email address] echo "Rpi has booted into operation" | mail -s "Alert from Peppermill RPi" [email address for text messages] I read that scripts placed in "rc.local" get run at boot, so I edited /etc/rc.local like this #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Print the IP address * # Have the system pause while all the mail elements load, ? sleep 60 # and then run the script: ? sudo /usr/local/bin/reboot_notify * _IP=$(hostname -I) || true if [ "$_IP" ]; then ? printf "My IP address is %s\n" "$_IP" fi exit 0 Then I made the file executable chmod +x /etc/rc.local To test it I ran <upsmon -c fsd> ; the Pi did an orderly shutdown, the UPS turned off and then came back on again. A few minutes later, after the Pi booted, I received a text message, and the following email message: "Alert from Peppermill Pi", "RPi has booted into operation". I'm sure there was probably a more-elegant way of doing that from a programming standpoint, but for someone who didn't know the first thing about Linux a month ago, I was pleased that I have a solution. Now I hope I didn't make some major mistake which de-stabilizes the system ? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20210306/003826b7/attachment.htm>
Roger Price
2021-Mar-07 10:06 UTC
[Nut-upsuser] Request For Additional Status Confirmation
On Sat, 6 Mar 2021, Jon Kinne via Nut-upsuser wrote:> I created a script called "reboot_notify" and saved it in usr/local/bin, and > it looks like this:Yes, good approach to the problem. In my solution there was an error. Instead of "@reboot root ups-report &", I should have said "@reboot nut ups-report &". It was bad security to execute as superuser.> # Have the system pause while all the mail elements load, > ? sleep 60 > # and then run the script: > ? sudo /usr/local/bin/reboot_notifyDo you need to get root involved? If a hacker can substitute his reboot_notify for yours, he gets full control. Roger