[m-rev.] for review: generate index files for ftp site

Simon Taylor stayl at cs.mu.OZ.AU
Wed Sep 4 19:41:55 AEST 2002


Estimated hours taken: 1

tools/test_mercury:
	Generate index.html files for the ftp site.	

tools/generate_index_html:
	Lock the directory before generating the index.
	generate_index_html is now invoked by all hosts,
	not just the one that creates the rotd.


Index: test_mercury
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/test_mercury,v
retrieving revision 1.195
diff -u -u -r1.195 test_mercury
--- test_mercury	3 Sep 2002 06:57:11 -0000	1.195
+++ test_mercury	4 Sep 2002 08:40:42 -0000
@@ -1174,12 +1174,21 @@
 	(
 	cd $BETA_WEBDIR_TOP
 	generate_index_html
-	)
+	) || set_status "generating www index"
 	echo "test_mercury generating www index files, finished at `date`" 1>&2
 	;;
     *)
 	;;
 esac
+
+# Now rebuild the index files on the ftp site
+echo "test_mercury generating ftp index files, starting at `date`" 1>&2
+rsh $BETA_FTPHOST "\
+	PATH=/home/mercury/public/cron/scripts:\$PATH &&
+	export PATH &&
+	cd $BETA_FTPDIR &&
+	generate_index_html" || set_status "generating ftp index"
+echo "test_mercury generating ftp index files, finished at `date`" 1>&2
 
 : check for success
 
Index: generate_index_html
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/generate_index_html,v
retrieving revision 1.7
diff -u -u -r1.7 generate_index_html
--- generate_index_html	29 Aug 2002 09:47:28 -0000	1.7
+++ generate_index_html	4 Sep 2002 08:42:18 -0000
@@ -16,10 +16,23 @@
 # matching the release numbers.
 shopt -s extglob
 
-INDEX=index.html.$HOST
+INDEX=index.html.$HOST.$$
+LOCKDIR=generate_index_html.lock
 handled_files=
 
-trap 'rm -f $INDEX; exit 1' 1 2 3 13 15
+# Lock the directory (this script may be invoked by test_mercury
+# on multiple machines at once).
+timeout=20
+retries=0
+until mkdir $LOCKDIR; do
+	case $retries in
+	    $timeout) 	echo "** $0: timed out" 1>&2; exit 1 ;;
+	esac
+	sleep 5
+	retries=`expr $retries + 1`
+done
+
+trap 'rm -rf $INDEX $LOCKDIR; exit 1' 1 2 3 13 15
 
     #
     # These are the standard locations for apache's icons
@@ -188,7 +201,7 @@
 #
 for file in *
 do
-	if [ -d $file ]
+	if [ -d $file -a $file != $LOCKDIR ]
 	then
 		(cd $file && generate_index_html)
 		echo "$img_dir <a href=$file/>$file/</a><br>" >> $INDEX
@@ -291,3 +304,4 @@
 
 mv $INDEX index.html
 
+rmdir $LOCKDIR || { echo "** $0: error removing $LOCKDIR" 1>&2; exit 1; }
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list