#! /bin/csh -f ###################################################################### # This script updates the zip archive of the entire website. # # # Usage: # # % makebulk # # # The makefile "BULKMAKE", located in the top-level dir of the website, # contains the list of files that will go into the bulk archive. # It looks something like this: # # -------- start of BULKMAKE -------- # # SHELL = /bin/sh # DESTDIR = $(BULK_DIR) # # ZIP = bulk.zip # # INCLUDE = *.html\ # tech/*\ # cdrom/*html\ # pali/*.html\ # ... (a bunch of other directories) ... # canon/khuddaka/therigatha/*.html\ # canon/khuddaka/udana/*.html # # $(ZIP): $(INCLUDE) # zip -qu $(DESTDIR)/$(ZIP) $(INCLUDE) # chmod a+r $(DESTDIR)/$(ZIP) # # kill: # rm $(DESTDIR)/$(ZIP) # # -------- end of BULKMAKE -------- # # # # The path to the website dir is stored in the environment # variable $HTML_DIR. Some of the makefiles also need to know where # the zipped files live; this is stored in the env variable $ZIP_DIR. # It's convenient to set these variables in your .login or .cshrc file, # like this: # # setenv HTML_DIR /foo/bar/website # setenv ZIP_DIR /foo/bar/zipdir ###################################################################### set me=$0:t # the name of this program # Abort if the required env variables aren't set if (! ${?BULK_DIR}) then echo ${me}: BULK_DIR environment variable not set\! exit else if (! ${?ZIP_DIR}) then echo ${me}: ZIP_DIR environment variable not set\! exit else if (! ${?HTML_DIR}) then echo ${me}: HTML_DIR environment variable not set\! exit else if (! ${?DATE_FORMAT_ATI_FRIENDLY}) then echo ${me}: DATE_FORMAT_ATI_FRIENDLY environment variable not set\! exit else if (! ${?DATE_FORMAT_ATI_VERSION}) then echo ${me}: DATE_FORMAT_ATI_VERSION environment variable not set\! exit endif else if (! ${?DATE_FORMAT_RSS}) then echo ${me}: DATE_FORMAT_RSS environment variable not set\! exit endif if ($# > 0) then echo "huh?" exit endif set theMakeFile = BULKMAKE cd $HTML_DIR # delete the previous bulk file make -f $theMakeFile kill # Hmm... The following is a cheap kludge. What if the subsequent 'make' # fails? -- we're still left with an updated bulk.html file and version no. # This script can take up to a minute to run, so let's lock in the # date and (date-based) version number now. set theBulkVersion=`date "+$DATE_FORMAT_ATI_VERSION"` set theBulkPrefix = ati- set theBulkName=${theBulkPrefix}${theBulkVersion}.zip # a file name containing the ver. no. set theBulkDate=`date "+$DATE_FORMAT_ATI_FRIENDLY"` set theRSSDate=`date "+$DATE_FORMAT_RSS"` echo "${me}: Building new bulk archive (version $theBulkVersion)..." # create a little zero-size file whose name contains this version no. cd $HTML_DIR ; /bin/rm _atibulk.* # first remove any old ones touch _atibulk.${theBulkVersion}.txt # make a new one # localize the CSS and the home page for the bulk download localize bulk # insert bulk version stamps on the files that need 'em echo -n "${me}: Applying bulk version stamps..." set needBulkStamp=`find . -name \*html -exec grep -l _BULKVERSION {} \;` echo -n "(found $#needBulkStamp files)..." echo if ($#needBulkStamp > 0) then stamp_bulk "$theBulkVersion" "$theBulkDate" "$theBulkName" $needBulkStamp >& /dev/null endif echo "${me}: Bulk version stamps applied to $#needBulkStamp files." # create (or update) the raw bulk.zip file # (and stamp the version no. onto the files that need it) echo "${me}: Launching 'make $theMakeFile'..." make -f $theMakeFile bulk.zip echo "${me}: 'make $theMakeFile' finished." # update the master file lists bulklist cd $HTML_DIR ; zip -u -b /tmp $BULK_DIR/bulk.zip tech/download/allfiles.html #jtb 030124 # Create a zip file based on bulk.zip, but whose files live in a # different root dir. This will simplify life for users: all they'll # see is a folder (containing all the html files) and a single index # file. Clicking on the index file redirects them to the html folder. # Now they won't have to go hunting through a bunch of html files to # find the right one (index.html) to click on. _newbulkroot #jtb 050502 # while we're at it, rename the archive to include the version No. set tidyFile = atibulk.zip # the end result from _newbulkroot set bulkDir = $BULK_DIR # where the bulk file lives set bulkDump = ~/Sites/backups/ati # where I stash the old zip files set redirect = $bulkDir/bulk.html cd $bulkDir set nonomatch #jtb 050808 -- in case ${theBulkPrefix}* doesn't exist foreach x (${theBulkPrefix}*) mv $x $bulkDump/. # move out any old zip files end unset nonomatch #jtb 050808 mv -f $tidyFile $theBulkName # now create an HTML redirect that points to the new zip file cat << END_INPUT > $redirect Redirecting to bulk download... END_INPUT echo -n "${me}: Updating RSS feed... " set tmpRssChunkFile = ~/tmp/${me}.tmp set rssFile = $HTML_DIR/rss/news.rss cat > $tmpRssChunkFile << END_INPUT The current Off-line Edition is $theBulkVersion ($theBulkDate) http://www.accesstoinsight.org/tech/download/bulk.html The Off-line Edition was last updated on ${theBulkDate}. $theRSSDate END_INPUT insert_chunk $tmpRssChunkFile OFFLINE_EDITION $rssFile /bin/rm $tmpRssChunkFile # update the lastBuildDate ed -s $rssFile << END_INPUT %s/.*/$theRSSDate<\/lastBuildDate>/ w Q END_INPUT # restore online localization of the CSS and home page localize online echo "done." cat << END_INPUT Bulk file: $theBulkName version: $theBulkVersion date: $theBulkDate. ${me}: All done. +----------------------------------------------+ | ** Don't forget to run 'upload_to_server' ** | | | | When did you last update the search index? | +----------------------------------------------+ END_INPUT