#! /bin/tcsh -f ###################################################################### # # Assembles a list of files that have been modified since the # last invocation of this script. Depending on the args, # it will either simply list the files that need uploading to the web server, # or actually upload them. # # See the Usage: block for more info. # ###################################################################### set me=${0:t} # name of this script goto Start ###################################################################### Usage: cat << END_INPUT usage: $me:t sitename [html|zip|bulk|fdse|all] [password] Uploads newly modified files onto the remote web server. sitename -- the name of the website to upload: ati - Access to Insight not - notdotorgnot.com god - godblessourslogans.com Exactly one of the following filetype options is required: all - upload everything (all of the following) bulk - upload the bulk file only css - upload the cascading style sheets html - upload html files only fdse - upload FDSE index file only icon - upload gifs and jpegs only rss - upload the RSS feed file tech - upload tech files only zip - upload zip files only (excluding the bulk file) If no password is given, a list of files that need uploading is shown. If the password is given, an ftp session is initiated and the files are actually uploaded. END_INPUT exit ###################################################################### Start: if ( ($# < 2) || ($# > 3)) then goto Usage endif # decide which website to do switch ($1) case ati: set homeDir = ~/Sites/ati set homeDomain = accesstoinsight.org set ftpHost = ftp-dom.earthlink.net set bulkFileName = 'ati-*.zip' breaksw case not: set homeDir = ~/Sites/notdotorgnot set homeDomain = notdotorgnot.com set ftpHost = ftp-dom.earthlink.net set bulkFileName = notdot.zip breaksw case god: set homeDir = ~/Sites/godblessourslogans set homeDomain = godblessourslogans.com set ftpHost = ftp-dom.earthlink.net set bulkFileName = god.zip breaksw default: echo Unknown sitename: $1 goto Usage breaksw endsw # determine the file extension for the given filetype set fileType=${2} set fileExt = "foobar" switch ($fileType) case html: set fileExt = "html" breaksw case rss: set fileExt = "rss" breaksw case pdf: set fileExt = "pdf" breaksw case css: set fileExt = "css" breaksw case zip: set fileExt = "zip" breaksw case bulk: set fileExt = "zip" breaksw case fdse: set fileExt = "txt" breaksw case tech: ; #(fileExt isn't used for tech files) breaksw case icon: ; #(fileExt isn't used for icon files) breaksw case all: $me $1 bulk $3 # do the bulk file first $me $1 zip $3 $me $1 css $3 # do the CSS before the HTMLs $me $1 pdf $3 $me $1 html $3 $me $1 icon $3 $me $1 tech $3 $me $1 fdse $3 $me $1 rss $3 exit breaksw default: echo Unknown extension: ${fileType} goto Usage endsw set ftpCmds = ~/tmp/${me}.${fileType}.upload_tmp set upLog = $homeDir/.uploadLog-${fileType}.txt # For keeping a log of files uploaded. # The last mod time of this file is used as the reference time against which # the mod times of the html files are compared set upList = ~/tmp/${me}.${fileType}.uploadList_tmp #temporary list of files to be uploaded # If the password is specified, then we'll actually do the upload. # Otherwise, just list the files that need uploading. set doUpload="no" if ($# == 3) then set password=${3} set doUpload="yes" endif echo "--------- processing $fileType files..." # Gather a list of files with the desired extension # that have changed since the last upload cd $homeDir switch ($fileType) case bulk: # if we're looking for the bulk file, then look for just that one find . -name "$bulkFileName" -newer $upLog -print > $upList breaksw case zip: echo ' *** Zip file uploads are currently disabled ***' touch $upList # look for all zip files that don't have "bulk" in the name #find . -name \*.${fileExt} -newer $upLog \! -name \*bulk\* -print > $upList breaksw case html: # look for all html files of non-zero size find . -name \*.${fileExt} -newer $upLog \! -size 0 -print > $upList breaksw case rss: find rss -name \*.${fileExt} -newer $upLog \! -size 0 -print > $upList breaksw case pdf: find extras/pdf -name \*.${fileExt} -newer $upLog \! -size 0 -print > $upList breaksw case css: find css -name \*.${fileExt} -newer $upLog \! -size 0 -print > $upList breaksw case fdse: #find the FDSE index file find cgi/search/searchdata -name atiIndex.${fileExt}\* -newer $upLog -print > $upList #jtb 050102: added '*' to catch the atiIndex.txt.pagecount file, too breaksw case tech: #Warning: this allows any file in tech/ not starting with "." to be uploaded! find tech/scripts tech/includes \! -name .\* -newer $upLog -print > $upList breaksw case icon: #Warning: this allows any file in icon/ with a 3-char extension to be uploaded! find icon -name \*.\?\?\? -newer $upLog \! -size 0 -print > $upList breaksw default: echo Illegal filetype: ${fileType} goto Usage breaksw endsw if (-z $upList) then #if upload file is zero size echo ${fileType} files are already up to date. Upload not necessary. goto Cleanup endif # Assemble a list of 'put' commands for ftp echo "" > $ftpCmds sed -e "s/^/put /" $upList > $ftpCmds set nFiles = `grep -c put $ftpCmds` #count the lines if ($doUpload == "yes") then echo preparing to upload $nFiles files logit "${me:t}: preparing to upload $nFiles ${fileType} files" cd $homeDir ftp ftp://${homeDomain}:${password}@${ftpHost} < $ftpCmds #do it! set exitStatus = $status if ($exitStatus == 0) then set today = `date` echo " " >> $upLog echo "------- ${today}: Uploaded $nFiles files ---------" >> $upLog cat $upList >> $upLog echo "------------------------" >> $upLog echo " " >> $upLog echo "${me:t}: uploaded $nFiles ${fileType} files" logit "${me:t}: uploaded $nFiles ${fileType} files" else echo "${me:t}: ftp failed. No ${fileType} files uploaded." logit "${me:t}: ftp failed. No ${fileType} files uploaded." endif else echo $nFiles $fileType files are ready for uploading: cat $upList echo " " echo Total: $nFiles files. echo To upload these files, invoke this command again, using the password. endif goto Cleanup exit Cleanup: /bin/rm -f $upList $ftpCmds echo "------------------------------" echo " " exit