diff options
author | James Rayner <james@archlinux.org> | 2007-11-11 23:36:40 +0100 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2007-11-19 12:06:25 +0100 |
commit | bce740635a1649551b32d0d09a70e19dcedb37d3 (patch) | |
tree | 9d1acd58810c3a072b8578a8b00725c88826a0ea /src/ethernet.subr | |
parent | 3537beba0d91a4a7947f5439f695cbebff9e6f55 (diff) | |
download | netctl-bce740635a1649551b32d0d09a70e19dcedb37d3.tar.gz netctl-bce740635a1649551b32d0d09a70e19dcedb37d3.tar.xz |
Fix up tests
Diffstat (limited to 'src/ethernet.subr')
-rw-r--r-- | src/ethernet.subr | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ethernet.subr b/src/ethernet.subr index 39ae11a..ca694b7 100644 --- a/src/ethernet.subr +++ b/src/ethernet.subr @@ -4,7 +4,7 @@ mii_check() { local conn_state=$(mii-tool $1 2> /dev/null) local ret=$? if echo $conn_state|grep "no link" &> /dev/null; then - if [ $ret -eq 0 ]; then + if [[ $ret -eq 0 ]]; then return 1 fi fi @@ -14,7 +14,7 @@ mii_check() { ethernet_up() { - if [ ! -e /sys/class/net/$INTERFACE ]; then + if [[ ! -e /sys/class/net/$INTERFACE ]]; then if ! echo "$INTERFACE"|grep ":"; then err_append "Interface $INTERFACE does not exist" fi @@ -28,7 +28,7 @@ ethernet_up() { case $IP in dhcp) # Check if DHCP_TIMEOUT was set if not set a default value - [ -z $DHCP_TIMEOUT ] && DHCP_TIMEOUT=10 + [[ -z "$DHCP_TIMEOUT" ]] && DHCP_TIMEOUT=10 if checkyesno $DHCLIENT; then rm -r /var/run/dhclient-${INTERFACE}.pid >/dev/null 2>&1 @@ -40,7 +40,7 @@ ethernet_up() { # Clear remaining pid files. rm -f /var/run/dhcpcd-${INTERFACE}.{pid,cache} >/dev/null 2>&1 # If using own dns, tell dhcpcd to NOT replace resolv.conf - [ -n $DNS1 ] && DHCP_OPTIONS="-R $DHCP_OPTIONS" + [[ -n "$DNS1" ]] && DHCP_OPTIONS="-R $DHCP_OPTIONS" # Start dhcpcd if ! dhcpcd -L -t $DHCP_TIMEOUT $DHCP_OPTIONS $INTERFACE; then err_append "DHCP IP lease attempt failed" @@ -56,7 +56,7 @@ ethernet_up() { fi # bring up the default route (gateway) - if [ "$GATEWAY" ]; then + if [[ -n "$GATEWAY" ]]; then if ! route add default gw $GATEWAY; then err_append "Adding gateway $GATEWAY failed" return 1 @@ -66,7 +66,7 @@ ethernet_up() { esac # set the hostname - if [ "$HOSTNAME" ]; then + if [[ -n "$HOSTNAME" ]]; then if ! hostname $HOSTNAME; then err_append "Cannot set hostname" return 1 @@ -74,12 +74,12 @@ ethernet_up() { fi # Generate a new resolv.conf - if [ "$DNS1" ]; then + if [[ -n "$DNS1" ]]; then : >/etc/resolv.conf - [ "$DOMAIN" ] && echo "domain $DOMAIN" >>/etc/resolv.conf - [ "$SEARCH" ] && echo "search $SEARCH" >>/etc/resolv.conf - [ "$DNS1" ] && echo "nameserver $DNS1" >>/etc/resolv.conf - [ "$DNS2" ] && echo "nameserver $DNS2" >>/etc/resolv.conf + [[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf + [[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf + [[ -n "$DNS1" ]] && echo "nameserver $DNS1" >>/etc/resolv.conf + [[ -n "$DNS2" ]] && echo "nameserver $DNS2" >>/etc/resolv.conf fi } @@ -87,17 +87,17 @@ ethernet_down() { case $IP in dhcp) if checkyesno $DHCLIENT; then - if [ -f /var/run/dhclient-${INTERFACE}.pid ]; then + if [[ -f /var/run/dhclient-${INTERFACE}.pid ]]; then kill `cat /var/run/dhclient-${INTERFACE}.pid` fi else - if [ -f /var/run/dhcpcd-${INTERFACE}.pid ]; then + if [[ -f /var/run/dhcpcd-${INTERFACE}.pid ]]; then dhcpcd -x $INTERFACE fi fi ;; static) - [ "$GATEWAY" ] && route del default gw $GATEWAY + [[ -n "$GATEWAY" ]] && route del default gw $GATEWAY ;; esac ifconfig $INTERFACE 0.0.0.0 |