source: projects/initscripts/tags/initscripts-8.91.0/sysconfig/network-scripts/ifup @ 2576

Revision 2576, 4.2 KB checked in by daisuke, 13 years ago (diff)

tagging as initscripts-8.91.0

Line 
1#!/bin/bash
2# Network Interface Configuration System
3# Copyright (c) 1996-2001 Red Hat, Inc. all rights reserved.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License, version 2,
7# as published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17
18unset WINDOW # defined by screen, conflicts with our usage
19
20. /etc/init.d/functions
21
22cd /etc/sysconfig/network-scripts
23. /etc/sysconfig/network-scripts/network-functions
24
25[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
26
27CONFIG=${1}
28
29[ -z "${CONFIG}" ] && {
30    echo $"Usage: ifup <device name>" >&2
31    exit 1
32}
33
34need_config ${CONFIG}
35
36[ -f "${CONFIG}" ] || {
37    echo $"$0: configuration for ${1} not found." >&2
38    echo $"Usage: ifup <device name>" >&2
39    exit 1
40}
41
42if [ ${UID} != 0 ]; then
43    if [ -x /usr/sbin/usernetctl ]; then
44        source_config
45        if /usr/sbin/usernetctl ${CONFIG} report ; then
46            exec /usr/sbin/usernetctl ${CONFIG} up
47        fi
48    fi
49    echo $"Users cannot control this device." >&2
50    exit 1
51fi
52
53source_config
54
55if [ "foo$2" = "fooboot" ] && [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ]
56then
57    exit 0
58fi
59if [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ]
60then
61    exit 0
62fi
63if [ -n "$IN_HOTPLUG" -a "${TYPE}" = "Bridge" ];
64then
65    exit 0
66fi
67
68# Ethernet 802.1Q VLAN support
69if [ -x /sbin/vconfig -a "${VLAN}" = "yes" -a "$ISALIAS" = "no" ]; then
70    VID=""
71    MATCH='^(eth|bond)[0-9]+\.[0-9]{1,4}$'
72    if [[ "${DEVICE}" =~ $MATCH ]]; then
73        VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^[a-z0-9]*\.0*//')
74        PHYSDEV=${DEVICE%.*}
75    fi
76    MATCH='^vlan[0-9]{1,4}?'
77    if [[ "${DEVICE}" =~ $MATCH ]]; then
78        VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^vlan0*//')
79        # PHYSDEV should be set in ifcfg-vlan* file
80        if test -z "$PHYSDEV"; then
81                echo $"PHYSDEV should be set for device ${DEVICE}"
82                exit 1
83        fi
84    fi
85    if [ -n "$VID" ]; then
86        if [ ! -d /proc/net/vlan ]; then
87            if modprobe 8021q >/dev/null 2>&1 ; then
88                test -z "$VLAN_NAME_TYPE" && VLAN_NAME_TYPE=DEV_PLUS_VID_NO_PAD
89                /sbin/vconfig set_name_type "$VLAN_NAME_TYPE" >/dev/null 2>&1 || {
90                    echo $"Could not set 802.1Q VLAN parameters."
91                }
92            else
93                echo $"No 802.1Q VLAN support available in kernel for device ${DEVICE}"
94                exit 1
95            fi
96        fi
97
98        is_available ${PHYSDEV} || {
99            if [ "$?" = "1" ] ; then
100                echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization."
101                exit 1
102            else
103                exit 0
104            fi
105        }
106
107        # Link on Physical device needs to be up but no ip required
108        check_device_down ${PHYSDEV} && {
109            ip -o link set dev ${PHYSDEV} up
110        }
111
112        if [ ! -f /proc/net/vlan/${DEVICE} ]; then
113            /sbin/vconfig add ${PHYSDEV} ${VID} || {
114                (logger -p daemon.info -t ifup \
115                    $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" &)&
116                echo $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}"
117                exit 1
118            }
119        fi
120
121        if [ -f /proc/net/vlan/${DEVICE} ]; then
122            case "$REORDER_HDR" in
123                yes|1)
124                    /sbin/vconfig set_flag ${DEVICE} 1 1 || {
125                        (logger -p daemon.info -t ifup \
126                            "WARNING: vconfig not able to enable REORDER_HDR on ${DEVICE}" &)&
127                    }
128                    ;;
129                no|0)
130                    /sbin/vconfig set_flag ${DEVICE} 1 0 || {
131                        (logger -p daemon.info -t ifup \
132                            $"WARNING: vconfig not able to disable REORDER_HDR on ${DEVICE}" &)&
133                    }
134                    ;;
135            esac
136        fi
137    fi
138fi
139
140# Old BOOTP variable
141if [ "${BOOTP}" = "yes" ]; then
142    BOOTPROTO=bootp
143fi
144
145if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then
146    DYNCONFIG=true
147fi
148
149if [ -x /sbin/ifup-pre-local ]; then
150    /sbin/ifup-pre-local ${CONFIG} $2
151fi
152
153OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"
154
155if [ ! -x ${OTHERSCRIPT} ]; then
156    OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
157fi
158
159exec ${OTHERSCRIPT} ${CONFIG} $2
160
161
Note: See TracBrowser for help on using the repository browser.