Notifies when the computer powered on using the Telesign or Twilio
The script uses a .env
file that should contain the variables needed for the script to work properly.
After setting up the values in the .env
file you should add the following to your crontab:
@reboot /path/to/your/script/notify-server-up.sh >> /var/log/notify-sms.log
For some reason the base64
string generated by the telesign_encode_credentials
function differs on the last character, in contrast of the one generated in https://developer.telesign.com/enterprise/reference/sendsms. That's why I had to add the sed s/K$/=/
to the output, but in normal circunstances I guess it shouldn't be needed.
Note that the value for PHONE_TARGET must have the + character as prefix when using Twilio, but not for Telesign.
This script will alert when the server has been unplugged from AC Power. and when it's connected again. It does that by getting the current status from $STATE_FILE.
It is recommended that $STATE_FILE should be in a volatile mountpoint, like a tmpfs filesystem, though, not a requirement...
The notification goes through a ntfy.sh topic.
* * * * * /path/to/your/script/notify-termux-plugged.sh >> /var/log/termux-battery.log
Due to a termux environment is very homogenous, the script shall automate the dependencies installation.