|
@@ -2,11 +2,18 @@
|
|
|
|
|
|
DAEMON="iptables"
|
|
|
|
|
|
-IPTABLES_ARGS=""
|
|
|
+IPTABLES_CONF="/etc/iptables.conf"
|
|
|
+
|
|
|
+# Run only if IPTABLES_CONF exists, except when the action is "save"
|
|
|
+# (which creates it).
|
|
|
+if [ ! -f "${IPTABLES_CONF}" ] && [ "$1" != "save" ]; then
|
|
|
+ echo "${IPTABLES_CONF} does not exist, nothing to do."
|
|
|
+ exit 0
|
|
|
+fi
|
|
|
|
|
|
start() {
|
|
|
printf 'Starting %s: ' "$DAEMON"
|
|
|
- iptables-restore /etc/iptables.conf
|
|
|
+ iptables-restore "$IPTABLES_CONF"
|
|
|
status=$?
|
|
|
if [ "$status" -eq 0 ]; then
|
|
|
echo "OK"
|
|
@@ -18,7 +25,7 @@ start() {
|
|
|
|
|
|
stop() {
|
|
|
printf 'Stopping %s: ' "$DAEMON"
|
|
|
- iptables -F
|
|
|
+ iptables --flush
|
|
|
status=$?
|
|
|
if [ "$status" -eq 0 ]; then
|
|
|
echo "OK"
|
|
@@ -30,13 +37,12 @@ stop() {
|
|
|
|
|
|
restart() {
|
|
|
stop
|
|
|
- sleep 1
|
|
|
start
|
|
|
}
|
|
|
|
|
|
save() {
|
|
|
printf 'Saving %s: ' "$DAEMON"
|
|
|
- iptables-save -f /etc/iptables.conf
|
|
|
+ iptables-save --file "$IPTABLES_CONF"
|
|
|
status=$?
|
|
|
if [ "$status" -eq 0 ]; then
|
|
|
echo "OK"
|