#!/bin/sh # ifup DEVICE=${1} BRCTL=/usr/sbin/brctl # Source functions library source /etc/rc.d/init.d/functions log_script_name "$0 $*" # Load network interface card parameters source /etc/sysconfig/network/ifconfig.${DEVICE} # Check that the brctl program is present and executable. check_brctl() { if [ ! -x ${BRCTL} ]; then msg_log "*** ERROR: /usr/sbin/brctl not found." exit ${EXIT_CODE_FAILURE} fi } # Determining if the interface is a bridge: if [ "x${BRIDGE}" = "xyes" ]; then check_brctl cmd_run_log ${BRCTL} addbr ${1} && cmd_run_log ${BRCTL} stp ${1} off || exit 1 fi # Determining if the interface is part of a bridge: if [ -n "${BRIDGE_TO}" ]; then check_brctl cmd_run_log ${BRCTL} addif ${BRIDGE_TO} ${1} || exit 1 fi if [ "x${BOOTPROTO}" = "xdhcp" ]; then # DHCP configuration # Load DHCP client parameters source /etc/sysconfig/network/dhcp-client # Make sure no file named `/var/run/dhclient.pid' remains. if [ -f "/var/run/dhclient.pid" ]; then rm -f /var/run/dhclient.pid fi if [ ! -x "${DHCP_PROG}" ]; then echo "Program \"${DHCP_PROG}\" is not executable." exit ${EXIT_CODE_FAILURE} fi cmd_run_log ${DHCP_PROG} ${DHCP_START} ${DEVICE} elif [ x${BOOTPROTO} = "xstatic" ]; then # Static configuration cmd_run_log ip addr add ${IPADDR}/${PREFIX_LENGTH} dev ${DEVICE} brd + ${IFSCOPE} && cmd_run_log ip link set ${DEVICE} up if [ -n "${GATEWAY}" ]; then if ip route | grep -q default; then msg_log "Gateway already setup; skipping." else cmd_run_log_box "Adding default route to gateway ${GATEWAY}" \ ip route add default via ${GATEWAY} dev ${DEVICE} fi fi elif [ x${BOOTPROTO} = "xpppoe" ]; then # PPPoE configuration cmd_run_log pppoe-start else exit 1 fi exit $?