aboutsummaryrefslogtreecommitdiff
path: root/firewall/multiconfig.sh
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-30 13:49:11 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-30 14:11:58 +0200
commit496fad1b1059118900d8450ce400330c65116497 (patch)
treeba833dad00cbbdb2b4e5e0fd2e7ad97a3db5c8d2 /firewall/multiconfig.sh
parent315dd7ca36cd0118f5dd4a98d5321c8ac642643f (diff)
downloadmulticonfig-496fad1b1059118900d8450ce400330c65116497.tar.gz
multiconfig-496fad1b1059118900d8450ce400330c65116497.tar.bz2
multiconfig-496fad1b1059118900d8450ce400330c65116497.zip
Implement firewall script and morev0.1.2
Diffstat (limited to 'firewall/multiconfig.sh')
-rwxr-xr-xfirewall/multiconfig.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/firewall/multiconfig.sh b/firewall/multiconfig.sh
new file mode 100755
index 0000000..1c9b6ff
--- /dev/null
+++ b/firewall/multiconfig.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -e
+
+mkdir /etc/iptables
+
+configure() {
+ if ! grep -q "$3_SAVE=\"/etc/iptables/$1\""; then
+ echo "Reconfiguring $2 service configuration"
+ sed -i "s#^$3_SAVE=.*\$#$3_SAVE=\"/etc/iptables/$1\"#" "/etc/conf.d/$2"
+ fi
+}
+configure ipv4 iptables IPTABLES
+configure ipv6 ip6tables IP6TABLES
+
+H="$(hostname)"
+
+if inst "firewall/$H.ipv4" /etc/iptables/ipv4; then
+ echo "Reloading IPv4 firewall"
+ service iptables reload
+fi
+
+if inst "firewall/$H.ipv6" /etc/iptables/ipv6; then
+ echo "Reloading IPv6 firewall"
+ service ip6tables reload
+fi