/[baselayout]/branches/baselayout-1_12/net-scripts/net/dhcpcd.sh
Gentoo

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

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

Revision 3175 Revision 3176
58# 58#
59# Start DHCP on an interface by calling dhcpcd $iface $options 59# Start DHCP on an interface by calling dhcpcd $iface $options
60# 60#
61# Returns 0 (true) when a DHCP address is obtained, otherwise 1 61# Returns 0 (true) when a DHCP address is obtained, otherwise 1
62dhcpcd_start() { 62dhcpcd_start() {
63 local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid" 63 local iface="$1" opt= opts= new= args= pidfile="/var/run/dhcpcd-$1.pid"
64 local ifvar=$(bash_variable "${iface}") metric= d= 64 local ifvar=$(bash_variable "${iface}") metric= d=
65 65
66 interface_exists "${iface}" true || return 1 66 interface_exists "${iface}" true || return 1
67 67
68 # Get our options 68 # Get dhcpcd options
69 eval args=\$dhcpcd_${ifvar}
70 [[ -n ${dhcpcd} ]] && args="${dhcpcd} ${args}"
71
72 # Get generic dhcp options
69 opts="dhcpcd_${ifvar}" 73 eval opts=\$dhcp_${ifvar}
70 opts="${dhcpcd} ${!opts}" 74 [[ -z ${opts} ]] && opts=${dhcp}
75
76 # Figure out which version of dhcpcd we have so we know
77 # which style of option to use
78 case $(dhcpcd --version) in
79 "dhcpcd "[123]*) new=false ;;
80 *) new=true ;;
81 esac
71 82
72 # Map some generic options to dhcpcd 83 # Map some generic options to dhcpcd
73 d="dhcp_${ifvar}" 84 for opt in ${opts} ; do
74 d=" ${!d} " 85 case "${opt}" in
75 [[ ${d} == " " ]] && d=" ${dhcp} " 86 nodns)
76 [[ ${d} == *" nodns "* ]] && opts="${opts} -R" 87 ${new} \
77 [[ ${d} == *" nontp "* ]] && opts="${opts} -N" 88 && args="${args} -C resolv.conf" \
78 [[ ${d} == *" nonis "* ]] && opts="${opts} -Y" 89 || args="${args} -R"
79 [[ ${d} == *" nogateway "* ]] && opts="${opts} -G" 90 ;;
80 if [[ ${d} == *" nosendhost "* ]] ; then 91 nontp)
81 opts="${opts} -h ''" 92 ${new} \
82 else 93 && args="${args} -C ntp.conf" \
94 || args="${args} -N"
95 ;;
96 nonis)
97 ${new} \
98 && args="${args} -C yp.conf" \
99 || args="${args} -Y"
100 ;;
101 nogateway) args="${args} -G" ;;
102 nosendhost) args="${args} -h ''" ;;
103 esac
104 done
105
83 # We transmit the hostname by default 106 # We transmit the hostname by default
84 if [[ " ${opts} " != *" -h "* ]]; then 107 if [[ " ${args} " != *" -h "* ]]; then
85 local hname=$(hostname) 108 local hname=$(hostname)
86 [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ 109 [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
87 && opts="-h \"${hname}\" ${opts}" 110 && args="-h \"${hname}\" ${args}"
88 fi
89 fi 111 fi
90 112
91 # Add our route metric 113 # Add our route metric
92 metric="metric_${ifvar}" 114 metric="metric_${ifvar}"
93 [[ -n ${!metric} && ${!metric} != "0" ]] && opts="${opts} -m ${!metric}" 115 [[ -n ${!metric} && ${!metric} != "0" ]] && args="${args} -m ${!metric}"
94 116
95 # Bring up DHCP for this interface (or alias) 117 # Bring up DHCP for this interface (or alias)
96 ebegin "Running dhcpcd" 118 ebegin "Running dhcpcd"
97 119
98 eval /sbin/dhcpcd "${opts}" "${iface}" 120 eval /sbin/dhcpcd "${args}" "${iface}"
99 eend $? || return 1 121 eend $? || return 1
100 122
101 # DHCP succeeded, show address retrieved 123 # DHCP succeeded, show address retrieved
102 local addr=$(interface_get_address "${iface}") 124 local addr=$(interface_get_address "${iface}")
103 einfo "${iface} received address ${addr}" 125 einfo "${iface} received address ${addr}"

Legend:
Removed from v.3175  
changed lines
  Added in v.3176

  ViewVC Help
Powered by ViewVC 1.1.20