source: bootscripts/lfs/sysconfig/network-devices/ifdown@ 18d0acd

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 18d0acd was f5573ef, checked in by Jim Gifford <clfs@…>, 18 years ago

r5255@server: jim | 2006-08-27 21:00:26 -0700
Added the same logic fix to ifdown, that jeremy added to ifup

  • Property mode set to 100644
File size: 2.6 KB
Line 
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. /etc/sysconfig/rc
19. ${rc_functions}
20
21# Collect a list of configuration files for our interface
22if [ -n "${2}" ]; then
23 for file in ${@#$1}; do # All parameters except $1
24 FILES="${FILES} ${network_devices}/ifconfig.${1}/${file}"
25 done
26elif [ -d "${network_devices}/ifconfig.${1}" ]; then
27 FILES=`echo ${network_devices}/ifconfig.${1}/*`
28else
29 FILES="${network_devices}/ifconfig.${1}"
30fi
31
32# Reverse the order configuration files are processed in
33for file in ${FILES}; do
34 FILES2="${file} ${FILES2}"
35done
36FILES=${FILES2}
37
38# Process each configuration file
39for file in ${FILES}; do
40 # skip backup files
41 if [ "${file}" != "${file%""~""}" ]; then
42 continue
43 fi
44
45 if [ ! -f "${file}" ]; then
46 boot_mesg "${file} is not a network configuration file or directory." ${WARNING}
47 echo_warning
48 continue
49 fi
50 (
51 . ${file}
52
53 # Will not process this service if started by boot, and ONBOOT
54 # is not set to yes
55 if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
56 continue
57 fi
58
59 # Will not process this service if started by hotplug, and
60 # ONHOTPLUG is not set to yes
61 if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" ]; then
62 continue
63 fi
64
65 # This will run the service script, if SERVICE is set
66 if [ -n "${SERVICE}" -a -x "${network_devices}/services/${SERVICE}" ]; then
67 if ip link show ${1} > /dev/null 2>&1
68 then
69 IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${1} down
70 else
71 boot_mesg "Interface ${1} doesn't exist." ${WARNING}
72 echo_warning
73 fi
74 else
75 boot_mesg -n "Unable to process ${file}. Either" ${FAILURE}
76 boot_mesg -n " the SERVICE variable was not set,"
77 boot_mesg " or the specified service cannot be executed."
78 echo_failure
79 continue
80 fi
81 )
82done
83
84if [ -z "${2}" ]; then
85 link_status=`ip link show ${1} 2> /dev/null | grep ${1}`
86 if [ -n "${link_status}" ]; then
87 if echo "${link_status}" | grep -q UP; then
88 boot_mesg "Bringing down the ${1} interface..."
89 ip link set ${1} down
90 evaluate_retval
91 fi
92 fi
93fi
94
95# End $network_devices/ifdown
Note: See TracBrowser for help on using the repository browser.