Makefile | 4 +-- sc | 10 +++--- sc.init | 106 +++++++++++++++++++++++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 51 deletions(-) diff --git a/Makefile b/Makefile index c7ea51e..a169f5c 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,8 @@ help: echo " uninstall uninstall program" install: $(PROG) $(PROG).init $(PROG).conf.5 $(PROG).8 $(PROG).conf - install -D -m 755 $(PROG) $(DESTDIR)$(SBINDIR) - install -D -m 644 $(PROG).8 $(DESTDIR)$(MANDIR)/man8/$(PROG).8 + install -D -m 755 $(PROG) $(DESTDIR)$(SBINDIR)/shapercontrol + install -D -m 644 $(PROG).8 $(DESTDIR)$(MANDIR)/man8/shapercontrol.8 install -D -m 644 $(PROG).conf.5 $(DESTDIR)$(MANDIR)/man5/$(PROG).conf.5 install -D -m 755 $(PROG).init $(DESTDIR)$(INITDIR)/$(SERVICE) install -D -m 644 $(PROG).conf $(DESTDIR)$(CONFDIR)/$(PROG).conf.default diff --git a/sc b/sc index 8975650..bb316a4 100755 --- a/sc +++ b/sc @@ -1144,7 +1144,7 @@ sub shaper_dev_init if ($default_policy eq 'block' || $default_policy eq 'block-all') { $TC->( "filter add dev $dev parent 1:0 protocol ip pref $pref_default ". - 'u32 match u32 0 0 at 0 police mtu 1 drop' + 'u32 match u32 0 0 at 0 action drop' ); } if ($default_policy eq 'pass') { @@ -1492,7 +1492,7 @@ sub policer_dev_init $TC->( "filter add dev $dev parent $ingress_cid: protocol ip ". "pref $pref_default u32 match u32 0 0 at 0 ". - "police mtu 1 drop" + "action drop" ); } return $?; @@ -2110,11 +2110,11 @@ __END__ =head1 NAME -B - administration tool for ISP traffic shaper +B - administration tool for ISP traffic shaper =head1 SYNOPSIS -B [options] B [ip] [rate] +B [options] B [ip] [rate] =head1 DESCRIPTION @@ -2512,7 +2512,7 @@ C =head1 CONFIGURATION -By default B reads configuration from F file and uses +By default B reads configuration from F file and uses SQLite database at F. See sc.conf(5) for details. diff --git a/sc.init b/sc.init index ea97111..df05a1c 100755 --- a/sc.init +++ b/sc.init @@ -1,4 +1,8 @@ #!/bin/sh +# chkconfig: - 15 85 +# description: starts the Shaper Control Tool +# processname: /usr/sbin/shapercontrol +# config: /etc/sysconfig/sc ### BEGIN INIT INFO # Provides: sc @@ -9,56 +13,70 @@ # Short-Description: Shaper Control Tool ### END INIT INFO -set -e +# /etc/init.d/shapercontrol: init script for Shaper Control Tool -# /etc/init.d/sc: init script for Shaper Control Tool +SC=shapercontrol +. /etc/init.d/functions -SC=/usr/local/sbin/sc -test -x $SC || exit 0 +SourceIfNotEmpty /etc/sysconfig/sc +LOCKFILE="/var/lock/subsys/$SC" -if test -f /etc/default/sc; then - . /etc/default/sc -fi +RETVAL=0 -. /lib/lsb/init-functions +start() +{ + action "Starting shaper" $SC $SC_OPTS load 2>/dev/null + RETVAL=$? + if [ $RETVAL = 0 ]; then + touch "$LOCKFILE" + else + rm -f "$LOCKFILE" + fi -if [ -n "$2" ]; then - SC_OPTS="$SC_OPTS $2" -fi + return $RETVAL +} -case "$1" in - start) - log_daemon_msg "Starting shaper" "sc" - if $SC $SC_OPTS load ; then - log_end_msg 0 - else - log_end_msg 1 - fi - ;; - - stop) - log_daemon_msg "Stopping shaper" "sc" - if $SC $SC_OPTS reset ; then - log_end_msg 0 - else - log_end_msg 1 - fi - ;; - - restart|reload|force-reload) - log_daemon_msg "Restarting shaper" "sc" - if $SC $SC_OPTS reload ; then - log_end_msg 0 - else - log_end_msg 1 - fi - ;; +stop() +{ + action "Stopping shaper" $SC $SC_OPTS reset 2>/dev/null + RETVAL=$? + rm -f $LOCKFILE + return $RETVAL +} - status) - $SC $SC_OPTS status - ;; +reload() +{ + action "Reload shaper" $SC $SC_OPTS reload 2>/dev/null + RETVAL=$? + return $RETVAL +} - *) - log_action_msg "Usage: /etc/init.d/sc {start|stop|reload|force-reload|restart|status}" - exit 1 +case "$1" in + start) + start + ;; + save) + save + ;; + status) + $SC status + RETVAL=$? + ;; + stop) + stop + ;; + restart|reload) + reload + ;; + condrestart) + [ -e "$LOCKFILE" ] && start + ;; + condstop) + [ -e "$LOCKFILE" ] && stop + ;; + *) + msg_usage "${0##*/} {condrestart|panic|restart|save|start|status|stop}" + RETVAL=1 esac + +exit $RETVAL