Index: trunk/MagicSoft/Mars/datacenter/scripts/copyscript
===================================================================
--- trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7454)
+++ trunk/MagicSoft/Mars/datacenter/scripts/copyscript	(revision 7455)
@@ -228,4 +228,79 @@
 #rsync -av --delete $transdir/ $extern >> $scriptlog 2>&1 
 
+
+
+#second part of the script:
+#update the catalog file magic_favorites.edb
+
+magfav=magic_favorites.edb #catalog filename
+catalog=$setuppath/$magfav #current catalogfile
+diff=$setuppath/.diff #file to store difference
+#addresses to which the changes are sent
+adrs="dorner@astro.uni-wuerzburg.de, tbretz@astro.uni-wuerzburg.de, hoehne@astro.uni-wuerzburg.de" 
+
+#getting new catalogfiles 
+catfiles=`find $subsystempath/cc/ -name $magfav -cnewer $catalog | sort`
+
+for catfile in ${catfiles[@]}
+do
+   #write information into .diff
+   echo "file: "$catfile > $diff
+   diff $catalog $catfile >> $diff
+   #getting differences
+   ins=`cat $diff| grep '>'` #what has been inserted
+   outs=`cat $diff | grep '<'`#what has been removed
+   
+   #check if lines have been inserted
+   if ! [ "$ins" == "" ]
+   then 
+      echo "--> catalogfile: "$catfile >> $scriptlog 2>&1 
+      echo "the following lines were added:" >> $scriptlog 2>&1 
+      cat $diff | grep '>'  >> $scriptlog 2>&1 
+   
+      #check if lines have been removed
+      if ! [ "$outs" == "" ]
+      then 
+         echo "the following lines have been removed" >> $scriptlog 2>&1 
+         cat $diff | grep '<'  >> $scriptlog 2>&1 
+         echo " -> please check the file $catfile" >> $scriptlog 2>&1 
+         #inform $adr about removed lines
+         nail -s 'catalogfile - removed lines' $adrs < $diff
+         exit
+      fi
+      
+      #getting date of new catalogfile from path
+      date=`echo $catfile | cut -d/ -f5-7 | sed -e 's/\///g'`
+      
+      #rsync current catalogfile to directory with old catalogfiles including the date of the new catalogfile into the filename
+      if ! rsync -av $catalog $setuppath/oldcatalogs/$magfav.$date >> $scriptlog 2>&1 
+      then 
+         echo "could not do 'rsync -av $catalog $setuppath/oldcatalogs/$magfav.$date' -> exit" >> $scriptlog 2>&1 
+         exit
+      fi
+      #rsync new catalogfile to current catalogfile
+      if ! rsync -av $catfile $catalog >> $scriptlog 2>&1 
+      then 
+         echo "could not do 'rsync -av $catfile $catalog' -> exit" >> $scriptlog 2>&1 
+         exit
+      fi
+      #inform $adr about changes
+      echo "file has been rsynced sucessfully -> sending email" >> $scriptlog 2>&1 
+      nail -s 'new catalogfile installed - new lines'  $adrs < $diff
+      continue
+   fi
+   #check if lines have been removed
+   if ! [ "$outs" == "" ]
+   then 
+      echo "the following lines have been removed" >> $scriptlog 2>&1 
+      cat $diff | grep '<'  >> $scriptlog 2>&1 
+      echo " -> please check the file $catfile" >> $scriptlog 2>&1 
+      #inform $adr about removed lines
+      nail -s 'catalogfile - removed lines' $adrs < $diff
+      exit
+   fi
+#   echo "nothing has changed ($catfile)"  >> $scriptlog 2>&1 
+done
+
+
 rm -v $lockpath/lock-copyscript.txt >> $scriptlog 2>&1
 date >> $scriptlog 2>&1
