source: bootscripts/lfs/sbin/ifdown@ f874424

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 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 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 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 f874424 was f874424, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Rename /etc/sysconfig/init_params to /etc/sysconfig/rc.site.
Move network services to /lib/services.
Move init-functions to /lib/lsb.
Make /lib/lsb a symlink to /lib/services.
Create convenience symlink /etc/init.d->/etc/rc.d/init.d
Add help and man pages to ifup/ifdown.

Append /run/var/bootlog to /var/log/boot.log at the end of
the boot sequence.

Add capability to step through the boot scripts at boot time.

Optionally allow environment variables in sysconfig directory's
console, network, and clock files to be placed in rc.site.

Add an optional FASTBOOT parameter to set /fastboot when rebooting.

Remove a minor warning message from udev that is triggered
by the udev_retry boot script.

Add SKIPTMPCLEAN as an optional parameter to skip cleaning /tmp at boot time.

Add a page to Chapter 7 documenting rc.site.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9597 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • 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# This will run the service script, if SERVICE is set
71if [ -n "${SERVICE}" -a -x "/lib/services/${SERVICE}" ]; then
72 if ip link show ${IFACE} > /dev/null 2>&1; then
73 IFCONFIG=${file} /lib/services/${SERVICE} ${IFACE} down
74 else
75 log_warning_msg "Interface ${1} doesn't exist."
76 echo_warning
77 fi
78else
79 MSG="Unable to process ${file}. Either "
80 MSG="${MSG}the SERVICE variable was not set"
81 MSG="${MSG}or the specified service cannot be executed."
82 log_failure_msg "$MSG"
83 exit 1
84fi
85
86link_status=`ip link show ${IFACE} 2>/dev/null`
87
88if [ -n "${link_status}" ]; then
89 if [ "$(echo "${link_status}" | grep UP)" != "" ]; then
90 if [ "$(ip addr show ${IFACE} | grep 'inet ')" != "" ]; then
91 log_info_msg "Bringing down the ${IFACE} interface..."
92 ip link set ${IFACE} down
93 evaluate_retval
94 fi
95 fi
96fi
97
98# End /sbin/ifdown
Note: See TracBrowser for help on using the repository browser.