3 # 2011, Calin-Andrei Burloiu, calin.burloiu@gmail.com
5 # Bash script used to detect when a regular client finished
6 # downloading a torrent
9 # * monitors a log file provided as an argument
10 # * as long as the doe is not finished the script keeps running
11 # * when the doe is finished it returns 0
12 # * blocks the caller - the script exits only when the doe has completed
18 if [ ! $# -eq 1 ]; then
19 echo "usage: $0 log-file"
26 # check for complete transfer
27 if cat $LOG_FILE | grep "Torrent finished" &> /dev/null; then
28 echo "Torrent transfer finished"
32 if cat $LOG_FILE | grep "Segmentation fault" &> /dev/null; then
33 echo "Segmentation fault when transferring torrent"
37 # check stat client is alive
38 if ! pgrep "hrktorrent" &> /dev/null; then
39 if ! pgrep -f "schedule_client.sh" &> /dev/null; then
40 echo "No hrktorrent and no schedule_client.sh process"
45 # Don't do continuous polling