| 1 | #!/bin/bash |
1 | #!/bin/bash |
| 2 | # Copyright (c) 2004-2005 Gentoo Foundation |
2 | # Copyright (c) 2005 Gentoo Foundation |
| 3 | # Distributed under the terms of the GNU General Public License v2 |
3 | # Distributed under the terms of the GNU General Public License v2 |
| 4 | |
4 | |
| 5 | # Contributed by Roy Marples (uberlord@gentoo.org) |
5 | # Contributed by Roy Marples (uberlord@gentoo.org) |
| 6 | |
6 | |
| 7 | . /lib/rcscripts/net.modules.d/helpers.d/module-loader |
7 | MODULES_DIR="/lib/rcscripts/net.modules.d" |
|
|
8 | . /lib/rcscripts/sh/rc-services.sh |
|
|
9 | . "${MODULES_DIR}/helpers.d/functions" |
|
|
10 | conf=$(add_suffix "/etc/conf.d/net") |
|
|
11 | [[ -e ${conf} ]] && source "${conf}" |
| 8 | |
12 | |
| 9 | service="net.${interface}" |
13 | service="net.${interface}" |
| 10 | |
14 | |
| 11 | if [[ ${action} != "up" ]]; then |
15 | if [[ ${action} != "up" ]]; then |
| 12 | if service_starting "${service}" || service_started "${service}" ; then |
16 | if service_starting "${service}" || service_started "${service}" ; then |
| 13 | mark_service_inactive "${service}" |
17 | mark_service_inactive "${service}" |
| 14 | fi |
18 | fi |
| 15 | remove_state "${interface}" false |
19 | remove_state "${interface}" false |
| 16 | if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then |
20 | else |
| 17 | best_interface=$( select_best_interface ) |
21 | ! service_stopping "${service}" && mark_service_started "${service}" |
| 18 | apply_state "${best_interface}" |
|
|
| 19 | fi |
|
|
| 20 | exit 0 |
|
|
| 21 | fi |
22 | fi |
| 22 | |
23 | |
| 23 | # Map MAC address variables to interface variables |
24 | if [[ ${RC_AUTO_INTERFACE} == "yes" ]]; then |
| 24 | macnet_pre_start "${interface}" 1>/dev/null |
25 | best_interface=$( select_best_interface ) |
| 25 | |
26 | apply_state "${best_interface}" |
| 26 | # Map wireless ESSID variables to interface variables |
|
|
| 27 | if [[ -n ${wireless_module} ]]; then |
|
|
| 28 | if wireless_check_extensions "${interface}" ; then |
|
|
| 29 | essidnet_pre_start "${interface}" 1>/dev/null |
|
|
| 30 | fi |
|
|
| 31 | fi |
27 | fi |
| 32 | |
|
|
| 33 | # Add any search domains if we have any defined |
|
|
| 34 | ifvar=$( bash_variable "${interface}" ) |
|
|
| 35 | eval d=\" \$\{dhcp_${ifvar}\} \" |
|
|
| 36 | [[ ${d} == " " ]] && d=" ${dhcp} " |
|
|
| 37 | |
|
|
| 38 | if [[ ${d} != *" nodns "* ]]; then |
|
|
| 39 | eval search=\"\$\{dns_search_domains_${ifvar}\}\" |
|
|
| 40 | if [[ -n ${search} ]]; then |
|
|
| 41 | resolv="${statedir}/${interface}/resolv.conf" |
|
|
| 42 | tmp="${revolv}.$$" |
|
|
| 43 | egrep -v "^[ \t]*search" "${resolv}" > "${tmp}" |
|
|
| 44 | domain=$( sed -n -e 's/^[ \t]*domain[ \t]*\(.*\)[ \t]*.*/\1/p' ${tmp} ) |
|
|
| 45 | echo "search ${domain} ${search}" >> "${tmp}" |
|
|
| 46 | mv "${tmp}" "${resolv}" |
|
|
| 47 | fi |
|
|
| 48 | fi |
|
|
| 49 | |
|
|
| 50 | ! service_stopping "${service}" && mark_service_started "${service}" |
|
|
| 51 | |
|
|
| 52 | [[ ${RC_AUTO_INTERFACE} == "yes" ]] && interface=$( select_best_interface ) |
|
|
| 53 | apply_state "${interface}" |
|
|