[Nut-upsuser] Request For Additional Status Confirmation
Jon Kinne
jhkinne1 at gmail.com
Sun Mar 7 02:41:39 GMT 2021
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>
More information about the Nut-upsuser
mailing list