tiny refactor: replace some 'if's with short-circuit expressions

This commit is contained in:
Matthias Radestock committed 2015-06-15 18:33:29 +01:00
1 parent 6534cc6ae3
commit 8ac98f9f6b
1 file changed
+5 -12
+5 -12
View File
@@ -265,9 +265,8 @@ create_bridge() {
run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true run_iptables -t nat -N WEAVE >/dev/null 2>&1 || true
add_iptables_rule nat POSTROUTING -j WEAVE add_iptables_rule nat POSTROUTING -j WEAVE
fi fi
if [ ! "$1" = "--without-ethtool" ] ; then
ethtool -K $BRIDGE tx off >/dev/null [ "$1" != "--without-ethtool" ] && ethtool -K $BRIDGE tx off >/dev/null
fi
ip link set dev $BRIDGE up ip link set dev $BRIDGE up
@@ -277,9 +276,7 @@ create_bridge() {
} }
destroy_bridge() { destroy_bridge() {
if [ -d /sys/class/net/$BRIDGE ] ; then [ -d /sys/class/net/$BRIDGE ] && ip link del dev $BRIDGE
ip link del dev $BRIDGE
fi
if [ "$DOCKER_BRIDGE" != "$BRIDGE" ] ; then if [ "$DOCKER_BRIDGE" != "$BRIDGE" ] ; then
run_iptables -t filter -D FORWARD -i $DOCKER_BRIDGE -o $BRIDGE -j DROP 2>/dev/null || true run_iptables -t filter -D FORWARD -i $DOCKER_BRIDGE -o $BRIDGE -j DROP 2>/dev/null || true
fi fi
@@ -582,9 +579,7 @@ wait_for_log() {
grep -q "$2" $fifo || res=1 grep -q "$2" $fifo || res=1
kill $! 2>/dev/null || true kill $! 2>/dev/null || true
rm $fifo rm $fifo
if [ $res -eq 1 ] ; then [ $res -eq 1 ] && echo "$1 container has died." >&2
echo "$1 container has died." >&2
fi
return $res return $res
} }
@@ -1184,9 +1179,7 @@ case "$COMMAND" in
arp_update $BRIDGE $CIDR arp_update $BRIDGE $CIDR
add_iptables_rule nat WEAVE -d $CIDR ! -s $CIDR -j MASQUERADE add_iptables_rule nat WEAVE -d $CIDR ! -s $CIDR -j MASQUERADE
add_iptables_rule nat WEAVE -s $CIDR ! -d $CIDR -j MASQUERADE add_iptables_rule nat WEAVE -s $CIDR ! -d $CIDR -j MASQUERADE
if [ "$FQDN" ] ; then [ -n "$FQDN" ] && when_dns_running put_dns_fqdn 'weave:expose' $FQDN $CIDR
when_dns_running put_dns_fqdn 'weave:expose' $FQDN $CIDR
fi
fi fi
done done
;; ;;