1 | #!/bin/sh
|
---|
2 | ########################################################################
|
---|
3 | # Begin $NETWORK_DEVICES/ifup
|
---|
4 | #
|
---|
5 | # Description : Interface Up
|
---|
6 | #
|
---|
7 | # Authors : Nathan Coulson - nathan@linuxfromscratch.org
|
---|
8 | # Kevin P. Fleming - kpfleming@linuxfromscratch.org
|
---|
9 | #
|
---|
10 | # Version : 00.00
|
---|
11 | #
|
---|
12 | # Notes : the IFCONFIG variable is passed to the scripts found
|
---|
13 | # in the services directory, to indicate what file the
|
---|
14 | # service should source to get environmental variables.
|
---|
15 | #
|
---|
16 | ########################################################################
|
---|
17 |
|
---|
18 | . /lib/lsb/init-functions
|
---|
19 |
|
---|
20 | # Collect a list of configuration files for our interface
|
---|
21 | if [ -n "${2}" ]; then
|
---|
22 | for file in ${@#$1} # All parameters except $1
|
---|
23 | do
|
---|
24 | FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}"
|
---|
25 | done
|
---|
26 | elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then
|
---|
27 | FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*`
|
---|
28 | else
|
---|
29 | FILES="${NETWORK_DEVICES}/ifconfig.${1}"
|
---|
30 | fi
|
---|
31 |
|
---|
32 | message="Bringing up the ${1} interface..."
|
---|
33 |
|
---|
34 | # Process each configruation file
|
---|
35 | for file in ${FILES}; do
|
---|
36 | # skip backup files
|
---|
37 | if [ "${file}" != "${file%""~""}" ]; then
|
---|
38 | continue
|
---|
39 | fi
|
---|
40 |
|
---|
41 | if [ ! -f "${file}" ]; then
|
---|
42 | log_warning_msg
|
---|
43 | message="${file} is not a network configuration file or directory."
|
---|
44 | log_warning_msg
|
---|
45 | fi
|
---|
46 |
|
---|
47 | (
|
---|
48 | if [ ! -d "${file}" ]; then
|
---|
49 | . ${file}
|
---|
50 | fi
|
---|
51 |
|
---|
52 | # Will not process this service if started by boot, and ONBOOT
|
---|
53 | # is not set to yes
|
---|
54 | if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
|
---|
55 | continue
|
---|
56 | fi
|
---|
57 | # Will not process this service if started by hotplug, and
|
---|
58 | # ONHOTPLUG is not set to yes
|
---|
59 | if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then
|
---|
60 | continue
|
---|
61 | fi
|
---|
62 |
|
---|
63 | if [ -n "${SERVICE}" -a -x "/lib/network-services/${SERVICE}" ]; then
|
---|
64 | if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
|
---|
65 | if ip link show ${1} > /dev/null 2>&1; then
|
---|
66 | link_status=`ip link show ${1}`
|
---|
67 | if [ -n "${link_status}" ]; then
|
---|
68 | if ! echo "${link_status}" | grep -q UP; then
|
---|
69 | ip link set ${1} up
|
---|
70 | evaluate_retval standard
|
---|
71 | fi
|
---|
72 | fi
|
---|
73 | else
|
---|
74 | message="${message}Interface ${1} doesn't exist."
|
---|
75 | log_warning_msg
|
---|
76 | fi
|
---|
77 | fi
|
---|
78 | IFCONFIG=${file} /lib/network-services/${SERVICE} ${1} up
|
---|
79 | if [ "${?}" -eq "0" ]; then
|
---|
80 | if [ ! -d "${file}" -a "${file}" != "${NETWORK_DEVICES}/ifconfig.${1}" ]; then
|
---|
81 | mkdir -p "/run/network/ifconfig.${1}"
|
---|
82 | cp "${file}" "/run/network/ifconfig.${1}"
|
---|
83 | elif [ ! -d "${file}" ]; then
|
---|
84 | cp "${file}" "/run/network/"
|
---|
85 | fi
|
---|
86 | fi
|
---|
87 | else
|
---|
88 | echo -e "${FAILURE}Unable to process ${file}. Either"
|
---|
89 | echo -e "${FAILURE}the SERVICE variable was not set,"
|
---|
90 | echo -e "${FAILURE}or the specified service cannot be executed."
|
---|
91 | message=""
|
---|
92 | log_failure_msg
|
---|
93 | fi
|
---|
94 | )
|
---|
95 | done
|
---|
96 |
|
---|
97 | # End $NETWORK_DEVICES/ifup
|
---|