2021-09-15 15:06:20 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DAEMON="iptables"
|
|
|
|
|
|
|
|
IPTABLES_ARGS=""
|
|
|
|
|
|
|
|
start() {
|
|
|
|
printf 'Starting %s: ' "$DAEMON"
|
2021-10-06 08:20:31 +02:00
|
|
|
iptables-restore /etc/iptables.conf
|
2021-09-15 15:06:20 +02:00
|
|
|
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"
|
2021-10-06 08:20:31 +02:00
|
|
|
iptables-save -f /etc/iptables.conf
|
2021-09-15 15:06:20 +02:00
|
|
|
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;;
|
|
|
|
*)
|
2021-10-06 08:20:31 +02:00
|
|
|
echo "Usage: $0 {start|stop|restart|save|reload}"
|
2021-09-15 15:06:20 +02:00
|
|
|
exit 1
|
|
|
|
esac
|