/[baselayout]/trunk/net-scripts/net.modules.d/rename
Gentoo

Contents of /trunk/net-scripts/net.modules.d/rename

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1274 - (show annotations) (download)
Mon Jul 4 13:23:16 2005 UTC (13 years, 10 months ago) by uberlord
File size: 1844 byte(s)
dded a rename module to rename interfaces based on MAC address
    (preferred) or current name. Fixes #76328

1 #!/bin/bash
2 # Copyright (c) 2004-2005 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # Contributed by Roy Marples (uberlord@gentoo.org)
6
7 # char* rename_provides(void)
8 #
9 # Returns a string to change module definition for starting up
10 rename_provides() {
11 echo "rename"
12 }
13
14 # void rename_depend(void)
15 #
16 # Sets up the dependancies for the module
17 rename_depend() {
18 before macchanger interface
19 }
20
21 # bool rename_check_installed(void)
22 #
23 # We are always installed
24 rename_check_installed() {
25 return 0
26 }
27
28 # bool rename_check_depends(void)
29 #
30 # Checks to see if we have the needed functions
31 rename_check_depends() {
32 return 0
33 }
34
35 # bool rename_pre_start(char *iface)
36 #
37 # Checks to see if we have to rename the interface
38 rename_pre_start() {
39 local iface="$1" newname="" mac ifvar=$( bash_variable "$1" )
40
41 interface_exists "${iface}" true || return 0
42
43 mac=$( interface_get_mac_address "${iface}" )
44 eval newname=\"\$\{rename_${mac//:/}\}\"
45 [[ -z ${newname} ]] && eval newname=\"\$\{rename_${ifvar}\}\"
46 [[ -z ${newname} || ${iface} == ${newname} ]] && return 0
47
48 ebegin "Renaming \"${iface}\" to \"${newname}\""
49
50 # Ensure that we have an init script
51 [[ ! -e /etc/init.d/net."${newname}" ]] \
52 && ( cd /etc/init.d ; ln -s net.lo "net.${newname}" )
53
54 # Ensure that the interface is down and without any addresses or we
55 # will not work
56 interface_del_addresses "${iface}"
57 interface_down "${iface}"
58 interface_set_name "${iface}" "${newname}"
59 eend $? "Failed to rename interface" || return 1
60
61 # Mark us as stopped, start the new interface and bail cleanly
62 mark_service_stopped "net.${iface}"
63 einfo "Stopped configuration of ${iface} due to renaming"
64 service_stopped "net.${newname}" && start_service "net.${newname}"
65
66 exit 1
67 }

  ViewVC Help
Powered by ViewVC 1.1.20