/[vps]/baselayout-vserver/branches/baselayout-1_12/net-scripts/net/ifconfig.sh
Gentoo

Diff of /baselayout-vserver/branches/baselayout-1_12/net-scripts/net/ifconfig.sh

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

Revision 413 Revision 414
236 if [[ -n ${!i} && -z ${config} ]]; then 236 if [[ -n ${!i} && -z ${config} ]]; then
237 # Make sure these get evaluated as arrays 237 # Make sure these get evaluated as arrays
238 local -a aliases=() broadcasts=() netmasks=() 238 local -a aliases=() broadcasts=() netmasks=()
239 239
240 # Start with the primary interface 240 # Start with the primary interface
241 config=( ${!i} ) 241 config=( "${!i}" )
242 242
243 # ..then add aliases 243 # ..then add aliases
244 aliases="alias_${ifvars}" 244 aliases="alias_${ifvars}"
245 aliases=( ${!aliases} ) 245 aliases=( ${!aliases} )
246 broadcasts="broadcast_${ifvar}" 246 broadcasts="broadcast_${ifvar}"
256 [[ ${#inet6[@]} == 1 && ${inet6} == *' '* ]] && inet6=( ${inet6} ) 256 [[ ${#inet6[@]} == 1 && ${inet6} == *' '* ]] && inet6=( ${inet6} )
257 257
258 # Add inet6 addresses to our config if required 258 # Add inet6 addresses to our config if required
259 [[ -n ${inet6} ]] && config=( "${config[@]}" "${inet6[@]}" ) 259 [[ -n ${inet6} ]] && config=( "${config[@]}" "${inet6[@]}" )
260 260
261 # BACKWARD COMPATIBILITY: set the default gateway
262 if [[ ${gateway} == "${iface}/"* ]]; then
263 i="routes_${ifvar}[@]"
264 local -a routes=( "${!i}" )
265
266 # We don't add the old gateway if one has been set in routes_IFACE
267 local gw=true
268 for i in "${routes[@]}"; do
269 [[ ${i} != *"default gw"* ]] && continue
270 gw=false
271 break
272 done
273
274 if ${gw} ; then
275 eval "routes_${ifvar}=( \"default gw \${gateway#*/}\" \"\${routes[@]}\" )"
276 fi
277 fi
278
261 return 0 279 return 0
262} 280}
263 281
264# bool ifconfig_iface_stop(char *interface) 282# bool ifconfig_iface_stop(char *interface)
265# 283#
309# Returns 0 (true) when successful on the primary interface, non-zero 327# Returns 0 (true) when successful on the primary interface, non-zero
310# (false) when the primary interface fails. Aliases are allowed to 328# (false) when the primary interface fails. Aliases are allowed to
311# fail, the routine should still return success to indicate that 329# fail, the routine should still return success to indicate that
312# net.eth0 was successful 330# net.eth0 was successful
313ifconfig_post_start() { 331ifconfig_post_start() {
314 local iface="$1" ifvar=$(bash_variable "$1") routes= x= metric= mtu= cidr= 332 local iface="$1" ifvar=$(bash_variable "$1") x= metric= mtu= cidr=
333 local -a routes=()
315 metric="metric_${ifvar}" 334 metric="metric_${ifvar}"
316 335
317 ifconfig_exists "${iface}" || return 0 336 ifconfig_exists "${iface}" || return 0
318 337
319 # Make sure interface is marked UP 338 # Make sure interface is marked UP
321 340
322 # MTU support 341 # MTU support
323 mtu="mtu_${ifvar}" 342 mtu="mtu_${ifvar}"
324 [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}" 343 [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}"
325 344
326 routes="routes_${ifvar}[@]" 345 x="routes_${ifvar}[@]"
327 routes=( "${!routes}" ) 346 routes=( "${!x}" )
328
329 # BACKWARD COMPATIBILITY: set the default gateway
330 if [[ ${gateway} == "${iface}/"* ]]; then
331 # We don't add the old gateway if one has been set in routes_IFACE
332 local gw=true
333 for x in "${routes[@]}"; do
334 [[ ${x} != *"default gw"* ]] && continue
335 gw=false
336 break
337 done
338 ${gw} && routes=( "${routes[@]}" "default gw ${gateway#*/}" )
339 fi
340 347
341 [[ -z ${routes} ]] && return 0 348 [[ -z ${routes} ]] && return 0
342 349
343 # Add routes for this interface, might even include default gw 350 # Add routes for this interface, might even include default gw
344 einfo "Adding routes" 351 einfo "Adding routes"

Legend:
Removed from v.413  
changed lines
  Added in v.414

  ViewVC Help
Powered by ViewVC 1.1.20