add support for tc shaping

This commit is contained in:
John Bintz 2012-05-17 16:22:56 -04:00
parent 775dedf53b
commit c540794dd1
7 changed files with 43 additions and 20 deletions

View File

@ -46,29 +46,15 @@ start() {
umask 027
ulimit -n 65535
$BIN $ARGS
chown <%= scope.lookupvar('squid::user') %> $PID
RETVAL=$?
return $RETVAL
}
stop() {
PIDID=`cat $PID 2>/dev/null`
if [ -f $PID ]; then
kill $PIDID
fi
cnt=0
while kill -0 $PIDID 2>/dev/null
do
cnt=`expr $cnt + 1`
if [ $cnt -gt 24 ]
then
RETVAL=1
return RETVAL
fi
sleep 5
done
$BIN $ARGS -k shutdown
$BIN $ARGS -k kill
return $RETVAL
}

View File

@ -0,0 +1,9 @@
class tc::debian($config) {
$packages = [ 'ethtool' ]
init_d_bundle { 'tc':
init_d_prolog => template('tc/debian/init-d-prolog'),
init_d_prerun => template('tc/debian/init-d-prerun'),
require => Class['squid']
}
}

View File

@ -0,0 +1,8 @@
### BEGIN INIT INFO
# Provides: tc
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Traffic shaping
### END INIT INFO

View File

@ -0,0 +1,23 @@
<%= scope.function_template('base/init-d-header') %>
<%= init_d_prolog %>
<%= init_d_prerun %>
start() {
echo -n "Starting $NAME: "
<%= scope.lookupvar('tc::debian::config') %>
echo "done"
}
stop() {
echo -n "Stopping $NAME: "
tc qdisc del dev eth0 root
echo "done"
}
<%= scope.function_template('base/init-d-actions') %>

View File

@ -1,3 +0,0 @@
DAEMON_OPTS="\
"