1#!/bin/sh 2 3DAEMON="iptables" 4 5IPTABLES_ARGS="" 6 7start() { 8 printf 'Starting %s: ' "$DAEMON" 9 iptables-restore /etc/iptables.conf 10 status=$? 11 if [ "$status" -eq 0 ]; then 12 echo "OK" 13 else 14 echo "FAIL" 15 fi 16 return "$status" 17} 18 19stop() { 20 printf 'Stopping %s: ' "$DAEMON" 21 iptables -F 22 status=$? 23 if [ "$status" -eq 0 ]; then 24 echo "OK" 25 else 26 echo "FAIL" 27 fi 28 return "$status" 29} 30 31restart() { 32 stop 33 sleep 1 34 start 35} 36 37save() { 38 printf 'Saving %s: ' "$DAEMON" 39 iptables-save -f /etc/iptables.conf 40 status=$? 41 if [ "$status" -eq 0 ]; then 42 echo "OK" 43 else 44 echo "SKIP (read-only file system detected)" 45 fi 46 return "$status" 47} 48 49case "$1" in 50 start|stop|restart|save) 51 "$1";; 52 reload) 53 # Restart, since there is no true "reload" feature. 54 restart;; 55 *) 56 echo "Usage: $0 {start|stop|restart|save|reload}" 57 exit 1 58esac 59