fw4: make `fw4 restart` behavior more robust
authorJo-Philipp Wich <jo@mein.io>
Tue, 31 May 2022 07:36:20 +0000 (09:36 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 31 May 2022 07:36:20 +0000 (09:36 +0200)
Start the firewall on `fw4 restart` even if it was not previously started.

Ref: #9935
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
root/sbin/fw4

index 30db129415016f75959f628f40fb2f13eea6e0cd..b66f5d72426e7e9718c5ef0111b21f4725eba1e2 100755 (executable)
@@ -48,7 +48,7 @@ stop() {
                        nft delete table inet fw4
                        rm -f $STATE
                else
-                       die "The fw4 firewall does not appear to be loaded, try fw4 flush to delete all rules."
+                       return 1
                fi
        } 1000>$LOCK
 }
@@ -97,13 +97,13 @@ case "$1" in
                start "$1"
        ;;
        stop)
-               stop
+               stop || die "The fw4 firewall does not appear to be loaded, try fw4 flush to delete all rules."
        ;;
        flush)
                flush
        ;;
        restart)
-               stop
+               stop || rm -f $STATE
                start
        ;;
        print)