]>
Commit | Line | Data |
---|---|---|
7742e157 AF |
1 | #!/bin/bash |
2 | ||
3 | # adds aliases of device $1 | |
4 | ||
5 | if [ "$1" = "" ]; then | |
6 | echo "usage: $0 <net-device>" | |
7 | exit 1 | |
8 | fi | |
9 | ||
10 | if [ -x /bin/linuxconf ] ; then | |
11 | # ask linuxconf for lines like: | |
12 | # add <device> <ip> | |
13 | # del <device> | |
14 | # reload <number_of_aliases> | |
15 | linuxconf --hint ipalias $1 | while read verb arg1 arg2 ; do | |
16 | case $verb in | |
17 | add) | |
18 | /sbin/ifconfig $arg1 $arg2 | |
19 | /sbin/route add $arg2 $arg1 | |
20 | ;; | |
21 | del) | |
22 | # the <device>- 0.0.0.0 tells the kernel to remove the device | |
23 | # it is necessary to remove it in order for reload to work. | |
24 | /sbin/ifconfig ${arg1}- 0.0.0.0 | |
25 | ;; | |
26 | reload) | |
27 | echo $arg1 > /proc/sys/net/core/net_alias_max | |
28 | ;; | |
29 | esac | |
30 | done | |
31 | ||
32 | else | |
33 | # we don't have linuxconf to fall back on, so presumably we do | |
34 | # not have to parse linuxconf ipalias ranges, either. | |
35 | allow_null_glob_expansion=foo | |
36 | for alias in /etc/sysconfig/network-scripts/ifcfg-$1:* ; do | |
37 | /etc/sysconfig/network-scripts/ifup $alias | |
38 | done | |
39 | unset allow_null_glob_expansion | |
40 | fi |