notification/templates/sendmail-reboot.sh
2023-02-18 09:22:41 +03:00

44 lines
1013 B
Bash

#! /bin/sh
# chkconfig: 2345 20 80
### BEGIN INIT INFO
# Provides: sendmail-reboot
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Sending a message on startup
### END INIT INFO
start() {
sleep 30
python3 /usr/local/bin/sendmail.py \
--smtp "$(cat /usr/local/bin/sendmail.config | grep "smtp=" | cut -d= -f2)" \
-u "$(cat /usr/local/bin/sendmail.config | grep "from=" | cut -d= -f2)" \
-p "$(cat /usr/local/bin/sendmail.config | grep "pass=" | cut -d= -f2)" \
-d "$(cat /usr/local/bin/sendmail.config | grep "dest=" | cut -d= -f2)" \
--subj "[System States] $(cat /etc/hostname): computer has been rebooted" \
--text "$(w)" \
>> /dev/null 2>&1 &
}
stop() {
pkill -f /usr/local/bin/sendmail.py
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0