diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-address | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/scripts/vyatta-address b/scripts/vyatta-address index 08e14196..bc496996 100755 --- a/scripts/vyatta-address +++ b/scripts/vyatta-address @@ -9,45 +9,40 @@ if [ $# -ne 3 ]; then fi case $1 in - add) - if [[ "$3" = "dhcp" ]] - then - exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=start - elif [[ "$3" = "dhcpv6" ]] - then + add) + if [[ "$3" = "dhcp" ]]; then + exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=start + elif [[ "$3" = "dhcpv6" ]]; then exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --start -ifname "$2" - elif [[ "$3" =~ ":" ]] - then # Ipv6 address - if ! ip -6 addr list dev $2 | grep -q $3; then - exec ip -6 addr add "$3" dev "$2" - fi - else - if ! ip addr list dev $2 | grep -q $3; then - exec ip addr add "$3" broadcast + dev "$2" - fi - fi ;; + elif [[ "$3" =~ ":" ]]; then + # Ipv6 address + if ! ip -6 addr list dev $2 | grep -q $3; then + exec ip -6 addr add "$3" dev "$2" + fi + else + if ! ip addr list dev $2 | grep -q $3; then + exec ip addr add "$3" broadcast + dev "$2" + fi + fi ;; - delete) + delete) if ! /sbin/ip address show dev $2 2>/dev/null | grep -q "$3"; then # Address doesn't exist there, nothing to delete exit 0 fi - if [ ! -d "/sys/class/net/$2" ] - then # device is already gone - exit 0 - elif [[ "$3" = "dhcp" ]] - then - exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=stop - elif [[ "$3" = "dhcpv6" ]] - then - exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --ifname "$2" - elif [[ "$3" =~ ":" ]] - then - exec ip -6 addr del "$3" dev "$2" - else - exec ip addr del "$3" dev "$2" - fi ;; - *) - echo "Unknown option $1" - exit 1 ;; + if [ ! -d "/sys/class/net/$2" ]; then + # device is already gone + exit 0 + elif [[ "$3" = "dhcp" ]]; then + exec /opt/vyatta/sbin/vyatta-interfaces.pl --dev="$2" --dhcp=stop + elif [[ "$3" = "dhcpv6" ]]; then + exec /opt/vyatta/sbin/vyatta-dhcpv6-client.pl --stop --ifname "$2" + elif [[ "$3" =~ ":" ]]; then + exec ip -6 addr del "$3" dev "$2" + else + exec ip addr del "$3" dev "$2" + fi ;; + *) + echo "Unknown option $1" + exit 1 ;; esac |