4906e77d59
This patch will add an init script that allows to set a ruleset in /etc/iptables.conf to be loaded on boot, or flushed on stop, as well as a saving command to generate a new file. Signed-off-by: José Pekkarinen <jose.pekkarinen@unikie.com> [Arnout: change handling of readonly filesystem] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
59 lines
816 B
Bash
59 lines
816 B
Bash
#!/bin/sh
|
|
|
|
DAEMON="iptables"
|
|
|
|
IPTABLES_ARGS=""
|
|
|
|
start() {
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
iptables-restore < /etc/iptables.conf
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf 'Stopping %s: ' "$DAEMON"
|
|
iptables -F
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
sleep 1
|
|
start
|
|
}
|
|
|
|
save() {
|
|
printf 'Saving %s: ' "$DAEMON"
|
|
iptables-save > /etc/iptables.conf
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
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|reload}"
|
|
exit 1
|
|
esac
|