From dd273339066e8a7c2322f29144ef985ed94fcaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 22 Feb 2015 14:37:45 +0100 Subject: [PATCH] ip.bash: fix route syntax on freebsd/macosx --- lib/ip.bash | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ip.bash b/lib/ip.bash index 6abd43f..983b80d 100644 --- a/lib/ip.bash +++ b/lib/ip.bash @@ -1,18 +1,18 @@ -format_ip6_from_mac(){ +format_ip6_from_mac() { local template=$1 IFS=':'; set $2; unset IFS printf "$template" 0x${3} 0x${4} 0x${5} 0x${6} } -add_ip6(){ +add_ip6() { local interface=$1 local ip=$2 local prefixlen=$3 if has ip; then _add_ip_linux "$ip" "$prefixlen" "$interface" elif has ifconfig; then - ifconfig "$interface" inet6 del "$ip" prefixlen "$prefixlen" || true - ifconfig "$interface" inet6 add "$ip" prefixlen "$prefixlen" + ifconfig "$interface" inet6 "$ip" prefixlen "$prefixlen" delete || true + ifconfig "$interface" inet6 "$ip" prefixlen "$prefixlen" add else die "no suitable program found to configure the network interface, need iproute2 or ifconfig" fi @@ -26,8 +26,8 @@ add_ip4() { local cidr="$(mask2cidr $netmask)" _add_ip_linux "$ip" "$cidr" "$interface" elif has ifconfig; then - ifconfig "$interface" del "$ip" netmask "$netmask" || true - ifconfig "$interface" add "$ip" netmask "$netmask" + ifconfig "$interface" "$ip" netmask "$netmask" delete || true + ifconfig "$interface" "$ip" netmask "$netmask" add else die "no suitable program found to set ip address, need iproute2 or ifconfig" fi @@ -37,4 +37,3 @@ _add_ip_linux() { ip addr del "$1/$2" dev "$3" || true ip addr add "$1/$2" dev "$3" } -