A lot of distributions, including Arch and Debian/Raspbian, use initscripts to initialise the system, and you can use them to run arbitrary commands. You need to install a script similar to the following in /etc/init.d.
#! /bin/sh
# /etc/init.d/pushover
#
# Some things that run always
touch /var/lock/pushover
TOKEN=
USER=
DIST=`cat /etc/os-release | perl -n -e '/^NAME=\"([a-zA-Z ]*)\"$/ && print "$1\n"'`
echo $TOKEN
echo $USER
echo $DIST
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script pushover "
curl -s \
--data-urlencode "token=$TOKEN" \
--data-urlencode "user=$USER" \
--data-urlencode "message=Raspberry Pi ($DIST) is starting." \
https://api.pushover.net/1/messages
;;
stop)
echo "Stopping script pushover"
curl -s \
--data-urlencode "token=$TOKEN" \
--data-urlencode "user=$USER" \
--data-urlencode "message=Raspberry Pi ($DIST) is stopping." \
https://api.pushover.net/1/messages
;;
*)
echo "Usage: /etc/init.d/pushover {start|stop}"
exit 1
;;
esac
exit 0
You should register with the Pushover service and enter your app token in the TOKEN variable and your user key in the USER variable.
Test it in your home directory first, then move it to /etc/init.d/pushover. You should ensure it is runnable and owned by root.
sudo chmod 755 /etc/init.d/pushover
sudo chown root:root /etc/init.d/pushover
References
- How do I run a command at boot?
- How do I access the distribution's name on the command line?
- Pushover