summaryrefslogtreecommitdiff
blob: f978f681cc6383a9aa3be2d206b05662c0daef04 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Copyright (c) 2004-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

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

. "${svclib}/sh/rc-services.sh"

MODULES_DIR="${svclib}/net.modules.d"
. "${MODULES_DIR}/system"
. "${MODULES_DIR}/helpers.d/functions"

conf="$(add_suffix /etc/conf.d/net)"
[[ -e ${conf} ]] && source "${conf}"
conf="$(add_suffix "/etc/conf.d/net.${interface}")"
[[ -e ${conf} ]] && source "${conf}"

# Create some dummy functions, so we can depend on a module
after() { return; }
before() { return; }
need() { return; }
provide() { return; }
installed() { return; }
functions() { return; }
variables() { eval "${MODULE}_variables() { echo \"$*\"; }"; }

# Guess which interface module to load - we prefer iproute2
if [[ -x /sbin/ip ]] ; then
	interface_module="iproute2"
elif [[ -x /sbin/ifconfig ]] ; then
	interface_module="ifconfig"
else
	echo "Can't find a known interface module" >&2
	exit 1
fi

# iwconfig is the best bet for wireless - we use wpa_supplicant
# only if we need to
if [[ -x /sbin/iwconfig ]] ; then
	wireless_module="iwconfig"
elif [[ -x /sbin/wpa_supplicant \
	&& -S "/var/run/wpa_supplicant/${interface}" ]] ; then
	wireless_module="wpa_supplicant"
fi

MODULES=( "system" )

# Load our modules
. "${MODULES_DIR}/${interface_module}"
MODULE="interface"
${interface_module}_depend
function_wrap "${interface_module}" interface

if [[ -e "${MODULES_DIR}/macnet" ]] ; then
	. "${MODULES_DIR}/macnet"
	MODULE="macnet"
	macnet_depend
fi

. "${MODULES_DIR}/system"
MODULE="system"
system_depend

if [[ -n ${wireless_module} ]] ; then
	. "${MODULES_DIR}/${wireless_module}"
	MODULE="${wireless_module}"
	${wireless_module}_depend
	function_wrap "${wireless_module}" wireless
	. "${MODULES_DIR}/essidnet"
fi

# Dummy dhcp
dhcp_variables() { echo "dhcp"; }

# vim:ts=4