#!/usr/local/bin/bash export PATH=$PATH:/usr/local/bin # Download a file, but only if it's available and not zero size getfile() { rm -f $2.new curl -s -f -o $2.new $1 if [ -s $2.new ]; then mv -f $2.new $2 fi } BASE=$1 if [ "$BASE" = "" ]; then echo "Usage: $0 [-nodocs] [-noftp]" exit fi STATIC=${BASE}/../static EXT=${BASE}/../ext DL=${BASE}/../dl # Parse other args MIRRORPARAM= FTP=1 while shift; do case "$1" in "-nodocs") MIRRORPARAM="${MIRRORPARAM} -r docs/(\d.*|current)/" ;; "-noftp") MIRRORPARAM="${MIRRORPARAM} -r ftp/" FTP=0 ;; "") ;; *) echo "Invalid parameter '$1'" exit 1 esac done # Update everything. First do a revert, so any local changes get # blown away, then update from repo. cd ${BASE} /usr/local/bin/svn revert -R . /usr/local/bin/svn update --non-interactive # Pull stuff we need with curl cd ${DL} getfile http://planet.postgresql.org/rss20.xml planetpostgresql.rss cd ${BASE} # If doing ftp update, rsync the ftp archive if [ "$FTP" == "1" ]; then /usr/local/bin/rsync -avz --delete --exclude "binary/OLD" svr1.postgresql.org::pgsql-ftp /usr/local/www/wwwmaster.postgresql.org/ftp fi # Copy in the static stuff cp -Rp ${BASE}/files ${STATIC}/ cp -Rp ${BASE}/layout ${STATIC}/ # Build the static pages rm -f /tmp/mirror.log /usr/local/bin/php -q ${BASE}/tools/mirror.php -v -l /tmp/mirror.log -o ${STATIC} ${MIRRORPARAM} # Rewrite the mirror list /usr/local/bin/php ${BASE}/tools/mirrorlist.php ${STATIC}/mirrors.xml # Rewrite the application list /usr/local/bin/php ${BASE}/tools/applicationlist.php ${STATIC}/applications-v2.xml # Rewrite the version list cd ${BASE}/tools /usr/local/bin/php ${BASE}/tools/versionlist.php ${STATIC}/versions.xml cd ${BASE} # Copy static htaccess files cp -Rp ${BASE}/tools/htaccess/root ${STATIC}/.htaccess cp -Rp ${BASE}/tools/htaccess/files_documentation ${STATIC}/files/documentation/.htaccess cp -Rp ${BASE}/tools/htaccess/docs ${STATIC}/docs/.htaccess # Copy robots and sitemap files cp -Rp ${BASE}/tools/htaccess/robots.txt ${STATIC}/robots.txt cp -Rp ${BASE}/tools/htaccess/sitemap.xml ${STATIC}/sitemap.xml # Create google account file for webmaster@postgresql.org test -f ${STATIC}/googlece5fa9d11e0cd8c5.html || touch ${STATIC}//googlece5fa9d11e0cd8c5.html # Build htaccess file for ftp tree /usr/local/bin/php ${BASE}/tools/ftplinks.php ${DL}/ftp.htaccess cmp ${DL}/ftp.htaccess ${STATIC}/ftp/.htaccess || cp -Rp ${DL}/ftp.htaccess ${STATIC}/ftp/.htaccess rm -f ${DL}/ftp.htaccess # Touch the timestamp file /bin/date -u "+%Y-%m-%d %H:%M:%S UTC" > ${STATIC}/web_sync_timestamp cp ${STATIC}/web_sync_timestamp ${BASE}/web_sync_timestamp