/[vps]/baselayout-vserver/trunk/lib/rcscripts/net.modules.d/rename
Gentoo

Contents of /baselayout-vserver/trunk/lib/rcscripts/net.modules.d/rename

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download)
Sat Sep 3 16:10:27 2005 UTC (9 years, 3 months ago) by hollow
File size: 2184 byte(s)
import initial baselayout sources (1.12.0_pre8)
1 #!/bin/bash
2 # Copyright (c) 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 after macchanger macnet
19 before wireless interface
20 }
21
22 # bool rename_check_installed(void)
23 #
24 # We are always installed
25 rename_check_installed() {
26 return 0
27 }
28
29 # bool rename_check_depends(void)
30 #
31 # Checks to see if we have the needed functions
32 rename_check_depends() {
33 return 0
34 }
35
36 # char* rename_get_vars(char *interface)
37 #
38 # Returns a string spaced with possible user set
39 # configuration variables
40 rename_get_vars() {
41 echo "rename_$1"
42 }
43
44 # bool rename_pre_start(char *iface)
45 #
46 # Checks to see if we have to rename the interface
47 rename_pre_start() {
48 local iface="$1" newname="" mac ifvar=$( bash_variable "$1" )
49
50 interface_exists "${iface}" || return 0
51
52 eval newname=\"\$\{rename_${ifvar}\}\"
53 [[ -z ${newname} || ${iface} == "${newname}" ]] && return 0
54
55 # We cannot rename vlan interfaces as /proc/net/vlan/config always
56 # returns the old interface name. We don't bail out though as it's
57 # not critical that the interface gets renamed.
58 if [[ -d /proc/net/vlan/config ]] ; then
59 if grep -q "^eth0.2 " /proc/net/vlan/config ; then
60 eerror "Cannot rename VLAN interfaces"
61 return 0
62 fi
63 fi
64
65 ebegin "Renaming \"${iface}\" to \"${newname}\""
66
67 # Ensure that we have an init script
68 [[ ! -e "/etc/init.d/net.${newname}" ]] \
69 && ( cd /etc/init.d ; ln -s net.lo "net.${newname}" )
70
71 # Ensure that the interface is down and without any addresses or we
72 # will not work
73 interface_del_addresses "${iface}"
74 interface_down "${iface}"
75 interface_set_name "${iface}" "${newname}"
76 eend "$?" "Failed to rename interface" || return 1
77
78 # Mark us as stopped, start the new interface and bail cleanly
79 mark_service_stopped "net.${iface}"
80 einfo "Stopped configuration of ${iface} due to renaming"
81 service_stopped "net.${newname}" && start_service "net.${newname}"
82
83 exit 1
84 }
85
86 # vim:ts=4

  ViewVC Help
Powered by ViewVC 1.1.20