summaryrefslogtreecommitdiffstats
path: root/helper/xml-iptables-safe
blob: 22e4804c90c32c70c2180642f888302dc4f4e8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

[ `id -u` = 0 ] || exit 1

export PATH=/sbin:/usr/local/sbin/:/usr/sbin:$PATH

TEMP1=`tempfile`
TEMP2=`tempfile`
chmod 600 $TEMP1 $TEMP2

iptables-save > $TEMP1
xml-iptables $1 > $TEMP2
ret=$? 

if [ "$ret" = "0" ] ; then
    . $TEMP2
    ret=$?
fi

if [ "$ret" = "0" ] ; then
    echo "Firewall installation succeeded." 2>&1
else
    echo "Firewall installation failed." 2>&1
    iptables-restore < $TEMP1
fi

rm -f $TEMP1 $TEMP2

exit $ret