Skip to content

Instantly share code, notes, and snippets.

@liayn
Last active October 27, 2017 09:43
Show Gist options
  • Save liayn/fab3aea3a78fc4608198 to your computer and use it in GitHub Desktop.
Save liayn/fab3aea3a78fc4608198 to your computer and use it in GitHub Desktop.
TYPO3 Instance Upgrade Script
#!/bin/bash
#
# TYPO3 CMS Upgrade script
#
# (c) Reelworx GmbH, http://reelworx.at
#
# Date: 2016-05-17
# Licence: MIT
#
# Requirements:
# - TYPO3 sources have to be downloaded beforehand manually
# - Instances need to have typo3_console extension installed
# - This script must be run as root (or any other use that may sudo -u for the web users)
#
# folder that contains the TYPO3 CMS sources. Folder have to look like: typo3_src-6.2.10
sources=/opt/typo3cms
# parent folder where all instances are located
webs=/var/www
if [ -z $1 ]; then
echo "Usage: $0 [--dry] <TYPO3 branch>"
exit 1
fi
dry=false
branch=$1
if [ "$1" == "--dry" ]; then
if [ -z $2 ]; then
echo "Usage: $0 [--dry] <TYPO3 branch>"
exit 1
fi
dry=true
branch=$2
fi
version=$(find $sources/* -maxdepth 0 -type d -name "*-$branch*" | sort -V | tail -1)
echo "TYPO3 CMS update script"
echo "Updating instances of branch $branch to version $version"
echo ""
for web in `find $webs -name typo3cms`; do
TYPO3_PATH_WEB=$(dirname $web)
TYPO3_USER=$(stat -c '%U' $TYPO3_PATH_WEB)
TYPO3_SRC=$TYPO3_PATH_WEB/typo3_src
TYPO3_VERSION=$(readlink $TYPO3_SRC | grep -Po '(?<=typo3_src-).*$' )
if [ ! -z $(echo $TYPO3_VERSION | egrep "^$branch") ]; then
echo "----"
echo " ## Updating $TYPO3_PATH_WEB (currently $TYPO3_VERSION)"
if $dry; then
echo "dry-run mode; no action taken"
else
cd $TYPO3_PATH_WEB
./typo3cms backend:lock
rm $TYPO3_SRC
ln -s $version $TYPO3_SRC
sudo -u $TYPO3_USER ./typo3cms cache:flush --force
./typo3cms backend:unlock
fi
fi
done
echo ""
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment