source: bootscripts/clfs/sysconfig/network-devices/ifup@ 0da1215

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 0da1215 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: 3.0 KB
RevLine 
[163a6701]1#!/bin/sh
2########################################################################
3# Begin $network_devices/ifup
4#
5# Description : Interface Up
6#
7# Authors : Nathan Coulson - nathan@linuxfromscratch.org
8# Kevin P. Fleming - kpfleming@linuxfromscratch.org
9#
10# Version : 00.00
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} # All parameters except $1
24 do
25 FILES="${FILES} ${network_devices}/ifconfig.${1}/${file}"
26 done
27elif [ -d "${network_devices}/ifconfig.${1}" ]; then
28 FILES=`echo ${network_devices}/ifconfig.${1}/*`
29else
30 FILES="${network_devices}/ifconfig.${1}"
31fi
32
33boot_mesg "Bringing up the ${1} interface..."
34boot_mesg_flush
35
36# Process each configruation file
37for file in ${FILES}; do
38 # skip backup files
39 if [ "${file}" != "${file%""~""}" ]; then
40 continue
41 fi
42
43 if [ ! -f "${file}" ]; then
44 boot_mesg "${file} is not a network configuration file or directory." ${WARNING}
45 echo_warning
46 continue
47 fi
48
49 (
50 . ${file}
51
52 # Will not process this service if started by boot, and ONBOOT
53 # is not set to yes
54 if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
55 continue
56 fi
57 # Will not process this service if started by hotplug, and
58 # ONHOTPLUG is not set to yes
59 if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then
60 continue
61 fi
62
[efc99f2]63 # This will allow us to assign subinterfaces to our primary
64 if [ "${INTERFACE}" != "" ]; then
65 NET_IF=${INTERFACE}
66 else
67 NET_IF=${1}
68 fi
69
[163a6701]70 if [ -n "${SERVICE}" -a -x "${network_devices}/services/${SERVICE}" ]; then
71 if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
[efc99f2]72 TEST="`ip addr show ${NET_IF} | grep inet | grep ${NET_IF} | cut -f1 -d'/' | cut -f2 -d't' | cut -f2 -d' '`"
[15962fe]73 if [ "$TEST" != "" ]; then
[efc99f2]74 boot_mesg "Interface ${NET_IF} already configured with IP ${TEST}." ${WARNING}
[15962fe]75 echo_warning
76 continue
77 else
[efc99f2]78 if ip link show ${NET_IF} > /dev/null 2>&1; then
79 link_status=`ip link show ${NET_IF} 2> /dev/null | grep ${NET_IF}`
[15962fe]80 if [ -n "${link_status}" ]; then
81 if ! echo "${link_status}" | grep -q UP; then
[efc99f2]82 ip link set ${NET_IF} up
[15962fe]83 fi
[163a6701]84 fi
[15962fe]85 else
[efc99f2]86 boot_mesg "Interface ${NET_IF} doesn't exist." ${WARNING}
[15962fe]87 echo_warning
88 continue
[163a6701]89 fi
90 fi
91 fi
[efc99f2]92 IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${NET_IF} up
[163a6701]93 else
94 boot_mesg "Unable to process ${file}. Either" ${FAILURE}
95 boot_mesg " the SERVICE variable was not set,"
96 boot_mesg " or the specified service cannot be executed."
97 echo_failure
98 continue
99 fi
100 )
101done
102
103# End $network_devices/ifup
Note: See TracBrowser for help on using the repository browser.