source: bootscripts/lfs/sbin/ifdown@ a44ae577

11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 arm bdubbs/gcc13 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since a44ae577 was a44ae577, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove spaces at end of lines - bootscripts

  • Property mode set to 100755
File size: 2.6 KB
Line 
1#!/bin/bash
2########################################################################
3# Begin /sbin/ifdown
4#
5# Description : Interface Down
6#
7# Authors : Nathan Coulson - nathan@linuxfromscratch.org
8# Kevin P. Fleming - kpfleming@linuxfromscratch.org
9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10#
11# Version : LFS 7.0
12#
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.
16#
17########################################################################
18
19RELEASE="7.0"
20
21USAGE="Usage: $0 [ -hV ] [--help] [--version] interface"
22VERSTR="LFS ifdown, version ${RELEASE}"
23
24while [ $# -gt 0 ]; do
25 case "$1" in
26 --help | -h) help="y"; break ;;
27
28 --version | -V) echo "${VERSTR}"; exit 0 ;;
29
30 -*) echo "ifup: ${1}: invalid option" >&2
31 echo "${USAGE}" >& 2
32 exit 2 ;;
33
34 *) break ;;
35 esac
36done
37
38if [ -n "$help" ]; then
39 echo "${VERSTR}"
40 echo "${USAGE}"
41 echo
42 cat << HERE_EOF
43ifdown is used to bring down a network interface. The interface
44parameter, e.g. eth0 or eth0:2, must match the trailing part of the
45interface specifications file, e.g. /etc/sysconfig/ifconfig.eth0:2.
46
47HERE_EOF
48 exit 0
49fi
50
51file=/etc/sysconfig/ifconfig.${1}
52
53# Skip backup files
54[ "${file}" = "${file%""~""}" ] || exit 0
55
56. /lib/lsb/init-functions
57
58if [ ! -r "${file}" ]; then
59 log_warning_msg "${file} is missing or cannot be accessed."
60 exit 1
61fi
62
63. ${file}
64
65if [ "$IFACE" = "" ]; then
66 log_failure_msg "${file} does not define an interface [IFACE]."
67 exit 1
68fi
69
70# We only need to first service to bring down the interface
71S=`echo ${SERVICE} | cut -f1 -d" "`
72
73if 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
76 else
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"
81 exit 1
82 fi
83else
84 log_warning_msg "Interface ${1} doesn't exist."
85fi
86
87# Leave the interface up if there are additional interfaces in the device
88link_status=`ip link show ${IFACE} 2>/dev/null`
89
90if [ -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
95 evaluate_retval
96 fi
97 fi
98fi
99
100# End /sbin/ifdown
Note: See TracBrowser for help on using the repository browser.