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

(-)net-scripts/net/dhcpcd.sh (-22 / +44 lines)
Lines 60-101 dhcpcd_stop() { 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" 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
	opts="dhcpcd_${ifvar}"
69
 	eval args=\$dhcpcd_${ifvar}
70
	opts="${dhcpcd} ${!opts}"
70
	[[ -n ${dhcpcd} ]] && args="${dhcpcd} ${args}"
71
72
	# Get generic dhcp options
73
	eval opts=\$dhcp_${ifvar}
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" \
83
		# We transmit the hostname by default
94
					|| args="${args} -N"
84
		if [[ " ${opts} " != *" -h "* ]]; then
95
				;;
85
			local hname=$(hostname)
96
			nonis)
86
			[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
97
				${new} \
87
				&& opts="-h \"${hname}\" ${opts}"
98
					&& args="${args} -C yp.conf" \
88
		fi
99
					|| args="${args} -Y"
100
				;;
101
			nogateway)  args="${args} -G" ;;
102
			nosendhost) args="${args} -h ''" ;;
103
		esac
104
	done
105
106
	# We transmit the hostname by default
107
	if [[ " ${args} " != *" -h "* ]]; then
108
		local hname=$(hostname)
109
		[[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \
110
			&& args="-h \"${hname}\" ${args}"
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

Return to bug 262097