Skip to content

Sysadmin grodoudou update wikizam git tag 18 06 2012

Yannouk edited this page Jul 5, 2012 · 1 revision

This script is located at /root/update-and-deploy-wikizam-tag.sh

To use it, call: /root/update-and-deploy-wikizam-tag.sh <Git tag>

#!/bin/sh

cd /root/seizam-git/seizamcore

# Read php tag argument
if [ $# -lt 1 ]
then
        echo "missing tag parameter, known available tag: "
	git tag
	exit 1
fi

echo "Updating /var/wikizam/versions/ using specified git TAG and deploy it"
echo "--------------------------------------------------------------------"

echo "Downloading WikiZam $1 release from Seizam Git..."
git pull origin master
if [ ! $? -eq 0 ]; then
	echo "Error while fetching git repository"
	exit 1
fi

git checkout $1
if [ ! $? -eq 0 ]; then
	echo "Error getting the tagged revision"
	exit 1
fi

echo "Graceful stopping Apache2..."
/etc/init.d/apache2 graceful-stop

echo "Backup MediaWiki Widgets extension compiled templates..."
rm -rf /var/wikizam/_compiled_templates_to_restore
mkdir -p /var/wikizam/_compiled_templates_to_restore
cp -R /var/wikizam/deployed/extensions/Widgets/compiled_templates/* /var/wikizam/_compiled_templates_to_restore

echo "Displaying maintenance message..."
rm /var/wikizam/deployed
ln -s /var/wikizam/maintenance /var/wikizam/deployed

echo "Starting Apache2..."
/etc/init.d/apache2 start

echo "Updating $1 'versions' folder..."
mkdir -p /var/wikizam/versions/$1
rm -Rf /var/wikizam/versions/$1/*
cp -R /root/seizam-git/seizamcore/WikiZam/* /var/wikizam/versions/$1

echo "Using _ServerSettings.php as the config file..."
rm -f /var/wikizam/versions/$1/ServerSettings.php
cp /var/wikizam/_ServerSettings.php /var/wikizam/versions/$1/ServerSettings.php

echo "Restore MediaWiki Widgets extension compiled templates..."
mv /var/wikizam/_compiled_templates_to_restore/* /var/wikizam/versions/$1/extensions/Widgets/compiled_templates
rm -R /var/wikizam/_compiled_templates_to_restore

echo "Setting file rights and ownership..."
chgrp -R www-data /var/wikizam/versions/$1/*
chmod -R 750 /var/wikizam/versions/$1/*
chmod -R 770 /var/wikizam/versions/$1/extensions/Widgets/compiled_templates

echo "Running update.php script, can take a while..."
cd /var/wikizam/versions/$1
php maintenance/update.php --quick

echo "Graceful stopping Apache2..."
/etc/init.d/apache2 graceful-stop

echo "Removing maintenance message..."
rm /var/wikizam/deployed
ln -s /var/wikizam/versions/$1/ /var/wikizam/deployed

echo "Starting Apache2..."
/etc/init.d/apache2 start

echo "END"
cd /root
Clone this wiki locally