#!/bin/sh Green='\033[0;32m' Color_off='\033[0m' Red='\033[0;31m' DAEMON="iptables" IPTABLES_ARGS="" start() { printf 'Starting %s: ' "$DAEMON" iptables-restore /etc/iptables.conf status=$? if [ "$status" -eq 0 ]; then printf "[$Green OK $Color_off]\n" else printf "[$Red ERR $Color_off]\n" fi return "$status" } stop() { printf 'Stopping %s: ' "$DAEMON" iptables -F status=$? if [ "$status" -eq 0 ]; then printf "[$Green OK $Color_off]\n" else printf "[$Red ERR $Color_off]\n" fi return "$status" } restart() { stop sleep 1 start } save() { printf 'Saving %s: ' "$DAEMON" iptables-save -f /etc/iptables.conf status=$? if [ "$status" -eq 0 ]; then printf "[$Green OK $Color_off]\n" else echo "SKIP (read-only file system detected)" fi return "$status" } case "$1" in start|stop|restart|save) "$1";; reload) # Restart, since there is no true "reload" feature. restart;; *) echo "Usage: $0 {start|stop|restart|save|reload}" exit 1 esac