source: bootscripts-standard/bootscripts/clfs/sysconfig/network-devices/ifup @ 2167cfe

Last change on this file since 2167cfe was 2167cfe, checked in by William Harrington <kb0iic@…>, 10 years ago

bootscripts are the scripts used for the sysvinit book.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#!/bin/bash
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 configuration 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
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
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
72                                TEST="`ip addr show ${NET_IF} | grep inet | grep ${NET_IF} | cut -f1 -d'/' | cut -f2 -d't' | cut -f2 -d' '`"
73                                if [ "$TEST" != "" ]; then
74                                                boot_mesg "Interface ${NET_IF} already configured with IP ${TEST}." ${WARNING}
75                                                echo_warning
76                                                continue
77                                else
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}`
80                                                if [ -n "${link_status}" ]; then
81                                                        if ! echo "${link_status}" | grep -q UP; then
82                                                                ip link set ${NET_IF} up
83                                                        fi
84                                                fi
85                                        else
86                                                boot_mesg "Interface ${NET_IF} doesn't exist." ${WARNING}
87                                                echo_warning
88                                                continue
89                                        fi
90                                fi
91                        fi
92                        IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${NET_IF} up
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.