Systemd with bash script

To load my firewall rules I have always used a init script containing all my iptables rules.
However with the switch to systemd in Debian Jessie things have changed a bit.

create a service file in /etc/systemd/system. In my case this is /etc/systemd/system/firewall.service


ExecStart=/bin/sh /scripts/ start
ExecStop=/bin/sh /scripts/ stop
ExecReload=/bin/sh /scripts/ restart


Important here are the Type and RemainAfterExit parameters. Also don’t forget /bin/sh or /bin/bash if you are executing a script !

Next enable and start the service

systemctl enable firewall.service
service firewall start

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.