Ashus.ashus.net
Mailcow-dockerized systemd control script - Printable Version

+- Ashus.ashus.net (https://ashus.ashus.net)
+-- Forum: My creations (https://ashus.ashus.net/forum-3.html)
+--- Forum: Other (https://ashus.ashus.net/forum-9.html)
+--- Thread: Mailcow-dockerized systemd control script (/thread-190.html)



Mailcow-dockerized systemd control script - Ashus - 28.6.2021

You can use this control script to enable commands like service mailcow restart just like with other services.
Add the following file named mailcow.service to directory /etc/systemd/system of you Debian installation.

Code:
[Unit]
Description=Mailcow-dockerized control
# no need to enable as a service - mailcow-dockerized gets executed on reboot automatically
Requires=docker.service
After=docker.service

[Service]
Type=oneshot
RemainAfterExit=true
Restart=no
RestartSec=2
User=root
WorkingDirectory=/opt/mailcow-dockerized/
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down

[Install]
WantedBy=multi-user.target