Index: trunk/MagicSoft/Mars/datacenter/scripts/checkstardone
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 7265)
+++ trunk/MagicSoft/Mars/datacenter/scripts/checkstardone	(revision 7460)
@@ -20,9 +20,19 @@
 #   Author(s): Daniela Dorner  08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
 #
-#   Copyright: MAGIC Software Development, 2000-2004
+#   Copyright: MAGIC Software Development, 2000-2006
 #
 #
 # ========================================================================
 #
+# This script launches the checking of the availability of the files for 
+# the datasets. 
+#
+# After checking, if the script is already running, the todolist is 
+# written by using the macro getdolist.C
+# Then for each dataset the sequences are extracted from the datasetfile 
+# and for each sequence the availability of the star files checked by using 
+# the macro checkstardone.C 
+# If this was successful, the status is inserted into the database using 
+# the macro setstatus.C
 #
 
@@ -42,5 +52,4 @@
 scriptlogpath=$logpath/run/checkstardone/`date +%Y/%m/%d`
 makedir $scriptlogpath
-
 scriptlog=$scriptlogpath/checkstardone-$datetime.log
 
@@ -51,11 +60,17 @@
 cd $mars
 
+# check if script is already running
+date > $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1 
+checklock0=$?
+case $checklock0 in 
+    0)   echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
+    1)   echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
+         echo "-> checkstardone is running -> exit" >> $scriptlog 2>&1
+         date  >> $scriptlog 2>&1
+         exit;;
+    *)   echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
+esac
 
-if [ -e $todofile ]
-then 
-   echo "checkstardone is already running -> exit" >> $scriptlog 2>&1
-   exit
-fi
-
+# get todo list
 echo "getting list..." >> $scriptlog 2>&1
 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
@@ -63,14 +78,17 @@
 case $check0 in 
    1)   echo "check0=$check0 -> everything ok -> do step" >> $scriptlog 2>&1 ;;
-   *)   echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1 ;;
+   *)   echo "check0=$check0 -> ERROR -> could not get list -> exit" >> $scriptlog 2>&1
+        rm -v $todofile >> $scriptlog 2>&1
+   	rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
+   	date  >> $scriptlog 2>&1
+	exit;;
 esac
 
 datasets=(`cat $todofile`)
-
 if [ "$datasets" = "" ]
 then 
    echo "nothing to do -> exit"  >> $scriptlog 2>&1
    rm -v $todofile >> $scriptlog 2>&1
-   rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+   rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
    date  >> $scriptlog 2>&1
    exit
@@ -78,5 +96,4 @@
 
 echo "datasets: "${datasets[@]} #>> $scriptlog 2>&1
-
 for dataset in ${datasets[@]}
 do 
@@ -123,5 +140,5 @@
 
 rm -v $todofile  >> $scriptlog 2>&1 
-rm -v $lockpath/lock-$table-$column.txt >> $scriptlog 2>&1
+rm -v $lockpath/lock-checkstardone.txt >> $scriptlog 2>&1
 
 date  >> $scriptlog 2>&1
