D.26. /etc/sysconfig/network-devices/ifdown

#!/bin/sh
########################################################################
# Begin /sbin/ifdown
#
# Description : Interface Down
#
# Authors     : Nathan Coulson - nathan@linuxfromscratch.org
#               Kevin P. Fleming - kpfleming@linuxfromscratch.org
# Update      : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version     : LFS 7.0
#
# Notes       : the IFCONFIG variable is passed to the scripts found
#               in the /lib/boot directory, to indicate what file the
#               service should source to get environmental variables.
#
########################################################################

file=/etc/sysconfig/ifconfig.${1}

# Skip backup files
[ "${file}" = "${file%""~""}" ] || exit 0

. /lib/boot/functions 

if [ ! -r "${file}" ]; then
   boot_mesg "${file} is missing or cannot be accessed." ${WARNING}
   echo_warning
   exit 1
fi

. ${file}

if [ "$IFACE" = "" ]; then
   boot_mesg "${file} does not define an interface [IFACE]." ${FAILURE}
   echo_failure
   exit 1
fi

# This will run the service script, if SERVICE is set
if [ -n "${SERVICE}" -a -x "/lib/boot/${SERVICE}" ]; then
   if ip link show ${IFACE} > /dev/null 2>&1; then
      IFCONFIG=${file} /lib/boot/${SERVICE} ${IFACE} down
   else
      boot_mesg "Interface ${1} doesn't exist." ${WARNING}
      echo_warning
   fi
else
   boot_mesg "Unable to process ${file}.  Either" ${FAILURE}
   boot_mesg "the SERVICE variable was not set"
   boot_mesg "or the specified service cannot be executed."
   echo_failure
   exit 1
fi

link_status=`ip link show ${IFACE} 2>/dev/null`

if [ -n "${link_status}" ]; then
   if echo "${link_status}" | grep -q UP; then
      boot_mesg "Bringing down the ${IFACE} interface..."
      ip link set ${IFACE} down
      evaluate_retval
   fi
fi

# End /sbin/ifdown