#! /bin/csh -f ###################################################################### # This script updates the zip archive of the entire website. # # # Usage: # # % makebulk [kill] # # The kill option removes all the bulk zip files. # # The makefile "BULKMAKE" contains all the details for updating the # zipfile. It looks something like this: # # -------- start of BULKMAKE -------- # # SHELL = /bin/sh # DESTDIR = $(ZIP_DIR)/bulk # # 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) # @ echo "Updating $(ZIP)" # zip -u -b /tmp $(DESTDIR)/$(ZIP) $(INCLUDE) # chmod a+r $(DESTDIR)/$(ZIP) # cd $(DESTDIR) ;\ # unzip -p $(ZIP) index.html | sed -e "/BASE HREF/d" > index.html ;\ # zip -u -b /tmp $(ZIP) index.html ; rm index.html # echo done. # # all: # make -f BULKMAKE $(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 zip 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 (! ${?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 ($# > 1) then goto Usage endif set theMakeFile = BULKMAKE set theOption="" if ($# == 1) then set theOption="$1" endif cd $HTML_DIR if ("$theOption" == "kill") then echo Deleting the bulk files make -f $theMakeFile kill echo Done. exit endif # 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"` #don't forget the RSS feed! #set rssFile=$HTML_DIR/rss/news.rss #stamp_bulk $theBulkVersion $theBulkDate $rssFile # export these variables into the environment so 'make' can use them # (we have to use 'echo' in order to preserve the double-quotes. And we need # double-quotes in case these strings contain spaces, etc.) setenv makebulk_BULK_VERSION `echo \""$theBulkVersion"\"` setenv makebulk_BULK_DATE `echo \""$theBulkDate"\"` setenv makebulk_BULK_NAME `echo \""$theBulkName"\"` # create (or update) the raw bulk.zip file # (and stamp the version no. onto the files that need it) make -f $theMakeFile bulk.zip # update the files that contain the master list of the website's files bulklist # Add the modified master file lists back into the zip file cd $HTML_DIR ; zip -u -b /tmp $ZIP_DIR/bulk/bulk.zip tech/download/newfiles.html tech/download/allfiles.html # Now edit those files in bulk.zip that contain specially marked bulk-related # chunks of text. These files may include those that refer to online-only # features of the website (e.g., the search engine), files that need to be # stamped with the bulk version number, etc. make -f $theMakeFile bulkfix #jtb 030124 # One more thing. Let's 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 = $ZIP_DIR/bulk # where the bulk file lives set bulkDump = ~/Sites/atibulk_archives # where I stash the old zip files set redirect = $bulkDir/bulk.html cd $bulkDir foreach x (${theBulkPrefix}*) mv $x $bulkDump/. # move out any old zip files end mv -f $tidyFile $theBulkName # now create an HTML redirect that points to the new zip file cat << END_INPUT > $redirect END_INPUT echo echo -n "Updating RSS feed... " set rssChunkFile = /tmp/${me}.tmp set rssFile = $HTML_DIR/rss/news.rss cat > $rssChunkFile << 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 $rssChunkFile OFFLINE_EDITION $rssFile # update the lastBuildDate ed -s $rssFile << END_INPUT %s/.*/$theRSSDate<\/lastBuildDate>/ w Q END_INPUT echo "done." #-------------------- echo echo "Bulk file: $theBulkName" echo " version: $theBulkVersion" echo " date: $theBulkDate." echo echo "makebulk done." echo echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo \*\*\* Don\'t forget to run \'upload_to_server\' \*\*\* echo " " echo \*\*\* When did you last update the search index\? \*\*\* echo \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* echo