Startup/Shutdown email notification

  • Hello Everyone,

    I am using OMV 5 as a backup server for daily automated backups. And it is doing an awesome job. Thanks for everyone contributing to this great project.

    I would like to receive an email notification once OMV startup and shutdown. Any ideas how to do this in clean way?
    I already configured SMTP for other notifications using OMV webGUI, and I can receive all other notifications. The only extra I need is to receive an email upon startup and shutdown.


    Thanks in advance:)

  • Mail at startup can be done by adding a scheduled job in the GUI of OMV with "time of exection" At Reboot.


    Command:

    echo "Server has restarted "`hostname` | mail -s "rebooted" jane.doe@gmail.com.


    Mail at shutdown is not so simple AFAIK, but you will find some ways using google.

  • Thanks for your reply. I tried to do a systemd service to send the shutdown email. But it is never sent on time because the message goes to queue first. And I am unable to find a way to make this service execute that script before stopping postfix

  • I managed to achieve what I wanted. Here is how..


    1- Create a user with privileges enough to send mail

    2- Create a service file nano /etc/systemd/system/email-notifications.service

    3- Enable the created service systemctl enable email-notifications.service


    Notes/Findings:

    • Those steps assumes you already configured email configurations in OMV webGUI
    • That service file worked for me after several try/error attempts. It is not guaranteed that it would work for everyone else
    • I think It needs tweaking (I am not familiar enough with systemd)
    • systemd is very fast in stopping/killing services/processes during shutdown. Thats why 5 seconds delay is needed
    • The main issue/challenge is that postfix doesn't send emails currently in queue before it gets stopped by systemd
    • systemd is complicated and messing with it is likely going to break your OMV installation. I suggest reading its manual pages carefully
    • It would be great if the function of shutdown notification be added in OMV webGUI


    Thanks for all your hints and for OMV :)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!