Skip to content

Instantly share code, notes, and snippets.

@jmetzger
Last active August 29, 2015 14:09
Show Gist options
  • Save jmetzger/2870fba95902f27a5a4b to your computer and use it in GitHub Desktop.
Save jmetzger/2870fba95902f27a5a4b to your computer and use it in GitHub Desktop.
Typo3 - Get last released version - for bash script (Typo3 6.2. + Typo3 4.5)
#!/usr/bin/php
<?php
/***
*
* check getopts
*
***/
$typo3version='4.5';
// show only release version
$longopts = array("releaseonly","typo3version::");
$options = getopt("r",$longopts);
if (isset($options['typo3version'])){
switch ($options['typo3version']){
case '6.2':
$typo3version = $options['typo3version'];
break;
}
}
$json = file_get_contents('http://get.typo3.org/json');
$data = json_decode($json,true);
$version=$data[$typo3version]["latest"];
if ($version != ""){
$arr=explode(".",$version);
$version_releaseonly=$arr[2];
}
// something went wrong
else {
exit (1);
}
if (isset($options["releaseonly"])){
echo $version_releaseonly;
exit (0);
}
if (isset($options["r"])){
echo $version_releaseonly;
exit (0);
}
echo $version;
?>

Typo3 - Downloader

Put both files in the same directory. Execute the downloader - script

/bin/bash typo3_download_latest.sh

The script will check, if the downloaded file exists already, if not download it.

So you could easily run this a daily cron.

#!/bin/bash
PHP=$(which php)
DEST_DIR=/usr/src
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$1" != "" ]
then
DEST_DIR=$1
fi
TYPO3_VERSION=$($PHP $DIR"/t3x_showlatest.php" --typo3version=6.2)
WGET=$(which wget)
if [ "$WGET" == "" ]
then
echo "Sorry. Wget is not installed. Giving up"
fi
if [ ! -f $DEST_DIR/typo3_src-${TYPO3_VERSION}.tar.gz ]
then
$WGET get.typo3.org/$TYPO3_VERSION -O $DEST_DIR/typo3_src-${TYPO3_VERSION}.tar.gz
DONE=$?
else
DONE=0
fi
exit $DONE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment