summaryrefslogtreecommitdiff
path: root/scripts/vyatta-address
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2023-05-05 20:19:46 +0100
committerDaniil Baturin <daniil@baturin.org>2023-05-05 20:30:43 +0100
commitf99ae0b453ac0f1f57192656f27536ab5e8a7463 (patch)
tree590d5431c90aa6a5d9531271a1c17989a23544f4 /scripts/vyatta-address
parent4af276ff4f495a4d130f6857fed2393c8a90b612 (diff)
downloadvyatta-cfg-system-f99ae0b453ac0f1f57192656f27536ab5e8a7463.tar.gz
vyatta-cfg-system-f99ae0b453ac0f1f57192656f27536ab5e8a7463.zip
T671: remove more dead scripts
Diffstat (limited to 'scripts/vyatta-address')
-rwxr-xr-xscripts/vyatta-address69
1 files changed, 0 insertions, 69 deletions
diff --git a/scripts/vyatta-address b/scripts/vyatta-address
deleted file mode 100755
index ed9a298e..00000000
--- a/scripts/vyatta-address
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /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
- if ! ip -6 addr list dev $2 | grep -q $3; then
- exec sudo ip -6 addr add "$3" dev "$2"
- fi
- else
- if ! ip addr list dev $2 | grep -q $3; then
- exec sudo ip addr add "$3" broadcast + dev "$2"
- fi
- fi ;;
-
- delete)
- # Get current address from interface when using DHCP
- if [[ "$3" = "dhcp" ]]; then
- lease_file=/var/lib/dhcp/dhclient_"$(echo $2 | sed -e 's/\./_/')".leases;
- ip=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p');
- #ip_address=$(sed -n 's/^\s\sfixed-address\s\(.*\);/\1/p' $lease_file | sed -n '$p');
- # T1053 we need IP/prefix for normalize-ip to function
- ip_address=$(ip a s dev $2 | grep "inet $ip" | awk '{print $2}')
- elif [[ "$3" = "dhcpv6" ]]; then
- lease_file=/var/lib/dhcp/dhclient_v6_"$(echo $2 | sed -e 's/\./_/')".leases;
- ip_address=$(sed -n 's/^\s\s\s\siaaddr\s\(.*\)\s{/\1/p' $lease_file | sed -n '$p');
- else
- ip_address=$3;
- fi
- if [[ "$ip_address" = "" ]]; then
- ip_address='0.0.0.0/0'
- fi
-
- ### T1053 parameter $ip_address needs to be prefixed, not just the IP
- ip_address=$(/usr/libexec/vyos/system/normalize-ip $ip_address)
-
- if ! ip address show dev $2 2>/dev/null | grep -q "$ip_address"; 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 sudo ip -6 addr del "$ip_address" dev "$2"
- else
- exec sudo ip addr del "$ip_address" dev "$2"
- fi ;;
- *)
- echo "Unknown option $1"
- exit 1 ;;
-esac