source: bootscripts/lfs/sbin/ifup@ 1fa2099

multilib-10.1 multilib-before-cross
Last change on this file since 1fa2099 was 1fa2099, checked in by Thomas Trepl <thomas@…>, 4 years ago

Initial creation of multilib branch

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@11565 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100755
File size: 3.4 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin /sbin/ifup
4#
5# Description : Interface Up
6#
7# Authors : Nathan Coulson - nathan@linuxfromscratch.org
8# Kevin P. Fleming - kpfleming@linuxfromscratch.org
9# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10#
11# Version : LFS 7.7
12#
13# Notes : The IFCONFIG variable is passed to the SERVICE script
14# in the /lib/services directory, to indicate what file the
15# service should source to get interface specifications.
16#
17########################################################################
18
19up()
20{
21 if ip link show $1 > /dev/null 2>&1; then
22 link_status=`ip link show $1`
23
24 if [ -n "${link_status}" ]; then
25 if ! echo "${link_status}" | grep -q UP; then
26 ip link set $1 up
27 fi
28 fi
29
30 else
31 log_failure_msg "\nInterface ${IFACE} doesn't exist."
32 exit 1
33 fi
34}
35
36RELEASE="7.7"
37
38USAGE="Usage: $0 [ -hV ] [--help] [--version] interface"
39VERSTR="LFS ifup, version ${RELEASE}"
40
41while [ $# -gt 0 ]; do
42 case "$1" in
43 --help | -h) help="y"; break ;;
44
45 --version | -V) echo "${VERSTR}"; exit 0 ;;
46
47 -*) echo "ifup: ${1}: invalid option" >&2
48 echo "${USAGE}" >& 2
49 exit 2 ;;
50
51 *) break ;;
52 esac
53done
54
55if [ -n "$help" ]; then
56 echo "${VERSTR}"
57 echo "${USAGE}"
58 echo
59 cat << HERE_EOF
60ifup is used to bring up a network interface. The interface
61parameter, e.g. eth0 or eth0:2, must match the trailing part of the
62interface specifications file, e.g. /etc/sysconfig/ifconfig.eth0:2.
63
64HERE_EOF
65 exit 0
66fi
67
68file=/etc/sysconfig/ifconfig.${1}
69
70# Skip backup files
71[ "${file}" = "${file%""~""}" ] || exit 0
72
73. /lib/lsb/init-functions
74
75log_info_msg "Bringing up the ${1} interface... "
76
77if [ ! -r "${file}" ]; then
78 log_failure_msg2 "${file} is missing or cannot be accessed."
79 exit 1
80fi
81
82. $file
83
84if [ "$IFACE" = "" ]; then
85 log_failure_msg2 "${file} does not define an interface [IFACE]."
86 exit 1
87fi
88
89# Do not process this service if started by boot, and ONBOOT
90# is not set to yes
91if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
92 log_skip_msg
93 exit 0
94fi
95
96for S in ${SERVICE}; do
97 if [ ! -x "/lib/services/${S}" ]; then
98 MSG="\nUnable to process ${file}. Either "
99 MSG="${MSG}the SERVICE '${S} was not present "
100 MSG="${MSG}or cannot be executed."
101 log_failure_msg "$MSG"
102 exit 1
103 fi
104done
105
106if [ "${SERVICE}" = "wpa" ]; then log_success_msg; fi
107
108# Create/configure the interface
109for S in ${SERVICE}; do
110 IFCONFIG=${file} /lib/services/${S} ${IFACE} up
111done
112
113# Bring up the interface and any components
114for I in $IFACE $INTERFACE_COMPONENTS; do up $I; done
115
116# Set MTU if requested. Check if MTU has a "good" value.
117if test -n "${MTU}"; then
118 if [[ ${MTU} =~ ^[0-9]+$ ]] && [[ $MTU -ge 68 ]] ; then
119 for I in $IFACE $INTERFACE_COMPONENTS; do
120 ip link set dev $I mtu $MTU;
121 done
122 else
123 log_info_msg2 "Invalid MTU $MTU"
124 fi
125fi
126
127# Set the route default gateway if requested
128if [ -n "${GATEWAY}" ]; then
129 if ip route | grep -q default; then
130 log_skip_msg "\n Gateway already setup; skipping."
131 else
132 log_info_msg "Setting up default gateway..."
133 ip route add default via ${GATEWAY} dev ${IFACE}
134 evaluate_retval
135 fi
136fi
137
138# End /sbin/ifup
Note: See TracBrowser for help on using the repository browser.