diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-22 10:32:04 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-22 11:14:18 -0800 |
commit | 39a799dac616edd4b42a1b4de2c861f248318e1f (patch) | |
tree | 821d778a77ff75015dba4936ca10652824224ef9 /scripts/vyatta-address | |
parent | b17d21023482c752c490754a11450d4c41c83607 (diff) | |
download | vyatta-cfg-quagga-39a799dac616edd4b42a1b4de2c861f248318e1f.tar.gz vyatta-cfg-quagga-39a799dac616edd4b42a1b4de2c861f248318e1f.zip |
Use script vyatta-address to set interface
Avoid the overhead of perl compilation of vyatta-interfaces for each
address added. Handle the case of deleting address on deleted device
cleanly.
Clean up dhcpv6 script so it can be used on interfaces other
than ethernet.
Diffstat (limited to 'scripts/vyatta-address')
-rw-r--r-- | scripts/vyatta-address | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/vyatta-address b/scripts/vyatta-address new file mode 100644 index 00000000..2e521c26 --- /dev/null +++ b/scripts/vyatta-address @@ -0,0 +1,45 @@ +#! /bin/bash +# +# Wrapper around ip link command that handles IPv4, IPv6 and DHCP +# This is done in shell rather than perl to avoid the overhead of recompilation + +if [ $# -ne 3 ]; then + echo "Usage: $0 {add|delete} interface address" + exit 1 +fi + +case $1 in + 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 + exec ip -6 addr add "$3" dev "$2" + else + exec ip addr add "$3" broadcast + dev "$2" + fi ;; + + delete) + 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 $ifname + 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 |