#!/bin/bash # author: Karl Voit, shellscript@Karl-Voit.at # version: v0.1 2003-11 # homepage: http://www.Karl-Voit.at/scripts/ # This script searches in RIPPINGDIR for running # sessions of 'abcde' and prints out the abcde-jobs # that are unfinished and the number of encoding- and # ripping-jobs running. # NOTE: this script is a quickhack and you should adopt it to your needs! # Once again: REQUIRES MODIFYING! # 2do: # * check, if used tools are installed # * check, if there is something to check ;-) RIPPINGDIR=/home/vk/temp/2del/ripping HARDDISK=hda4 ENCODER=oggenc RIPPER=cdparanoia MYABCDELOCKFILE="/var/lock/lockfile_mystatus" FILENAME=$(basename $0) any () { ## print out any job running that matches $1 /bin/ps xauwww | /bin/grep -v "grep" | /bin/grep -v "xauwww" | /bin/grep -i $1 } dosay() { ## prints out a message and uses the speech synthesizer festival to notify the user echo "$FILENAME: $1" ## PLEASE MODIFY to meet your requirements (festival or not) echo "$1" | festival --tts } printentry() { #echo "DEBUG: par1 of printentry is [$1]" CDDBRETURNCODE=`head -n 1 $1| awk '{print $1}'` #echo "DEBUG: CDDBRETURNCODE=[$CDDBRETURNCODE]" case "$CDDBRETURNCODE" in "200") # only one entry; take the (only) first line head -n 1 "$1" | awk '{ print "CD-id " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 }';; "210"|"211") # several entries; take the first one (2nd line) head -n 2 "$1" | tail -n 1 | awk '{ print "CD-id " $2 " " $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 }';; esac } echo echo "--------------------------------------- Jobs which are not finished yet" for JOB in ls $RIPPINGDIR/abcde.*; do #echo DEBUG: JOB=[$JOB] [ "$JOB" == "ls" ] || printentry "$JOB/cddbquery" done echo "------------------------------------------------------------- processes" NUMOFENCODERS=`any $ENCODER |wc -l` NUMOFRIPPERS=`any $RIPPER |wc -l` FREESPACEKB=`df|grep $HARDDISK|awk '{print $4}'` FREESPACEMB=`echo "$FREESPACEKB / 1024" | bc` echo "free space on harddisk: $FREESPACEMB MB" echo " running encoders: $NUMOFENCODERS" #[ $NUMOFENCODERS -ne 0 ] && dosay "There are $NUMOFENCODERS encoders running." || dosay "There is no encoder running." [ $NUMOFENCODERS -eq 0 ] && dosay "There is no encoder running." echo " working rippers: $NUMOFRIPPERS" #[ $NUMOFRIPPERS -ne 0 ] && dosay "There are $NUMOFRIPPERS rippers running." [ -e $MYABCDELOCKFILE ] && echo "A 'myabcde'-job is waiting to begin." [ ! -e $MYABCDELOCKFILE ] && [ $NUMOFRIPPERS -eq 0 ] && echo "No 'myabcde'-job is waiting to begin." [ $NUMOFRIPPERS -eq 0 ] && [ ! -e $MYABCDELOCKFILE ] && [ $FREESPACEMB -gt 650 ] && dosay "There is enough space, no 'myabcde'-job pending and there is no ripping going on. Please enter a new CD." #[ $NUMOFRIPPERS -eq 0 ] && [ $FREESPACEMB -gt 650 ] && dosay "There is enough space and there is no ripping going on. Please enter a new CD." echo "-----------------------------------------------------------------------" echo #end