LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File wondershaper-1.1a.diff of Package wondershaper (Project home:Ledest:bashisms)

diff -Nur wondershaper-1.1a.orig/wshaper wondershaper-1.1a/wshaper
--- wondershaper-1.1a.orig/wshaper	2002-04-16 16:26:35.000000000 +0200
+++ wondershaper-1.1a/wshaper	2004-09-29 17:06:24.247641806 +0200
@@ -1,51 +1,80 @@
-#!/bin/bash 
-
+#!/bin/bash
+#
 # Wonder Shaper
 # please read the README before filling out these values 
 #
 # Set the following values to somewhat less than your actual download
 # and uplink speed. In kilobits. Also set the device that is to be shaped.
-DOWNLINK=800
-UPLINK=220
-DEV=eth0
+#
+# Source sysconfig file
+if [ -f /etc/sysconfig/wondershaper ]; then
+. /etc/sysconfig/wondershaper
+fi
+
+DOWNLINK="$WSHAPER_DOWNLINK"
+UPLINK="$WSHAPER_UPLINK"
+DEV="$WSHAPER_DEV"
+export DOWNLINK UPLINK DEV
 
 # low priority OUTGOING traffic - you can leave this blank if you want
 # low priority source netmasks
-NOPRIOHOSTSRC=80
+NOPRIOHOSTSRC="$WSHAPER_NOPRIOHOSTSRC"
 
 # low priority destination netmasks
-NOPRIOHOSTDST=
+NOPRIOHOSTDST="$WSHAPER_NOPRIOHOSTDST"
 
 # low priority source ports
-NOPRIOPORTSRC=
+NOPRIOPORTSRC="$WSHAPER_NOPRIOPORTSRC"
 
 # low priority destination ports
-NOPRIOPORTDST=
+NOPRIOPORTDST="$WSHAPER_NOPRIOPORTDST"
 
-# Now remove the following two lines :-)
+# Check for QOS in the kernel
+if tc -s qdisc ls dev lo > /dev/null 2>&1; then
+        true
+else
+        echo "Your Kernel lacks QOS Support or you dont have the 'tc' tool installed" > /dev/stderr
+        exit 1
+fi
 
-echo Please read the documentation in 'README' first :-\)
-exit
+# Check for sysconfig settings
+function checkconf {
+if [ -z "$DEV" ]; then
+	echo "Please set WSHAPER_DEV in /etc/sysconfig/wondershaper" > /dev/stderr
+	exit 1
+elif
+	[ -z "$DOWNLINK" ]; then
+	echo "Please set WSHAPER_DOWNLINK in /etc/sysconfig/wondershaper" > /dev/stderr
+	exit 1
+elif
+	[ -z "$UPLINK" ];then
+	echo "Please set WSHAPER_UPLINK in /etc/sysconfig/wondershaper" > /dev/stderr
+	exit 1
+fi
+}
 
-#########################################################
+# start|stop|status
 
-if [ "$1" = "status" ]
-then
+case "$@" in
+	start)
+	checkconf
+	;;
+	status)
+	checkconf
 	tc -s qdisc ls dev $DEV
 	tc -s class ls dev $DEV
-	exit
-fi
-
+	exit 0
+	;;
+	stop)
+        tc qdisc del dev $DEV root    > /dev/null 2>&1
+	tc qdisc del dev $DEV ingress > /dev/null 2>&1
+ 	exit 0
+esac
 
 # clean existing down- and uplink qdiscs, hide errors
 tc qdisc del dev $DEV root    2> /dev/null > /dev/null
 tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
 
-if [ "$1" = "stop" ] 
-then 
-	exit
-fi
-
 ###### uplink
 
 # install root CBQ
diff -Nur wondershaper-1.1a.orig/wshaper.htb wondershaper-1.1a/wshaper.htb
--- wondershaper-1.1a.orig/wshaper.htb	2002-04-16 16:26:51.000000000 +0200
+++ wondershaper-1.1a/wshaper.htb	2004-09-29 17:06:43.220184342 +0200
@@ -1,51 +1,80 @@
 #!/bin/bash
+#
 # Wonder Shaper
 # please read the README before filling out these values 
 #
 # Set the following values to somewhat less than your actual download
 # and uplink speed. In kilobits. Also set the device that is to be shaped.
+#
+# Source sysconfig file
+if [ -f /etc/sysconfig/wondershaper ]; then
+. /etc/sysconfig/wondershaper
+fi
 
-DOWNLINK=800
-UPLINK=220
-DEV=ppp0
+DOWNLINK="$WSHAPER_DOWNLINK"
+UPLINK="$WSHAPER_UPLINK"
+DEV="$WSHAPER_DEV"
+export DOWNLINK UPLINK DEV
 
 # low priority OUTGOING traffic - you can leave this blank if you want
 # low priority source netmasks
-NOPRIOHOSTSRC=
+NOPRIOHOSTSRC="$WSHAPER_NOPRIOHOSTSRC"
 
 # low priority destination netmasks
-NOPRIOHOSTDST=
+NOPRIOHOSTDST="$WSHAPER_NOPRIOHOSTDST"
 
 # low priority source ports
-NOPRIOPORTSRC=
+NOPRIOPORTSRC="$WSHAPER_NOPRIOPORTSRC"
 
 # low priority destination ports
-NOPRIOPORTDST=
+NOPRIOPORTDST="$WSHAPER_NOPRIOPORTDST"
 
+# Check for QOS in the kernel
+if tc -s qdisc ls dev lo > /dev/null 2>&1; then
+        true
+else
+        echo "Your Kernel lacks QOS Support or you dont have the 'tc' tool installed" > /dev/stderr
+        exit 1
+fi
 
-# Now remove the following two lines :-)
+# Check for sysconfig settings
+function checkconf {
+if [ -z "$DEV" ]; then
+        echo "Please set WSHAPER_DEV in /etc/sysconfig/wondershaper" > /dev/stderr
+        exit 1
+elif
+        [ -z "$DOWNLINK" ]; then
+        echo "Please set WSHAPER_DOWNLINK in /etc/sysconfig/wondershaper" > /dev/stderr
+        exit 1
+elif
+        [ -z "$UPLINK" ];then
+        echo "Please set WSHAPER_UPLINK in /etc/sysconfig/wondershaper" > /dev/stderr
+        exit 1
+fi
+}
 
-echo Please read the documentation in 'README' first
-exit
+# start|stop|status
 
-if [ "$1" = "status" ]
-then
+case "$@" in
+	start) 
+	checkconf
+	;;
+	status)
+	checkconf
 	tc -s qdisc ls dev $DEV
 	tc -s class ls dev $DEV
-	exit
-fi
-
+	exit 0
+	;;
+	stop)
+        tc qdisc del dev $DEV root    > /dev/null 2>&1
+	tc qdisc del dev $DEV ingress > /dev/null 2>&1
+ 	exit 0
+esac
 
 # clean existing down- and uplink qdiscs, hide errors
 tc qdisc del dev $DEV root    2> /dev/null > /dev/null
 tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
 
-if [ "$1" = "stop" ] 
-then 
-	exit
-fi
-
-
 ###### uplink
 
 # install root HTB, point default traffic to 1:20: