--- badi/public_scripts/switchgate/switchgate 2010/08/18 11:38:24 1.7 +++ badi/public_scripts/switchgate/switchgate 2017/03/28 21:44:24 1.8 @@ -1,6 +1,6 @@ #!/bin/bash -# switchhgate 0.0.4 +# switchhgate 0.0.5 # (c) 2005-2010 under GPL by Adrian Zaugg # switchgate pings a set of hosts to determine the state of the internet connectivity. If @@ -59,15 +59,15 @@ function readgwlist { fi allgates=`grep -ve "^[ ]*[\#]\+.*$" "$GATEWAYS_FILE" | xargs` + alldhcpgates="" for gate in $allgates; do - if [[ $(echo "$gate" | grep -c -e "^[:space:]*dhcp\..*$") -eq 1 && \ - -f "$CONFIG_PATH/$gate" ]]; then + if [[ $(echo "$gate" | grep -c -e "^[[:space:]]*dhcp\..*$") -eq 1 && \ + -f "$DHCP_TMP_DIR/$gate" ]]; then # Read dhcp supplied gate for a specific interface - alldhcpgates=`grep -e "^[^\#].*$" "$CONFIG_PATH/$gate" | xargs` - elif [[ $(echo "$gate" | grep -c -e "^[:space:]*dhcp[:space:]*$") -eq 1 ]]; then + alldhcpgates="$alldhcpgates `grep -e "^[^\#].*$" "$DHCP_TMP_DIR/$gate" | xargs`" + elif [[ $(echo "$gate" | grep -c -e "^[[:space:]]*dhcp[[:space:]]*$") -eq 1 ]]; then # Read all dhcp files - alldhcpgates="" - for dhcpfile in $(echo -n $(ls -1 $DHCP_TMP_DIR/dhcp* 2>/dev/null)); do + for dhcpfile in $(echo -n $(ls -1 $DHCP_TMP_DIR/dhcp* 2>/dev/null)); do alldhcpgates="$alldhcpgates `grep -e "^[^\#].*$" "$dhcpfile" | xargs`" done else