blob: 43a6da10f71c8d03d0170f8351d820124b058bf7 (
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
53
54
55
56
57
58
59
60
61
62
63
|
# Copyright (c) 2005-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Roy Marples (uberlord@gentoo.org)
# void rename_depend(void)
#
# Sets up the dependancies for the module
rename_depend() {
after macchanger
before wireless interface
functions interface_exists interface_down interface_del_addresses
}
# void rename_expose(void)
#
# Expose variables that can be configured
rename_expose() {
variables rename
}
# bool rename_pre_start(char *iface)
#
# Checks to see if we have to rename the interface
rename_pre_start() {
local iface="$1" newname="" mac ifvar="$(bash_variable "$1")"
interface_exists "${iface}" || return 0
newname="rename_${ifvar}"
[[ -z ${!newname} || ${iface} == "${!newname}" ]] && return 0
# We cannot rename vlan interfaces as /proc/net/vlan/config always
# returns the old interface name. We don't bail out though as it's
# not critical that the interface gets renamed.
if [[ -d /proc/net/vlan/config ]] ; then
if grep -q "^${iface} " /proc/net/vlan/config ; then
eerror "Cannot rename VLAN interfaces"
return 0
fi
fi
ebegin "Renaming \"${iface}\" to \"${!newname}\""
# Ensure that we have an init script
[[ ! -e "/etc/init.d/net.${!newname}" ]] \
&& ( cd /etc/init.d ; ln -s net.lo "net.${!newname}" )
# Ensure that the interface is down and without any addresses or we
# will not work
interface_del_addresses "${iface}"
interface_down "${iface}"
interface_set_name "${iface}" "${!newname}"
eend $? "Failed to rename interface" || return 1
# Mark us as stopped, start the new interface and bail cleanly
mark_service_stopped "net.${iface}"
einfo "Stopped configuration of ${iface} due to renaming"
service_stopped "net.${!newname}" && start_service "net.${!newname}"
exit 1
}
# vim: set ft=sh ts=4 :
|