#! /bin/bash # # network Bring up/down trafficcontrol # # chkconfig: 3 11 89 # description: Activates/Deactivates traffic control on all network interfaces configured to \ # start at boot time. # ### BEGIN INIT INFO # Provides: $trafficcontrol # Should-Start: network # Short-Description: Bring up/down traffic control # Description: Bring up/down traffic control ### END INIT INFO # Source function library. . /etc/init.d/functions if [ ! -f /etc/sysconfig/network ]; then exit 6 fi . /etc/sysconfig/network if [ -f /etc/sysconfig/pcmcia ]; then . /etc/sysconfig/pcmcia fi # Check that networking is up. [ "${NETWORKING}" = "no" ] && exit 6 # if the ip configuration utility isn't around we can't function. [ -x /sbin/tc ] || exit 1 CWD=$(pwd) cd /etc/sysconfig/network-scripts . ./network-functions # find all the interfaces besides loopback. # ignore aliases, alternative configurations, and editor backup files interfaces=$(ls ifcfg* | \ LANG=C sed -e "$__sed_discard_ignored_files" \ -e '/\(ifcfg-lo$\|:\|ifcfg-.*-range\)/d' \ -e '/ifcfg-[A-Za-z0-9#\._-]\+$/ { s/^ifcfg-//g;s/[0-9]/ &/}' | \ LANG=C sort -k 1,1 -k 2n | \ LANG=C sed 's/ //') rc=0 # See how we were called. case "$1" in start) [ "$EUID" != "0" ] && exit 4 rc=0 # bring up all other interfaces configured to come up at boot time for i in $interfaces; do if LANG=C egrep -L "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ifcfg-$i > /dev/null ; then continue fi /sbin/tc qdisc del dev $i root 2>/dev/null /sbin/tc qdisc add dev $i root handle 1: prio bands 4 priomap 2 3 3 3 2 3 1 1 2 2 2 2 2 2 2 2 [ $? -ne 0 ] && rc=1 /sbin/tc qdisc add dev $i parent 1:1 handle 10: pfifo limit 127 [ $? -ne 0 ] && rc=1 /sbin/tc qdisc add dev $i parent 1:2 handle 20: pfifo limit 127 [ $? -ne 0 ] && rc=1 /sbin/tc qdisc add dev $i parent 1:3 handle 30: pfifo limit 127 [ $? -ne 0 ] && rc=1 /sbin/tc qdisc add dev $i parent 1:4 handle 40: pfifo limit 127 [ $? -ne 0 ] && rc=1 done touch /var/lock/subsys/trafficcontrol ;; stop) [ "$EUID" != "0" ] && exit 4 remaining="" rc=0 # get list of bonding, vpn, and xdsl interfaces for i in $interfaces; do /sbin/tc qdisc del dev $i root 2>/dev/null done rm -f /var/lock/subsys/trafficcontrol ;; status) for i in $interfaces; do echo $i /sbin/tc qdisc show dev $i done test -f /var/lock/subsys/trafficcontrol [ $? -ne 0 ] && rc=1 ;; restart|reload|force-reload) cd "$CWD" $0 stop $0 start rc=$? ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}" exit 2 esac exit $rc