source: bootscripts/clfs/sysconfig/network-devices/ifdown@ c4b9677

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

Added the ability to have network subinterfaces

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