2014-10-10 16:35:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: iptables
|
|
|
|
# Required-Start: $local_fs
|
|
|
|
# Required-Stop: $local_fs
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Description: IP Tables as service
|
|
|
|
# X-Author: Adrian Kousz, 2014
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
CONFIG=/etc/iptables.rules
|
|
|
|
|
|
|
|
start() {
|
|
|
|
iptables -F
|
2014-11-02 21:33:12 +01:00
|
|
|
iptables-restore -c < "$CONFIG"
|
2014-10-10 16:35:33 +02:00
|
|
|
echo 'Service started'
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
iptables -F
|
|
|
|
echo 'Service stopped'
|
|
|
|
}
|
|
|
|
|
|
|
|
status() {
|
|
|
|
iptables -L -v
|
|
|
|
}
|
|
|
|
|
|
|
|
save() {
|
|
|
|
iptables-save -c > "$CONFIG"
|
|
|
|
echo 'Settings saved'
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
save
|
|
|
|
if [ "$2" != "really" ]; then
|
|
|
|
echo 'Append "really" to disable iptables!' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|status}"
|
|
|
|
exit 1
|
|
|
|
esac
|