Replacing incron with systemd

Discussion in 'Tips/Tricks/Mods' started by Th0m, Feb 20, 2022.

Thread Status:
Not open for further replies.
  1. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Until Debian 11, we instructed users to use incron to monitor certificates changes to automatically restart your services when the certificate is updated. As incron is deprecated, you should now simply use systemd. This is a simple guide to replace incron with a systemd service for users that followed this guide: https://www.howtoforge.com/securing...server-with-a-valid-lets-encrypt-certificate/

    To start of, remove incron:
    Code:
    apt remove incron -y
    Create and open the new systemd service:
    Code:
    nano /etc/systemd/system/le-mailserver-restart.service
    Paste this in that file:
    Code:
    [Unit]
    Description="Run script to restart Postfix and Dovecot after the certificate has been renewed"
    
    [Service]
    ExecStart=/etc/init.d/le_mailserver_restart.sh
    
    Save and close this file. Then create and open the new systemd path file:
    Code:
    nano /etc/systemd/system/le-mailserver-restart.path
    Paste this in that file and replace mail.example.com with the hostname you used:
    Code:
    [Unit]
    Description="Monitor the mailserver certificate files to trigger a e-mail services restart after the certificates has been renewed"
    
    [Path]
    PathModified=/root/.acme.sh/mail.example.com/
    Unit=le-mailserver-restart.service
    
    [Install]
    WantedBy=multi-user.target
    Save and close this file. Then start the service and enable it so it runs on startup:
    Code:
    systemctl start le-mailserver-restart.path
    And enable it so it runs on startup:
    Code:
    systemctl enable le-mailserver-restart.path
    And we're done!

    This has been updated in the actively used guides on HowToForge.
     
    Last edited: Feb 23, 2022
    till likes this.
Thread Status:
Not open for further replies.

Share This Page