pootle-upgrade-all-extensions 1.62 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash

set -o errtrace
set -o nounset

#  Trap non-normal exit signals: 1/HUP, 2/INT, 3/QUIT, 15/TERM, ERR
trap onexit 1 2 3 15

#--- onexit() -----------------------------------------------------
#  @param $1 integer  (optional) Exit status.  If not set, use `$?'
function onexit() {
	local exit_status=${1:-$?}
	if [ $exit_status -gt 0 ]; then
		echo Exiting $0 with $exit_status
	fi
	exit $exit_status
}

BASE_DIRECTORY="/var/www/vhosts/pootle.typo3.org/pootle/po"
20
21
T3XUTILS=/var/www/vhosts/pootle.typo3.org/home/scripts/bin/t3xutils.phar
UPGRADE_EXTENSION=/var/www/vhosts/pootle.typo3.org/home/scripts/bin/pootle-upgrade-extension
22
23

echo "[INFO] Fetch and cache TER extension metadata"
24
$T3XUTILS updateinfo >/dev/null
25
26
27
28
29
30
31
32
33

cd $BASE_DIRECTORY
PROJECTS=$(find . -maxdepth 1 -type d | egrep 'TYPO3\.TYPO3\.ext\.' | sort)

for PROJECT in $PROJECTS;
do
	EXTENSION=$(echo $PROJECT | cut -b19-)

	echo -n "[INFO] Looking for latest version of $EXTENSION on TER: "
34
	LASTLINE=$($T3XUTILS info $EXTENSION 2>/dev/null | grep -v "Available versions:" | tail -n 1)
35
36
37
38
39
40
41
42
43
44
45
46
47
	if [ -z "$LASTLINE" ]; then
		echo "n/a"
		echo "[ERROR] Extension $EXTENSION does not exist on TER"
	else
		LASTVERSION=$(echo $LASTLINE | awk '{ print $1 }' | egrep '^[0-9.]+$')
		if [ -n "$LASTVERSION" ]; then
			echo $LASTVERSION
			LOCALVERSION=""
			if [ -f $BASE_DIRECTORY/$PROJECT/.ter-version ]; then
				LOCALVERSION=$(cat $BASE_DIRECTORY/$PROJECT/.ter-version)
			fi
			if [ -z "$LOCALVERSION" ] || [ "$LOCALVERSION" != "$LASTVERSION" ]; then
				echo "[INFO] Updating extension $EXTENSION to version $LASTVERSION"
48
				$UPGRADE_EXTENSION $EXTENSION $LASTVERSION
49
50
51
52
53
54
			fi
		fi
	fi
done

onexit