#!/bin/bash # # Make sure I'm the only one running, then loop through any entries in # the worklist directory running them till there are no more. # mydir=`dirname $0` PATH=`$mydir/echo-path` export PATH topdir="/huge/vids" whodir="$topdir/DoctorWho" dbdir="$whodir/.data" workdir="$dbdir/worklist" if [ -d "$workdir" ] then cd "$workdir" if [ -f "keeper.pid" ] then echo "keeper.pid" already exists 1>&2 exit 0 fi echo $$ > keeper.pid mypid=`cat keeper.pid` if [ "$$" = "$mypid" ] then # OK, it looks like I am the one who needs to really transcode # some files. Let's do them one after another till I run out. # Set KEEPER_PID env var so jobs can tell if they are running # under this script KEEPER_PID="$$" export KEEPER_PID trap "rm -f keeper.pid" EXIT while true do workfile=`ls -1 *.work 2>/dev/null | head -1` if [ -f "$workfile" ] then bash ./"$workfile" rm -f $workfile else # When transcoding is done, build a new web page index. build-web exit 0 fi done fi else echo "$workdir" is not a directory 1>&2 exit 2 fi