aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/ifdown-aliases
blob: 6a310cc7b40ab23e008c7f544a62d0ae3396fccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

# removes aliases of device $1

device=$1
if [ "$device" = "" ]; then
       echo $"usage: $0 <net-device>"
       exit 1
fi

parent_device=$device

cd /etc/sysconfig/network-scripts

. network-functions

# This is the same messy sed script as in the ifup-aliases script.
# Update also ifup-aliases!
eval $(LC_ALL= LANG= /sbin/ifconfig | LC_ALL=C sed -n '
# Alias name: store the number in TMP, ignore the following address if the
# device name does not match.  This may leave a hanging ||, so dummy X=x
# comands are used to ignore a possible previous condition.
/^[^[:space:]]*:[0-9A-Za-z_]*/ {
	s|^\([^:]*\):\([0-9A-Za-z_]*\).*$|X=x; TMP="\2"; [ "$device" != "\1" ] \|\| |p
	b
}
# Non-alias device: always ignore the following address
/^[^[:space:]]/ {
	s|^.*$|X=x; true \|\| |p
	b
}
# Address: Preceded by a device name, which was converted into
#	condition ||
# So this triggers only for $device.
# Add a trailing || (which will be swallowed by X=x) to keep the syntax
# correct.
/inet addr:[0-9]*\.[0-9]*\.[0-9]*\.[0-9]* *Bcast:[0-9.]* *Mask:[0-9.]*/ {
	s|^.*inet addr:\(\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\) *Bcast:\([0-9.]*\) *Mask:\([0-9.]*\).*$|eval "rdev_${TMP}_addr=\1; rdev_${TMP}_mb=\7_\6; rdevip_\2_\3_\4_\5=${TMP}; rdev_LIST=\\"\\$rdev_LIST \\${TMP}\\"; " \|\| |p
	b
}') X=x

for DEVNUM in $rdev_LIST ; do
       ifconfig $parent_device:$DEVNUM down
       do_netreport=yes
done

# notify programs that have requested notification, if we changed anything
if [ -n "$do_netreport" ]; then
       do_netreport
fi