Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7938)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7944)
@@ -57,6 +57,7 @@
 #
 
+source `dirname $0`/sourcefile
+printprocesslog "INFO starting $0"
 program=copyscript
-source `dirname $0`/sourcefile
 
 set -C
@@ -67,11 +68,7 @@
 char=24
 datetime=`date +%F-%H-%M-%S`
-lockfile=$lockpath/lock-copyscript.txt
-
-scriptlogpath=$runlogpath/$program
-makedir $scriptlogpath
-
-scriptlog=$scriptlogpath/copyscript-$datetime.log
-
+lockfile=$lockpath/lock-$program.txt
+
+scriptlog=$runlogpath/$program-$datetime.log
 date >> $scriptlog 2>&1
 
@@ -87,7 +84,5 @@
 then
    echo "couldn't create checkfile -> exit script" >> $scriptlog 2>&1
-   rm -v $lockfile >> $scriptlog 2>&1
-   date  >> $scriptlog 2>&1
-   exit
+   finish >> $scriptlog 2>&1
 else
    echo "checkfile created" >> $scriptlog 2>&1
@@ -109,7 +104,5 @@
 then 
    echo "nothing to do -> exit"  >> $scriptlog 2>&1
-   rm -v $lockfile >> $scriptlog 2>&1
-   date  >> $scriptlog 2>&1
-   exit
+   finish >> $scriptlog 2>&1
 fi
 
@@ -118,4 +111,5 @@
 for date in ${dates[@]}
 do 
+   printprocesslog "INFO processing files for $date"
    #find all files for this date
    files=`find $transdir/*/$date/ -name "*.*"`  >> $scriptlog 2>&1
@@ -129,5 +123,5 @@
    
    date2=`echo $date | sed -e 's/_/\//g'`
-   copylogpath=$logpath/copyscript/$date2
+   copylogpath=$logpath/$program/$date2
    echo "copylogpath: "$copylogpath >> $scriptlog 2>&1
    makedir $copylogpath >> $scriptlog 2>&1
@@ -155,8 +149,11 @@
             checkfillrbk=`root -q -b $macrospath/filldotrbk.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrbk-$filename-log.txt | grep int | sed -e 's/(int)//'`
             case $checkfillrbk in
-               1) echo "checkfillrbk=$checkfillrbk -> everything ok " >> $scriptlog 2>&1 
-                  echo " -> go on with copying file" >> $scriptlog 2>&1 ;;
-               *) echo "checkfillrbk=$checkfillrbk - Error -> go on with next file" >> $scriptlog 2>&1 
-                  continue;;
+               1) echo " checkfillrbk=$checkfillrbk -> everything ok " >> $scriptlog 2>&1 
+                  echo "  -> go on with copying file" >> $scriptlog 2>&1 
+                  ;;
+               *) echo " checkfillrbk=$checkfillrbk - Error -> go on with next file" >> $scriptlog 2>&1 
+                  printprocesslog "ERROR filldotrbk.C failed for $file"
+                  continue
+                  ;;
             esac
          fi
@@ -166,16 +163,21 @@
             checkfillrun=`root -q -b $macrospath/filldotrun.C+\("\"$file\""\,kFALSE\) | tee $copylogpath/filldotrun-$filename-log.txt  | grep int | sed -e 's/(int)//'`
             case $checkfillrun in
-               1) echo "checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1 
-                  echo "-> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1 
+               1) echo " checkfillrun=$checkfillrun -> everything ok " >> $scriptlog 2>&1 
+                  echo "  -> insert date in SequenceBuildStatus for $date" >> $scriptlog 2>&1 
 
                   checkinsertdate=`root -q -b $macrospath/insertdate.C+\("\"$date\""\) | tee $copylogpath/insertdate-$date-log.txt   | grep int | sed -e 's/(int)//'`
                   case $checkinsertdate in
                      1) echo "date inserted" >> $scriptlog 2>&1 ;;
-                     *) echo "checkinsertdate=$checkinsertdate -> ERROR - insert date didn't work" >> $scriptlog 2>&1 
-                        continue;;
+                     *) echo " checkinsertdate=$checkinsertdate -> ERROR - insert date didn't work" >> $scriptlog 2>&1 
+                        printprocesslog "ERROR insertdate.C failed for $date"
+                        continue
+                        ;;
                   esac
-                  echo " -> go on with copying file" >> $scriptlog 2>&1 ;;
-               *) echo "checkfillrun=$checkfillrun Error -> go on with next file" >> $scriptlog 2>&1 
-                  continue;;
+                  echo " -> go on with copying file" >> $scriptlog 2>&1 
+                  ;;
+               *) echo " checkfillrun=$checkfillrun Error -> go on with next file" >> $scriptlog 2>&1 
+                  printprocesslog "ERROR filldotrun.C failed for $file"
+                  continue
+                  ;;
             esac
          fi
@@ -189,4 +191,5 @@
          else
             echo $file" couldn't be moved!!!!!" >> $scriptlog 2>&1 
+            printprocesslog "WARN moving of file $file didn't work"
          fi
 
@@ -195,4 +198,5 @@
          #already processed (entry in donelist) -> go on with next file
          echo $file": checksum not ok " >> $scriptlog 2>&1 
+         printprocesslog "WARN checksum for file $file is not ok"
       fi
    done
@@ -208,5 +212,5 @@
 #second part of the script:
 #update the catalog file magic_favorites.edb
-
+printprocesslog "INFO processing new catalog files"
 magfav=magic_favorites.edb #catalog filename
 catalog=$setuppath/$magfav #current catalogfile
@@ -218,4 +222,5 @@
 for catfile in ${catfiles[@]}
 do
+   printprocesslog "INFO processing catalog file $catfile"
    #write information into .diff
    echo "diff $catfile $catalog" >| $diff
@@ -240,5 +245,6 @@
          #inform $adrs about removed lines
          nail -s 'catalogfile - removed lines' $adrs < $diff
-         exit
+         printprocesslog "NEWS catalog file: lines have been removed ($catfile)"
+         finish >> $scriptlog 2>&1
       fi
       
@@ -252,5 +258,6 @@
       then 
          echo "could not do 'rsync -av $catalog $setuppath/oldcatalogs/$magfav.$date' -> exit" >> $scriptlog 2>&1 
-         exit
+         printprocesslog "ERROR rsync of catalog file ($catalog -> $oldcatalogpath/$magfav.$date) didn't work"
+         finish >> $scriptlog 2>&1
       fi
       #rsync new catalogfile to current catalogfile
@@ -258,9 +265,11 @@
       then 
          echo "could not do 'rsync -av $catfile $catalog' -> exit" >> $scriptlog 2>&1 
-         exit
+         printprocesslog "ERROR rsync of catalog file ($catfile -> $catalog) didn't work"
+         finish >> $scriptlog 2>&1
       fi
       #inform $adrs about changes
       echo "file has been rsynced sucessfully -> sending email" >> $scriptlog 2>&1 
       nail -s 'new catalogfile installed - new lines'  $adrs < $diff
+      printprocesslog "NEWS there are new lines in the catalogfile (see $catalog)"
       continue
    fi
@@ -273,12 +282,10 @@
       #inform $adrs about removed lines
       nail -s 'catalogfile - removed lines' $adrs < $diff
-      exit
+      printprocesslog "NEWS catalog file: lines have been removed ($catfile)"
+      finish >> $scriptlog 2>&1
    fi
 #   echo "nothing has changed ($catfile)"  >> $scriptlog 2>&1 
 done
 
-
-rm -v $lockfile >> $scriptlog 2>&1
-date >> $scriptlog 2>&1
-
-set +C
+finish >> $scriptlog 2>&1
+
