#! /bin/sh -e # wwwoffle-outgoing-reprioritizer # reprioritize WWWOFFLE outgoing requests via regular expression # Copyright : http://www.fsf.org/copyleft/gpl.html # Author : Dan Jacobson -- http://jidanni.org/comp/wwwoffle/ # Created On : Wed Feb 1 08:54:46 2006 # Last Modified On: Mon Feb 13 06:35:22 2006 # Update Count : 26 #On my machine I found the requests in the WWWOFFLE outgoing directory #seem to be fetched in 'ls -U' order. I.e., From the top of #http://localhost:8080/index/outgoing?sort=none. #So to reprioritize (raise to top priority) a request, we will move it #to ../temp and move it back (staying on the same partition to reduce #work). Tested with WWWOFFLE 2.8e, GNU/Linux 2.6.14 #Only tested offline. Of course dependent on Linux #internal directory ordering. "Seems to work". #Must be root to use unless you chmod 777 $wwwoffle_cache/outgoing etc. dir=outgoing deprioritize= case $1 in -\?|-h|--help) cat <&2; exit 24;} test $# -gt 1 && { echo $0: one regexp please 1>&2; exit 33;} tmp=/tmp/worrZ.${RANDOM-x} trap "rm $tmp" 0 gawk="gawk -v IGNORECASE=${IGNORECASE-1} --re-interval" wwwoffle-ls $dir|$gawk '$6~"'$1'"{print $1,"U" substr($1,2),$6}' > $tmp if test -s $tmp then awk '{print $NF}' $tmp|sort|LESS=${LESS}F ${PAGER-pager} else echo no matches exit 1 fi set -e #again, just to be sure, for all this: echo -n Reprioritize these'? [N]|y ' read answer test "x$answer" = xy set -- $(awk '{$NF="";print}' $tmp) cd $wwwoffle_cache/$dir mv $@ ../temp others=`ls -U` #try to keep former order if test -n "$others" then mv $others ../temp else cat <&2 $0: Chose all files in $dir, no probable improvement, But still trying anyway. EOF fi cd ../temp case $deprioritize in '') mv $@ ../$dir test -n "$others" && mv $others ../$dir;; *) test -n "$others" && mv $others ../$dir mv $@ ../$dir;; esac