#!/bin/bash # # pmwiki management script. # BASE="<%= scope.lookupvar('pmwiki::www_folder') %>" # Check for existing installations function pmwiki_check_existing { if [ -e "$BASE/pmwiki-$1" ]; then echo "Folder $BASE/pmwiki-$1 already exists, skipping." exit 1 fi } # Deploy a fresh pmwiki tree function pmwiki_deploy { if [ "$#" != "1" ]; then echo "Usage: `basename $0` deploy " exit 1 fi # Setup new="$1" cd $BASE pmwiki_check_existing $new # Deploy a fresh pmwiki tree wget http://pmwiki.org/pub/pmwiki/pmwiki-$new.tgz wget http://pmwiki.org/pub/pmwiki/i18n/i18n-all.zip tar zxvf pmwiki-$new.tgz && rm pmwiki-$new.tgz ( cd pmwiki-$new && unzip -o ../i18n-all.zip && rm $_ ) if [ ! -e "pmwiki-$new/index.php" ]; then ( cd pmwiki-$new && ln -s pmwiki.php index.php ) fi chown -R root.root pmwiki-$new/ } # Upgrade a pmwiki instance using upstream source. function pmwiki_upgrade { if [ "$#" != "2" ]; then echo "Usage: `basename $0` upgrade " exit 1 fi # Setup old="$1" new="$2" extra_folders="" pmwiki_check_existing $new cd $BASE cp -a pmwiki-$old pmwiki-$old.backup # Deploy a fresh pmwiki tree pmwiki_deploy $new # Copy files for file in .htaccess index.php farmconfig.php local config.php wiki.d; do if [ -e "pmwiki-$old/$file" ]; then cp -a pmwiki-$old/$file pmwiki-$new/ fi done for extra_folder in $extra_folders; do if [ -d ../pmwiki-$old/$extra_folder ]; then cp -Rp ../pmwiki-$old/$extra_folder . fi done # Themes and cookbook rsync -av pmwiki-$old/cookbook/ pmwiki-$new/cookbook rsync -av --exclude=pmwiki --exclude=print pmwiki-$old/pub/skins/ pmwiki-$new/pub/skins/ # Change symlink to point to the new location cd $BASE ; rm -f wiki && ln -s pmwiki-$new wiki # Done echo "Audit: `du -hs pmwiki-$old`" echo "Audit: `du -hs pmwiki-$new`" echo "Check procedure and remove pmwiki-$old once you make sure that everything is fine." } # Main procedure if [ -z "$1" ]; then echo "Usage: `basename $0` [arguments]" exit 1 elif [ "$1" == "deploy" ]; then shift pmwiki_deploy $* elif [ "$1" == "upgrade" ]; then shift pmwiki_upgrade $* fi