next-share: complete next-share completion detection script
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 20 Sep 2010 18:01:51 +0000 (20:01 +0200)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 20 Sep 2010 18:01:51 +0000 (20:01 +0200)
ControlScripts/clients/next-share/detect_complete_nextshare.sh

index e828197..3d54a83 100755 (executable)
@@ -20,10 +20,25 @@ fi
 LOG_FILE=$1
 
 while true; do
-       if cat $LOG_FILE | grep DLSTATUS_SEEDING &> /dev/null; then
+       # check for complete transfer
+       if cat $LOG_FILE | grep "DLSTATUS_SEEDING" &> /dev/null; then
+               echo "Torrent transfer finished"
                exit 0
        fi
-       
+
+       if cat $LOG_FILE | grep "Segmentation fault" &> /dev/null; then
+               echo "Segmentation fault when transferring torrent"
+               exit 0
+       fi
+
+       # check stat client is alive
+       if ! pgrep -f "cmdlinedl.py" &> /dev/null; then
+               if ! pgrep -f "schedule_client.sh" &> /dev/null; then
+                       echo "No cmdlinedl.py and no schedule_client.sh process"
+                       exit 0
+               fi
+       fi
+
        # Don't do continuous polling
        sleep 5
 done