source: bootscripts/lfs/sysconfig/network-devices/ifdown@ 686a790

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

r5529@server: jim | 2006-09-03 23:05:37 -0700
Add a check to see if the interface is already disabled

  • Property mode set to 100644
File size: 2.8 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 TEST="`ip addr show ${1} | grep inet | cut -f1 -d'/' | cut -f2 -d't' | cut -f2 -d' '`"
68 if [ -z "$TEST" ]; then
69 boot_mesg "Interface ${1} already disabled." ${WARNING}
70 echo_warning
71 continue
72 else
73 if ip link show ${1} > /dev/null 2>&1; then
74 IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${1} down
75 else
76 boot_mesg "Interface ${1} doesn't exist." ${WARNING}
77 echo_warning
78 fi
79 fi
80 else
81 boot_mesg -n "Unable to process ${file}. Either" ${FAILURE}
82 boot_mesg -n " the SERVICE variable was not set,"
83 boot_mesg " or the specified service cannot be executed."
84 echo_failure
85 continue
86 fi
87 )
88done
89
90if [ -z "${2}" ]; then
91 link_status=`ip link show ${1} 2> /dev/null | grep ${1}`
92 if [ -n "${link_status}" ]; then
93 if echo "${link_status}" | grep -q UP; then
94 boot_mesg "Bringing down the ${1} interface..."
95 ip link set ${1} down
96 evaluate_retval
97 fi
98 fi
99fi
100
101# End $network_devices/ifdown
Note: See TracBrowser for help on using the repository browser.