#!/bin/sh## This script takes source files of amforth and call php script which# creates HTML pages. The script may be run by hand on regulerly fox# example once an hour or day.## (c) miho 2007 / www.mlab.cz# Configuration# =============# WorkingDir - existing directory with rw access# SvnPath - path ro subversion server with source files# SvnInfoFileName - name of file to put info about version in# WebForthInPath - name of directory with HTML templates and scripts# WebForthOutPath - name of directory to put HTML pages inWorkingDir=/home/miho/amforthSvnPath=https://amforth.svn.sourceforge.net/svnroot/amforth/trunkSvnInfoFileName=.svn-info.txtWebForthInPath=/var/www/Articles/ForthWebForthOutPath=/var/www/Articles/Forth# Start of script# ===============DateFile=/tmp/amforth.dateif [ -f $DateFile ]; thentail -n 400 $DateFile > $DateFile. 2> /dev/nulrm $DateFile 2> /dev/nulmv $DateFile. $DateFile 2> /dev/nulfidate >> $DateFile 2> /dev/nul# Create Log file# ===============if [ ! -d $WorkingDir ]; thenecho "--> ERROR: No Workig Directory"exit 1ficd $WorkingDirif [ ! -d $WorkingDir/Log ]; thenmkdir $WorkingDir/Log 2> /dev/nulif (($?)); thenecho "--> ERROR: Unable Create Working Directory"exit 1fifiLogFile=$WorkingDir/Log/amforth.logLogFileGenerate=$WorkingDir/Log/GenerateHTML.logecho "$0" > $LogFileecho "-------------------" >> $LogFile# Remove export directory# =======================echo "Performing: remove export directory" | tee -a $LogFilerm -rf $WorkingDir/source-exported | tee -a $LogFile 2>> $LogFileif (($?)); thenecho "--> ERROR: Unable Remove Export Directory" | tee -a $LogFileexit 1fiecho "-------------------" >> $LogFile# svn checkout# ============echo "Performing: svn checkout" | tee $LogFilesvn co $SvnPath $WorkingDir/source >> $LogFile 2>> $LogFileif (($?)); thenecho "--> ERROR: svn commit" | tee -a $LogFileexit 1fiecho "-------------------" >> $LogFile# svn export# ==========echo "Performing: svn export" | tee -a $LogFilesvn export $WorkingDir/source $WorkingDir/source-exported >> $LogFile 2>> $LogFileif (($?)); thenecho "--> ERROR: svn export" | tee -a $LogFileexit 1fiecho "-------------------" >> $LogFile# svn info# ========echo "Performing: svn info" | tee -a $LogFileResult=`svn info $WorkingDir/source` 2>> $LogFileecho "$Result" >> $LogFileif (($?)); thenecho "--> ERROR: svn export" | tee -a $LogFileexit 1fiecho "$Result" > $WorkingDir/source-exported/$SvnInfoFileNameecho "-------------------" >> $LogFile# Create HTML# ===========echo "Performing: GenerateHTML" | tee -a $LogFileif [ ! -d $WorkingDir/HTML ]; thenmkdir $WorkingDir/HTML 2>> $LogFilefiphp $WebForthInPath/PHP/GenerateHTML.php \EnableApache="0" \SourceDir="$WorkingDir/source-exported/" \SourceAsm="amforth.asm" \SvnInfoFileName="$SvnInfoFileName" \TemplateDir="$WebForthInPath/Templates/" \DestinationDir="$WorkingDir/HTML/" \> $LogFileGenerate 2>> $LogFileif (($?)); thenecho "--> ERROR: GenerateHTML.php" | tee -a $LogFileexit 1fiecho "-------------------" >> $LogFile# Copy result to Web Directory# ============================echo "Performing: copy HTML" | tee -a $LogFilerm -rf $WebForthOutPath/HTML | tee -a $LogFile 2>> $LogFileif (($?)); thenecho "--> ERROR: Unable Remove HTML Directory" | tee -a $LogFileexit 1fiif [ ! -d $WebForthOutPath/HTML ] || [ -d $WebForthOutPath ]; thenmkdir $WebForthOutPath/HTML | tee -a $LogFile 2>> $LogFileficp -r $WorkingDir/HTML/* $WebForthOutPath/HTML | tee -a $LogFile 2>> $LogFileecho "-------------------" >> $LogFileif (($?)); thenecho "--> ERROR: Unable Copy HTML Directory" | tee -a $LogFileexit 1fi# Finish# ======echo "O.K."echo "O.K." >> /tmp/amforth.dateexit 0