Ubuntu: Systemd issue (or misconfiguration)



Question:

I'm trying to configure and manage my firewall/iptables rules as a service, but I think I'm misunderstanding the objective of the ExecStop and ExecReload configs in the /etc/systemd/system/firewall.service file.

If I add these options to the file, it seems like the service is either not executed, or ExecStart/ExecStop/ExecReload are all executed. Can someone please cast some light on this issue for me?

Here is my /etc/systemd/system/firewall.service file:

[Unit]  Description=Firewall Service  After=network.target    [Service]  User=root  Restart=always  Type=simple  ExecStop=/etc/default/firewall_manager.sh stop  ExecReload=/etc/default/firewall_manager.sh restart  ExecStart=/etc/default/firewall_manager.sh start    [Install]  WantedBy=multi-user.target  

firewall_manager.sh is a shell script with some checks and a case like this:

case $1 in    start)      start      ;;    stop)      stop      ;;    stopv6)      stopv6      ;;    restart)      stop      start      ;;    expulse)      expulse      ;;    status)      echo "============================== IPv4 =============================="      /sbin/iptables -nL      #/sbin/iptables -t nat -L      echo "============================== IPv6 =============================="      /sbin/ip6tables -nL      RETVAL=0      ;;    *)      echo "Uso: $1 {start|stop|stopv6|restart|status|expulse}"      RETVAL=1;;  esac  

which then calls /etc/default/firewall_rules.sh, that have the firewall rules.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »