From: raptor <raptor@tvskat.net>
To: lartc@vger.kernel.org
Subject: Re: [LARTC] init scripts to use and save iproute and tc rules
Date: Tue, 26 Nov 2002 08:04:32 +0000 [thread overview]
Message-ID: <marc-lartc-103829786902931@msgid-missing> (raw)
In-Reply-To: <marc-lartc-103824067113988@msgid-missing>
|Where can I find any init scripts to use and save iproute and tc rules?
]- here is one for tcng for mandrake, u can easly change it for tc (just edit start() ) to suit your needs
#!/bin/sh
#
# tcng: Starts the tcng Server
#
# Version: @(#) /etc/rc.d/init.d/tcng 0.1
#
# chkconfig: 2345 90 10
# description: Starts and stops the tcng at boot time and shutdown.
#
# processname: tcng
#
# created : from Raptor
#
#path to the tc command
tc=/sbin/tc
#path to the tcc command
tcc=/arh/bin/com.pl
#where is the tcng config file
tcngConf=/path/tcng/blah.tcng
offMsg=OFF
onMsg=ON
debug=1
# Source function library.
. /etc/rc.d/init.d/functions
isUp () {
res=`$tc qdisc show dev $1`
if [ -z "$res" ]; then return 1; fi
return 0
}
start () {
gprintf "Starting tcng services: "; echo
OLDIFS="$IFS"
IFS="
"
cmds=`$tcc $tcngConf | grep -v "^#" | sed -e "s/^tc//"`
for cmd in $cmds; do
[ $debug -eq 1 ] && gprintf "Execute : $cmd:" && echo;
eval "$tc $cmd"
done
touch /var/lock/subsys/tcng
IFS="$OLDIFS"
}
stop () {
gprintf "Stopping some/all tcng services: "
echo
#if explictly specified shut only these devices
[ "$1" ] && devs=$*;
# echo $devs
for d in $devs; do
if isUp $d ; then
gprintf "Flushing : $d"; echo
$tc qdisc del dev $d root
else gprintf "No traffic control running on : $d"; echo
fi
# rm -f /var/lock/subsys/tcng-$d
done
rm -f /var/lock/subsys/tcng;#this is not the correct behavior
}
status () {
[ "$1" ] && devs=$*;
# echo $devs
for d in $devs; do
if isUp $d ;
then gprintf "traffic control on $d : [$onMsg]"; echo;
else gprintf "traffic control on $d: [$offMsg]"; echo;
fi
done
}
show () {
if [ -z "$1" ]; then what=all; else what=$1; fi
shift
if [ "$1" ]; then devs=$*; fi
for d in $devs; do
if isUp $d; then
[ "$what" = "all" ] || [ "$what" = "qdisc" ] && gprintf "`$tc qdisc show dev $d`"; echo
[ "$what" = "all" ] || [ "$what" = "class" ] && gprintf "`$tc class show dev $d`"; echo
[ "$what" = "all" ] || [ "$what" = "filter" ] && gprintf "`$tc filter show dev $d`"; echo
fi
done
}
parse () {
echo "$1" | perl -ne '
$_ =~ s/(\d+?:\d+?)/$1/gs;
print $_
'
}
stat () {
[ -z "$1" ] || [ -z "$2" ] && gprintf "qdisc|class or device has to be specified !!!" && echo && exit;
parse "`$tc -s $1 show dev $2`"
}
devs=`ifconfig -a | grep '^\w' | grep -v lo | cut -f 1 -d ' '`
command=$1
shift;
case "$command" in
start) start ;;
stop) stop $@ ;;
status) status $@ ;;
show) show $@ ;;
stat) stat $@ ;;
restart)
gprintf "Restarting tcng. "; echo
stop $@
start $@
;;
*)
gprintf "*** Usage:
tcng {start|stop|status|restart} [devices]
tcng show [all|qdisc|class|filter] [devices]
tcng stat [qdisc|class] [devices]
"; echo
exit 1
esac
exit 0
_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/
prev parent reply other threads:[~2002-11-26 8:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-25 16:08 [LARTC] init scripts to use and save iproute and tc rules Luis Miguel Cruz Miranda
2002-11-25 16:26 ` Stef Coene
2002-11-26 7:32 ` Tarek W.
2002-11-26 8:04 ` raptor [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-lartc-103829786902931@msgid-missing \
--to=raptor@tvskat.net \
--cc=lartc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.