Rewrite bootscripts and Chaper 7
[linux_from_scratch.git] / bootscripts / lfs / sysconfig / network-devices / ifup
blob3049a5c3db899721048395925779ecc007a746ad
1 #!/bin/sh
2 ########################################################################
3 # Begin /sbin/ifup
5 # Description : Interface Up
7 # Authors : Nathan Coulson - nathan@linuxfromscratch.org
8 # Kevin P. Fleming - kpfleming@linuxfromscratch.org
9 # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
11 # Version : LFS 7.0
13 # Notes : The IFCONFIG variable is passed to the SERVICE script
14 # in the /lib/boot directory, to indicate what file the
15 # service should source to get environmental variables.
17 ########################################################################
19 file=/etc/sysconfig/ifconfig.${1}
21 # Skip backup files
22 [ "${file}" = "${file%""~""}" ] || exit 0
24 . /lib/boot/functions
26 boot_mesg "Bringing up the ${1} interface..."
27 boot_mesg_flush
29 if [ ! -r "${file}" ]; then
30 boot_mesg "${file} is missing or cannot be accessed." ${WARNING}
31 echo_warning
32 exit 1
35 . $file
37 if [ "$IFACE" = "" ]; then
38 boot_mesg "${file} does not define an interface [IFACE]." ${FAILURE}
39 echo_failure
40 exit 1
43 # Do not process this service if started by boot, and ONBOOT
44 # is not set to yes
45 if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
46 echo_skipped
47 exit 0
50 if [ -n "${SERVICE}" -a -x "/lib/boot/${SERVICE}" ]; then
51 if [ -z "${CHECK_LINK}" -o \
52 "${CHECK_LINK}" = "y" -o \
53 "${CHECK_LINK}" = "yes" -o \
54 "${CHECK_LINK}" = "1" ]; then
56 # Bring up the interface
57 if ip link show ${IFACE} > /dev/null 2>&1; then
58 link_status=`ip link show ${IFACE}`
60 if [ -n "${link_status}" ]; then
61 if ! echo "${link_status}" | grep -q UP; then
62 ip link set ${IFACE} up
66 else
67 boot_mesg "Interface ${IFACE} doesn't exist." ${WARNING}
68 echo_warning
72 IFCONFIG=${file} /lib/boot/${SERVICE} ${IFACE} up
74 else
75 boot_mesg "Unable to process ${file}. Either" ${FAILURE}
76 boot_mesg "the SERVICE variable was not set"
77 boot_mesg "or the specified service cannot be executed."
78 echo_failure
79 exit 1
82 # End /sbin/ifup