First pass at a Git-aware version of export_htdocs
authorRuss Allbery <rra@stanford.edu>
Fri, 17 Jul 2009 00:11:43 +0000 (17:11 -0700)
committerRuss Allbery <rra@stanford.edu>
Fri, 17 Jul 2009 00:11:43 +0000 (17:11 -0700)
Replace the CVS code with git archive piped through tar xf -.  Remove
the /usr/local/libexec modular part; at least right now, we're not
going to use it.  Change the expected paths to match the current
layout on openafs.stanford.edu.

openafs/export_htdocs

index d72428e..7dc1204 100755 (executable)
@@ -1,18 +1,10 @@
 #!/bin/sh
-# export_htdocs - export HTML documents
+# export_htdocs - Export OpenAFS web site from Git repository
+#
+# Based on export_htdocs by Jeffrey Hutzelman <jhutz@cs.cmu.edu>
 
-if [ "x$CVSROOT" = "x" ] ; then
-  CVSROOT=/cvs
-  export CVSROOT
-fi
-
-if [ "x$1" = "x-d" ] ; then
-  CVSROOT="$2"
-  shift; shift;
-  export CVSROOT
-fi
-
-basedir=/data/htdocs
+basedir=/srv/www
+gitrepo=/srv/git/openafs-web.git
 
 umask 002
 set -e
@@ -22,24 +14,18 @@ if [ $# != 1 ] ; then
   exit 1
 fi
 
-tree=$1
+tree="$1"
 stamp=`date +%s`
-tag=htdocs_${tree}_${stamp}
-newtree=${tree}_${stamp}
+newtree="${tree}_${stamp}"
 cd $basedir
 
 trap 'rm -rf $newtree' 0 1 2 15
 
 # Generate the new tree
-cvs export -kv -d $newtree -r HEAD htdocs-$tree
-
-# Update any automatically-generated files
-if [ -f /usr/local/libexec/export-htdocs/$tree ] ; then
-  /usr/local/libexec/export-htdocs/$tree -x $newtree
-fi
+git archive --remote="$gitrepo" --prefix="$newtree"/ master | tar xf -
 
 # Generate frameless versions of pages
-/usr/local/sbin/frameless -v $newtree
+/usr/local/sbin/frameless -v "$newtree"
 
 # Move it into place
 rm -f $tree.new
@@ -47,13 +33,13 @@ ln -s $newtree $tree.new
 
 trap 0 1 2 15
 
-perl -e 'exit !rename($ARGV[0], $ARGV[1])' $tree.new $tree
+perl -e 'exit !rename($ARGV[0], $ARGV[1])' "$tree.new" "$tree"
 
 # Cleanup
-for i in ${tree}_* ; do
-  if [ $i != $newtree ]; then
-    rm -rf $i
-  fi
+for i in "${tree}"_* ; do
+    if [ $i != "$newtree" ]; then
+        rm -rf "$i"
+    fi
 done
 
 exit 0