Edit file File name : K01ndn-iptables Content :#! /bin/sh # pushed by ansible ndn_iptables_role ### BEGIN INIT INFO # Provides: ndn-iptables # Required-Start: $remote_fs $syslog $networking $procps # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 5 # Default-Stop: 0 1 4 6 # Short-Description: iptables starting # Description: manage iptables services. ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin SAVE=/sbin/iptables-save RESTORE=/sbin/iptables-restore IPTABLES=/sbin/iptables SAVE6=/sbin/ip6tables-save RESTORE6=/sbin/ip6tables-restore IPTABLES6=/sbin/ip6tables IPSET=/sbin/ipset IPSETDIR=/var/lib/ipset NAME=ndn-iptables DESC=ndn-iptables BASERULES=/var/lib/iptables/base.rules MYRULES=/var/lib/iptables/my.rules AUTORULES=/var/lib/iptables/auto.rules BASERULES6=/var/lib/ip6tables/base.rules MYRULES6=/var/lib/ip6tables/my.rules AUTORULES6=/var/lib/ip6tables/auto.rules LISTS=$(/bin/ls /var/lib/ipset | grep -E "\.ipset$"|sort) test -x $SAVE || exit 0 test -x $RESTORE || exit 0 test -f $BASERULES || exit 0 test -f $MYRULES || exit 0 test -x $SAVE6 || exit 0 test -x $RESTORE6 || exit 0 test -f $BASERULES6 || exit 0 test -f $MYRULES6 || exit 0 test -x $IPSET || exit 0 # Include ndn-iptables defaults if available if [ -f /etc/default/ndn-iptables ] ; then # shellcheck source=files/etc/init.d/ndn-iptables . /etc/default/ndn-iptables fi set -e case "$1" in start) echo "Starting $DESC ... " for L in $LISTS do echo "Restoring ipset $L ..." $IPSET restore -f $IPSETDIR/"$L" -exist || true echo "done" done cat $BASERULES $MYRULES | awk -F# '{print $1}' | $RESTORE cat $BASERULES6 $MYRULES6 | awk -F# '{print $1}' | $RESTORE6 echo "$NAME." ;; stop) echo "Stopping $DESC ... " $IPTABLES -F || true $IPTABLES6 -F || true echo "Stopping ipset ..." $IPSET flush || true echo "done" ;; restart|force-reload) echo "Restarting $DESC ... " $0 stop sleep 1 $0 start ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart}" >&2 exit 1 ;; esac exit 0 Save