#!/bin/sh # # Add item to worklist, start the worklist processor if it is not already # running. # # These worklist items will running keeper (one at a time) for each newly # downloaded episode. (Each keeper run already does multiple background jobs # so it would be counterproductive to do multiple keeper runs at the same # time). # # The args I get are the recorddate-id and the episodename # # Special case no args to extract info from current directory. # mydir=`dirname $0` PATH=`$mydir/echo-path` export PATH # if [ "$#" = 0 ] then t1=`/bin/pwd` t2=`basename $t1` basefile=`echo $t2 | sed -r -e 's/^[0-9]+-[0-9]+-[0-9]+-[0-9]+-//'` id=`echo $t2 | sed -e 's/-'$basefile'$//'` else id="$1" basefile="$2" fi # topdir="/huge/vids" whodir="$topdir/DoctorWho" dbdir="$whodir/.data" workdir="$dbdir/worklist" # [ -d "$workdir" ] || mkdir -p "$workdir" if [ -d "$workdir" ] then mpgdir="$whodir/$id-$basefile" if [ -d "$mpgdir" ] then workfile="$workdir/$$-$basefile.work" ( umask 077 ; echo cd '"'$mpgdir'"' > "$workfile.temp" ) ( umask 077 ; echo exec \> work.log 2\>\&1 >> "$workfile.temp" ) ( umask 077 ; echo $topdir/scripts/keeper '"'$basefile.mpg'"' >> \ "$workfile.temp" ) mv "$workfile.temp" "$workfile" nohup keep-working > /dev/null 2>&1 < /dev/null & else echo $mpgdir is not a directory 1>&2 exit 2 fi else echo Unable to create $workdir 1>&2 exit 2 fi