On Wed, Oct 14, 2020 at 09:59:28AM +0800, Hu Xuejiao wrote:
When firewalld is inactive, return code of 'systemctl status firewalld' will be 3, and install-tiny has set -e, so this will cause this process exit.
Signed-off-by: Hu XueJiao huxuejiao1@huawei.com
sparrow/2-network/iptables | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/sparrow/2-network/iptables b/sparrow/2-network/iptables index 092c4ca..772eb6f 100755 --- a/sparrow/2-network/iptables +++ b/sparrow/2-network/iptables @@ -12,15 +12,23 @@ iptables -I FORWARD 1 -j ACCEPT iptables -t nat -A POSTROUTING -o "$PUB_IFACE" -s $BR0_SUBNET -j MASQUERADE iptables -t nat -A POSTROUTING -o $BR0_IFACE -d $BR0_SUBNET -j MASQUERADE
-systemctl status firewalld | grep -q "running" && { +command -v firewall-cmd > /dev/null || {
- echo "firewalld.service could not be found"
不用显示. 用户不需要关注firewalld. 有没有firewalld都是正常, 我们需要支持的情况.
- exit 0
+}
+systemctl start firewalld +[ "$(systemctl is-active firewalld)" == "active" ] || {
- echo "start firewalld.service failed"
万一是用户自己disable了firewalld呢? 原来是active/inactive的, 最好保持原样.
- exit 0
+}
DOCKER0_IFACE=docker0
DOCKER0_SUBNET=172.17.0.0/16
iptables -t nat -A POSTROUTING -o $PUB_IFACE -s $DOCKER0_SUBNET -j MASQUERADE
iptables -t nat -A POSTROUTING -o $DOCKER0_IFACE -d $DOCKER0_SUBNET -j MASQUERADE
+DOCKER0_SUBNET=172.17.0.0/16
firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source address=$DOCKER0_SUBNET accept"
firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source address=$BR0_SUBNET accept"
firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source address=0.0.0.0/32 accept"
-}
+firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source +address=$DOCKER0_SUBNET accept"
合成一行? 分成两行不好看.
+firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source +address=$BR0_SUBNET accept" +firewall-cmd --zone=public --add-rich-rule="rule family=ipv4 source
+address=0.0.0.0/32 accept"
2.23.0