From 64d88fa50818ee03edb1e04207a382890cbccf75 Mon Sep 17 00:00:00 2001 From: Kiall Mac Innes Date: Mon, 10 Nov 2014 18:53:30 +0000 Subject: [PATCH] Fix incorrect service name on Debian in `add-rule` On Debian, the iptables-persistent service has been renamed to netfilter-persistent. The svc-map includes both default, ubuntu, and debian as ubuntu will "fallback" to debian as they are considered the same family of distro. Change-Id: I180a580820015a60ceb2221873a38ebbb06cf953 --- elements/iptables/bin/add-rule | 9 +++++++-- elements/iptables/svc-map | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 elements/iptables/svc-map diff --git a/elements/iptables/bin/add-rule b/elements/iptables/bin/add-rule index cd53c5e66..4fad5fc58 100755 --- a/elements/iptables/bin/add-rule +++ b/elements/iptables/bin/add-rule @@ -37,10 +37,15 @@ if [[ "RedHatEnterpriseServer CentOS Fedora" =~ "$DISTRO" ]]; then fi elif [[ "Debian Ubuntu" =~ "$DISTRO" ]]; then - service iptables-persistent reload + # NOTE(kiall): os-svc-restart etc don't support the custom 'save' + # action, so we grab the name and call the service + # binary "by hand" instead. + SERVICE_NAME=$(svc-map iptables-persistent) + + service $SERVICE_NAME reload iptables -C $RULE || iptables -I $RULE - service iptables-persistent save + service $SERVICE_NAME save fi diff --git a/elements/iptables/svc-map b/elements/iptables/svc-map new file mode 100644 index 000000000..1bcfcd7c1 --- /dev/null +++ b/elements/iptables/svc-map @@ -0,0 +1,4 @@ +iptables-persistent: + default: iptables-persistent + ubuntu: iptables-persistent + debian: netfilter-persistent