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 | |
---|
18 | unset WINDOW # defined by screen, conflicts with our usage |
---|
19 | |
---|
20 | . /etc/init.d/functions |
---|
21 | |
---|
22 | cd /etc/sysconfig/network-scripts |
---|
23 | . ./network-functions |
---|
24 | |
---|
25 | [ -f ../network ] && . ../network |
---|
26 | |
---|
27 | CONFIG=${1} |
---|
28 | |
---|
29 | [ -z "${CONFIG}" ] && { |
---|
30 | echo $"Usage: ifup <device name>" >&2 |
---|
31 | exit 1 |
---|
32 | } |
---|
33 | |
---|
34 | need_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 | |
---|
42 | if [ ${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 |
---|
51 | fi |
---|
52 | |
---|
53 | source_config |
---|
54 | |
---|
55 | if [ "foo$2" = "fooboot" ] && [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] |
---|
56 | then |
---|
57 | exit 0 |
---|
58 | fi |
---|
59 | if [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ] |
---|
60 | then |
---|
61 | exit 0 |
---|
62 | fi |
---|
63 | if [ -n "$IN_HOTPLUG" -a "${TYPE}" = "Bridge" ]; |
---|
64 | then |
---|
65 | exit 0 |
---|
66 | fi |
---|
67 | |
---|
68 | # Ethernet 802.1Q VLAN support |
---|
69 | if [ -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 |
---|
138 | fi |
---|
139 | |
---|
140 | # Old BOOTP variable |
---|
141 | if [ "${BOOTP}" = "yes" ]; then |
---|
142 | BOOTPROTO=bootp |
---|
143 | fi |
---|
144 | |
---|
145 | if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then |
---|
146 | DYNCONFIG=true |
---|
147 | fi |
---|
148 | |
---|
149 | if [ -x /sbin/ifup-pre-local ]; then |
---|
150 | /sbin/ifup-pre-local ${CONFIG} $2 |
---|
151 | fi |
---|
152 | |
---|
153 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" |
---|
154 | |
---|
155 | if [ ! -x ${OTHERSCRIPT} ]; then |
---|
156 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth" |
---|
157 | fi |
---|
158 | |
---|
159 | exec ${OTHERSCRIPT} ${CONFIG} $2 |
---|
160 | |
---|
161 | |
---|