2 ########################################################################
5 # Description : Interface Down
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Kevin P. Fleming - kpfleming@linuxfromscratch.org
9 # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
13 # Notes : the IFCONFIG variable is passed to the scripts found
14 # in the /lib/services directory, to indicate what file the
15 # service should source to get interface specifications.
17 ########################################################################
21 USAGE
="Usage: $0 [ -hV ] [--help] [--version] interface"
22 VERSTR
="LFS ifdown, version ${RELEASE}"
24 while [ $# -gt 0 ]; do
26 --help |
-h) help="y"; break ;;
28 --version |
-V) echo "${VERSTR}"; exit 0 ;;
30 -*) echo "ifup: ${1}: invalid option" >&2
38 if [ -n "$help" ]; then
43 ifdown is used to bring down a network interface. The interface
44 parameter, e.g. eth0 or eth0:2, must match the trailing part of the
45 interface specifications file, e.g. /etc/sysconfig/ifconfig.eth0:2.
51 file=/etc
/sysconfig
/ifconfig.
${1}
54 [ "${file}" = "${file%""~""}" ] ||
exit 0
56 .
/lib
/lsb
/init-functions
58 if [ ! -r "${file}" ]; then
59 log_warning_msg
"${file} is missing or cannot be accessed."
65 if [ "$IFACE" = "" ]; then
66 log_failure_msg
"${file} does not define an interface [IFACE]."
70 # We only need to first service to bring down the interface
71 S
=`echo ${SERVICE} | cut -f1 -d" "`
73 if ip link show
${IFACE} > /dev
/null
2>&1; then
74 if [ -n "${S}" -a -x "/lib/services/${S}" ]; then
75 IFCONFIG
=${file} /lib/services/${S} ${IFACE} down
77 MSG
="Unable to process ${file}. Either "
78 MSG
="${MSG}the SERVICE variable was not set "
79 MSG
="${MSG}or the specified service cannot be executed."
80 log_failure_msg
"$MSG"
84 log_warning_msg
"Interface ${1} doesn't exist."
87 # Leave the interface up if there are additional interfaces in the device
88 link_status
=`ip link show ${IFACE} 2>/dev/null`
90 if [ -n "${link_status}" ]; then
91 if [ "$(echo "${link_status}" | grep UP)" != "" ]; then
92 if [ "$(ip addr show ${IFACE} | grep 'inet ')" == "" ]; then
93 log_info_msg
"Bringing down the ${IFACE} interface..."
94 ip link
set ${IFACE} down