summaryrefslogtreecommitdiff
blob: 35b6f63ff034ebedde317c35f5eeb93620ab89c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Copyright (c) 2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# Contributed by Roy Marples (uberlord@gentoo.org)

interface="${1##*/dhcpcd-}"
interface="${interface%%.info}"

if [[ $2 != "up" && $2 != "new" ]]; then
	action="down"
else
	action="up"
fi

. /lib/rcscripts/net.modules.d/helpers.d/module-loader

# Map MAC address variables to interface variables
macnet_pre_start "${interface}" 1>/dev/null

# Map wireless ESSID variables to interface variables
if [[ -n ${wireless_module} ]]; then
	if wireless_check_extensions "${interface}" ; then
		essidnet_pre_start "${interface}" 1>/dev/null
	fi
fi

# Add any search paths if we have any defined
ifvar=$( bash_variable "${interface}" )

if [[ ${action} == "up" ]]; then
	d="dhcp_${ifvar}"
	resolv="${statedir}/${interface}/resolv.conf"

	if [[ " ${!d} " != *" nodns "* ]]; then
		search="dns_search_${ifvar}"
		if [[ -n ${!search} ]]; then
			tmp="${resolv}.$$"
			egrep -v "^[ \t]*(search|domain)[ \t]*" "${resolv}" > "${tmp}"
			echo "search ${!search}" >> "${tmp}" 
			mv "${tmp}" "${resolv}"
		fi
	fi

	system_dns_extra "${interface}" "${resolv}"
fi

# As we override the -c option, we need to call the specified script ourself
opts="dhcpcd_${ifvar}"
exe="${!opts##* -c }"
if [[ -n ${exe} && ${exe} != "${!opts}" ]]; then
	exe="${exe%% *}"
else
	exe="/etc/dhcpc/dhcpcd.exe"
fi
[[ -x ${exe} ]] && ( ${exe} "$@" 1>/dev/null )

. /lib/rcscripts/net.modules.d/helpers.d/dhcp-state

# vim:ts=4