| 1 | #! /usr/bin/env bash | 
| 2 |  | 
| 3 | # $Header: /u/gcmpack/mitgcm.org/scripts/bld_manual.sh,v 1.2 2008/03/03 20:32:00 jmc Exp $ | 
| 4 |  | 
| 5 | #BLDDIR='/u/u0/httpd/html/build_manual' | 
| 6 | #cd $BLDDIR | 
| 7 | #retval=$? | 
| 8 | #if test "x$retval" != x0 ; then | 
| 9 | #  echo "unable to cd to '$BLDDIR' => exit" | 
| 10 | #  exit | 
| 11 | #fi | 
| 12 | echo -n "-- Start '"`basename $0`"' at : " ; date | 
| 13 |  | 
| 14 | export CVSROOT=/u/gcmpack | 
| 15 | #OUTDIR='/u/u0/httpd/html/r2_manual' | 
| 16 | #- note: "mv" to relative path below is much faster than using full path above | 
| 17 | OUTDIR='../r2_manual' | 
| 18 | ADDRERR='jmc@ocean.mit.edu' | 
| 19 |  | 
| 20 | echo | 
| 21 | echo "  Removing previous directories..." | 
| 22 | test -e old  &&  rm -rf old | 
| 23 | mkdir old | 
| 24 | mv MITgcm manual mitgcm.org old | 
| 25 | rm -rf old & | 
| 26 |  | 
| 27 | if test -e scratch/dev_docs ; then | 
| 28 | mv scratch/dev_docs "scratch/dev_docs_"`date +%Y%m%d`"_"`date +%H%M` | 
| 29 | fi | 
| 30 |  | 
| 31 | echo | 
| 32 | echo "-- Download from CVS :" | 
| 33 | rm -f dwn.log | 
| 34 | echo -n ' MITgcm ... ' | 
| 35 | cvs -q co -P MITgcm > dwn.log | 
| 36 | echo "=====================================" >> dwn.log | 
| 37 | echo -n ', manual ... ' ; | 
| 38 | cvs -q co -P manual >> dwn.log | 
| 39 | echo "=====================================" >> dwn.log | 
| 40 | echo -n ', mitgcm.org ...' | 
| 41 | cvs -q co -P mitgcm.org >> dwn.log | 
| 42 | echo -n " : done " ; date | 
| 43 |  | 
| 44 | ( | 
| 45 | rm -f build.log | 
| 46 | cd mitgcm.org/devel/buildweb | 
| 47 | make All > ../../../build.log 2>&1 | 
| 48 | ) | 
| 49 | echo -n '-- Finish building manual at : ' ; date | 
| 50 |  | 
| 51 | newbld="dev_docs_"`date +%Y%m%d`"_"`date +%H%M` | 
| 52 | if test -f  scratch/dev_docs/index.html ; then | 
| 53 | echo " mv scratch/dev_docs $OUTDIR/$newbld" | 
| 54 | mv scratch/dev_docs $OUTDIR/$newbld | 
| 55 | else | 
| 56 | if test -e scratch/dev_docs ; then | 
| 57 | echo " mv scratch/dev_docs scratch/$newbld" | 
| 58 | mv scratch/dev_docs scratch/$newbld | 
| 59 | fi | 
| 60 | echo "========================================================" | 
| 61 | echo "error running '"`basename $0`"' at : "`date` | tee tmp.$$ | 
| 62 | echo " no file 'scratch/dev_docs/index.html' !" | tee -a tmp.$$ | 
| 63 | echo " ==> Incomplete build" | tee -a tmp.$$ | 
| 64 | echo "" | tee -a tmp.$$ | 
| 65 | echo "-> tail -15 build.log : >->->->->->->->->->->->->" | tee -a tmp.$$ | 
| 66 | tail -15 build.log | tee -a tmp.$$ | 
| 67 | echo "<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<" | tee -a tmp.$$ | 
| 68 | if test "x$ADDRERR" != x ; then | 
| 69 | mail -s `basename $0`' Error' $ADDRERR < tmp.$$ | 
| 70 | fi | 
| 71 | rm -f tmp.$$ | 
| 72 | exit 2 | 
| 73 | fi | 
| 74 |  | 
| 75 | ( | 
| 76 | cd $OUTDIR | 
| 77 | echo "-- Install latest in dir: "`pwd` | 
| 78 | test -e latest  &&  rm -f latest | 
| 79 | echo " ln -s `ls -td dev_docs* | head -1` latest" | 
| 80 | ln -s `ls -td dev_docs* | head -1` latest | 
| 81 | n=$(( `ls dev_docs*/index.html | wc -l` - 7 )) | 
| 82 | if test $n -gt 0 ; then | 
| 83 | echo -n ' remove dir: ' | 
| 84 | ls -t dev_docs*/index.html | sed 's/\/index.html//' | tail -"$n" | 
| 85 | ls -t dev_docs*/index.html | sed 's/\/index.html//' | tail -"$n" | xargs rm -rf | 
| 86 | fi | 
| 87 | ) | 
| 88 |  | 
| 89 | echo -n '-- Done at : ' ; date |