#!/bin/bash #$1=update to version file=contao-$1 tar_file=$file.tar.gz contao_src=/var/www/contao/ date=`date +%F` cd $contao_src #Backup all data tar -czf /var/tmp/contao_full_$date.tar.gz * tar -czf /var/tmp/contao_user_data_$date.tar.gz system/config/dcaconfig.php system/config/localconfig.php system/config/langconfig.php templates/* tl_files/* cd /tmp #Get the new file version wget http://prdownloads.sourceforge.net/typolight/$tar_file?download if [ $? -ne 0 ]; then echo "Unable to download $tar_file. Aborting..."; exit; fi #Extract archive and remove the original tar file tar -xzf $tar_file rm $tar_file cd $file #Get the new file list list=`find . -path "./tl_files" -prune -o -path "./templates" -prune -o -print -type f` for a in $list; do #Skipp some files if [ "$a" = "." -o "$a" = "./system/config/dcaconfig.php" -o "$a" = "./system/config/localconfig.php" -o "$a" = "./system/config/langconfig.php" ]; then echo "$contao_src$a SKIPED!" continue fi #Remove the "./" at the beginning a=${a:2} #Processing Directories if [ -d "$a" ]; then if [ ! -d "$contao_src$a" ]; then echo "$contao_src$a folder does not exist yet!" cp -r --parents $a $contao_src #echo "cp -r --parents $a $contao_src" continue fi echo "$contao_src$a folder exist. Skip..." continue; fi #Processing Files if [ -f "$a" ]; then if [ ! -f "$contao_src$a" ]; then echo "$contao_src$a file does not exist yet!" cp --parents $a $contao_src #echo "cp --parents $a $contao_src" continue fi fi # Diff the files - ignore the output... diff -q --exclude=.svn --exclude=dcaconfig.php --exclude=localconfig.php --exclude=langconfig.php \ --exclude=templates --exclude=tl_files $a $contao_src$a > /dev/null 2>&1 # ...but get the status status=$? case $status in 0) # Files are identical - don't copy the file #echo "$a unchanged" ;; 1) # Files differ - copy new file echo "$a changed" cp --parents $a $contao_src #echo "cp --parents $a $contao_src" ;; 2) # Old file doesn't exist - copy new file echo "old $a does not exist" cp --parents $a $contao_src #echo "cp --parents $a $contao_src" ;; *) echo "So, what to do with $a?" ;; esac done echo "Updated to verstion $1" echo "Please update your database by opening the contao install tool web page and scroll down to the database section and confirm the changes. " exit;