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

Diff of /trunk/net-scripts/net.modules.d/helpers.d/dhcp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1246 Revision 1247
24 24
25# iwconfig is the best bet for wireless - we use wpa_supplicant 25# iwconfig is the best bet for wireless - we use wpa_supplicant
26# only if we need to 26# only if we need to
27if [[ -x /usr/sbin/iwconfig ]]; then 27if [[ -x /usr/sbin/iwconfig ]]; then
28 wireless_module="iwconfig" 28 wireless_module="iwconfig"
29elif [[ -x /usr/sbin/wpa_supplicant && -S "/var/run/wpa_supplicant/${interface}" ]]; then 29elif [[ -x /usr/sbin/wpa_supplicant \
30 && -S "/var/run/wpa_supplicant/${interface}" ]]; then
30 wireless_module="wpa_supplicant" 31 wireless_module="wpa_supplicant"
31fi 32fi
32 33
33# Load our modules 34# Load our modules
34. "${MODULES_DIR}/${interface_module}" 35. "${MODULES_DIR}/${interface_module}"
75 76
76MODULES=( "system" ) 77MODULES=( "system" )
77 78
78# Map MAC address variables to interface variables 79# Map MAC address variables to interface variables
79. "${MODULES_DIR}/macnet" 80. "${MODULES_DIR}/macnet"
80macnet_pre_start ${interface} 81macnet_pre_start "${interface}"
81 82
82# Map wireless ESSID variables to interface variables 83# Map wireless ESSID variables to interface variables
83if [[ $( type -t wireless_check_extensions ) == "function" ]]; then 84if [[ $( type -t wireless_check_extensions ) == "function" ]]; then
84 if wireless_check_extensions "${interface}" ; then 85 if wireless_check_extensions "${interface}" ; then
85 . "${MODULES_DIR}/essidnet" 86 . "${MODULES_DIR}/essidnet"
86 essidnet_pre_start ${interface} 87 essidnet_pre_start "${interface}"
87 fi 88 fi
88fi 89fi
89 90
90# Calculate the metric for our routes 91# Calculate the metric for our routes
91ifvar=$( bash_variable ${interface} ) 92ifvar=$( bash_variable "${interface}" )
92eval metric=\"\$\{metric_${ifvar}\}\" 93eval metric=\"\$\{metric_${ifvar}\}\"
93if [[ -z ${metric} ]]; then 94if [[ -z ${metric} ]]; then
94 if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then 95 if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
95 metric=$( calculate_metric ${interface} ) 96 metric=$( calculate_metric "${interface}" )
96 else 97 else
97 metric=0 98 metric=0
98 fi 99 fi
99 eval metric_${ifvar}="${metric}" 100 eval metric_${ifvar}="${metric}"
100fi 101fi
101 102
102# Configure our IP address 103# Configure our IP address
103ip=${ip// } 104ip="${ip// }"
104subnet=${subnet// } 105subnet="${subnet// }"
105cidr=$( netmask2cidr ${subnet} ) 106cidr=$( netmask2cidr "${subnet}" )
106broadcast=${broadcast// } 107broadcast="${broadcast// }"
107[[ -n ${broadcast} ]] && broadcast="broadcast ${broadcast}" 108[[ -n ${broadcast} ]] && broadcast="broadcast ${broadcast}"
108 109
109# If we don't have our address then we flush it and then add our new one 110# If we don't have our address then we flush it and then add our new one
110curip=$( interface_get_address ${interface} ) 111curip=$( interface_get_address "${interface}" )
111if [[ ${curip} != "${ip}/${cidr}" ]] ; then 112if [[ ${curip} != "${ip}/${cidr}" ]] ; then
112 interface_del_addresses ${interface} 113 interface_del_addresses "${interface}"
113 interface_add_address ${interface} "${ip}/${cidr}" ${broadcast} 114 interface_add_address "${interface}" "${ip}/${cidr}" "${broadcast}"
114fi 115fi
115 116
116# Store the address in a cache for future usage 117# Store the address in a cache for future usage
117echo ${ip} > /var/cache/dhcp-${interface}.lease 118echo "${ip}" > "/var/cache/dhcp-${interface}.lease"
118chmod 600 /var/cache/dhcp-${interface}.lease 119chmod 600 "/var/cache/dhcp-${interface}.lease"
119 120
120# Configure our default route - we only have 1 default route 121# Configure our default route - we only have 1 default route
121for r in ${router}; do 122for r in ${router}; do
122 interface_default_route ${interface} ${r} ${metric:-0} && break 123 interface_default_route "${interface}" "${r}" "${metric:-0}" && break
123done 124done
124 125
125# Configure our hostname - but only if we need it 126# Configure our hostname - but only if we need it
126if [[ -n ${hostname} ]]; then 127if [[ -n ${hostname} ]]; then
127 x=$( /bin/hostname ) 128 x=$( /bin/hostname )
136[[ ${dhcp} != *' nodns '* ]] && system_dns "${interface}" 137[[ ${dhcp} != *' nodns '* ]] && system_dns "${interface}"
137[[ ${dhcp} != *' nontp '* ]] && system_ntp "${interface}" 138[[ ${dhcp} != *' nontp '* ]] && system_ntp "${interface}"
138[[ ${dhcp} != *' nonis '* ]] && system_nis "${interface}" 139[[ ${dhcp} != *' nonis '* ]] && system_nis "${interface}"
139 140
140if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then 141if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then
141 # save_state ${interface}
142 best_interface=$( select_best_interface ) 142 best_interface=$( select_best_interface )
143 apply_state "${best_interface}" 143 apply_state "${best_interface}"
144else 144else
145 apply_state "${interface}" 145 apply_state "${interface}"
146fi 146fi
147 147
148mark_service_started net.${interface} 148mark_service_started "net.${interface}"
149 149
150echo "${action}" 150echo "${action}"
151exit 0 151exit 0

Legend:
Removed from v.1246  
changed lines
  Added in v.1247

  ViewVC Help
Powered by ViewVC 1.1.20