1 | #!/bin/sh
|
---|
2 | ########################################################################
|
---|
3 | # Begin $NETWORK_DEVICES/ifdown
|
---|
4 | #
|
---|
5 | # Description : Interface Down
|
---|
6 | #
|
---|
7 | # Authors : Nathan Coulson - nathan@linuxfromscratch.org
|
---|
8 | # Kevin P. Fleming - kpfleming@linuxfromscratch.org
|
---|
9 | #
|
---|
10 | # Version : 00.01
|
---|
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}; do # All parameters except $1
|
---|
23 | FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}"
|
---|
24 | done
|
---|
25 | elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then
|
---|
26 | FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*`
|
---|
27 | else
|
---|
28 | FILES="${NETWORK_DEVICES}/ifconfig.${1}"
|
---|
29 | fi
|
---|
30 |
|
---|
31 | # Reverse the order configuration files are processed in
|
---|
32 | for file in ${FILES}; do
|
---|
33 | FILES2="${file} ${FILES2}"
|
---|
34 | done
|
---|
35 | FILES=${FILES2}
|
---|
36 |
|
---|
37 | # Process each configuration file
|
---|
38 | for file in ${FILES}; do
|
---|
39 | # skip backup files
|
---|
40 | if [ "${file}" != "${file%""~""}" ]; then
|
---|
41 | continue
|
---|
42 | fi
|
---|
43 |
|
---|
44 | if [ ! -f "${file}" ]; then
|
---|
45 | message="${file} is not a network configuration file or directory."
|
---|
46 | log_warning_msg
|
---|
47 | fi
|
---|
48 | (
|
---|
49 | . ${file}
|
---|
50 |
|
---|
51 | # Will not process this service if started by boot, and ONBOOT
|
---|
52 | # is not set to yes
|
---|
53 | if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
|
---|
54 | continue
|
---|
55 | fi
|
---|
56 |
|
---|
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" ]; then
|
---|
60 | continue
|
---|
61 | fi
|
---|
62 |
|
---|
63 | # This will run the service script, if SERVICE is set
|
---|
64 | if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then
|
---|
65 | if ip link show ${1} > /dev/null 2>&1
|
---|
66 | then
|
---|
67 | IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} down
|
---|
68 | else
|
---|
69 | message="Interface ${1} doesn't exist."
|
---|
70 | log_warning_msg
|
---|
71 | fi
|
---|
72 | else
|
---|
73 | echo -e "${FAILURE}Unable to process ${file}. Either"
|
---|
74 | echo -e "${FAILURE}the SERVICE variable was not set,"
|
---|
75 | echo -e "${FAILURE}or the specified service cannot be executed."
|
---|
76 | message=""
|
---|
77 | log_failure_msg
|
---|
78 | fi
|
---|
79 | )
|
---|
80 | done
|
---|
81 |
|
---|
82 | if [ -z "${2}" ]; then
|
---|
83 | link_status=`ip link show $1`
|
---|
84 | if [ -n "${link_status}" ]; then
|
---|
85 | if echo "${link_status}" | grep -q UP; then
|
---|
86 | message="Bringing down the ${1} interface..."
|
---|
87 | ip link set ${1} down
|
---|
88 | evaluate_retval standard
|
---|
89 | fi
|
---|
90 | fi
|
---|
91 | fi
|
---|
92 |
|
---|
93 | # End $NETWORK_DEVICES/ifdown
|
---|