Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 262097 | Differences between
and this patch

Collapse All | Expand All

(-)dhcpcd.sh.ORIG (-22 / +48 lines)
Lines 60-101 Link Here
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
62
dhcpcd_start() {
62
dhcpcd_start() {
63
	local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid"
63
	local iface="$1" 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
	opts="dhcpcd_${ifvar}"
69
 	eval args=\$dhcpcd_${ifvar}
70
	opts="${dhcpcd} ${!opts}"
70
	[ ! -z "${dhcpcd}" ] && args="${dhcpcd} ${args}"
71
72
	# Get generic dhcp options
73
	eval opts=\$dhcp_${ifvar}
74
	[ -z "${opts}" ] && opts=${dhcp}
75
76
	case "$(dhcpcd --version)" in
77
			"dhcpcd "[123]*) new=false;;
78
			*) new=true;;
79
	esac
71
80
72
	# Map some generic options to dhcpcd
81
	# Map some generic options to dhcpcd
73
	d="dhcp_${ifvar}"
82
	for opt in ${opts}; do
74
	d=" ${!d} "
83
		case "${opt}" in
75
	[[ ${d} == "  " ]] && d=" ${dhcp} "
84
			nodns)
76
	[[ ${d} == *" nodns "* ]] && opts="${opts} -R"
85
				if ${new}; then
77
	[[ ${d} == *" nontp "* ]] && opts="${opts} -N"
86
					args="${args} -C resolv.conf"
78
	[[ ${d} == *" nonis "* ]] && opts="${opts} -Y"
87
				else
79
	[[ ${d} == *" nogateway "* ]] && opts="${opts} -G"
88
					args="${args} -R"
80
	if [[ ${d} == *" nosendhost "* ]] ; then
89
				fi
81
		opts="${opts} -h ''"
90
				;;
82
	else
91
			nontp)
83
		# We transmit the hostname by default
92
				if ${new}; then
84
		if [[ " ${opts} " != *" -h "* ]]; then
93
					args="${args} -C ntp.conf"
85
			local hname=$(hostname)
94
				else
86
			[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
95
					args="${args} -N"
87
				&& opts="-h \"${hname}\" ${opts}"
96
				fi
88
		fi
97
				;;
98
			nonis)
99
				if ${new}; then
100
					args="${args} -C yp.conf"
101
				else
102
					args="${args} -Y"
103
				fi
104
				;;
105
			nogateway) args="${args} -G";;
106
			nosendhost) args="${args} -h ''";;
107
		esac
108
	done
109
110
	# We transmit the hostname by default
111
	if [[ " ${args} " != *" -h "* ]]; then
112
		local hname=$(hostname)
113
		[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
114
			&& args="-h \"${hname}\" ${args}"
89
	fi
115
	fi
90
116
91
	# Add our route metric
117
	# Add our route metric
92
	metric="metric_${ifvar}"
118
	metric="metric_${ifvar}"
93
	[[ -n ${!metric} && ${!metric} != "0" ]] && opts="${opts} -m ${!metric}"
119
	[[ -n ${!metric} && ${!metric} != "0" ]] && args="${args} -m ${!metric}"
94
120
95
	# Bring up DHCP for this interface (or alias)
121
	# Bring up DHCP for this interface (or alias)
96
	ebegin "Running dhcpcd"
122
	ebegin "Running dhcpcd"
97
123
98
	eval /sbin/dhcpcd "${opts}" "${iface}"
124
	eval /sbin/dhcpcd "${args}" "${iface}"
99
	eend $? || return 1
125
	eend $? || return 1
100
126
101
	# DHCP succeeded, show address retrieved
127
	# DHCP succeeded, show address retrieved

Return to bug 262097