diff --git a/modules/openstackid/files/functions b/modules/openstackid/files/functions index 6fcfaf2e51..4a5b22a3a2 100644 --- a/modules/openstackid/files/functions +++ b/modules/openstackid/files/functions @@ -31,6 +31,10 @@ function site_init() { chown $FILE_OWNER:$FILE_GROUP $SITE_ROOT/$dir done target_dir="$SITE_ROOT/slot0" + # fetch catalog and write actual version + fetch_catalog + RELEASE_VERSION=`catalog_get_version` + echo $RELEASE_VERSION > $SITE_ROOT/slot0/release # fetch and extract release tarball umask 0027 if [[ $SOURCE_TARBALL == http* ]]; then @@ -86,10 +90,28 @@ function site_status() { exit 1 fi else - echo "INSTALLED" + fetch_catalog + REMOTE_VERSION=`catalog_get_version` + RELEASE_VERSION=$(head -n 1 $SITE_ROOT/w/release) + if [ "$REMOTE_VERSION" == "$RELEASE_VERSION" ]; then + echo "INSTALLED [$RELEASE_VERSION]" + else + echo "UPDATE AVAILABLE [$RELEASE_VERSION-$REMOTE_VERSION]" + fi fi } +function fetch_catalog() { + curl --silent $SOURCE_ROOT > $SITE_ROOT/releases.lst + grep -q "^<!DOCTYPE HTML PUBLIC" $SITE_ROOT/releases.lst +} + +function catalog_get_version() { + RAW_LINE=`cat $SITE_ROOT/releases.lst | grep "$RELEASE_NAME" | sed "s/<[^>]\+>//g" | sed -r "s/^$RELEASE_NAME//"` + RELEASE_DATE=`echo $RAW_LINE | awk '{ print $1 " " $2}'` + echo $RELEASE_DATE +} + function site_update() { if [ ! $1 ]; then echo "ERROR: missing site parameter" diff --git a/modules/openstackid/templates/openstackid.conf.erb b/modules/openstackid/templates/openstackid.conf.erb index 30e81c2f7d..9d11831986 100644 --- a/modules/openstackid/templates/openstackid.conf.erb +++ b/modules/openstackid/templates/openstackid.conf.erb @@ -1,3 +1,5 @@ SITE_ROOT=/srv/openstackid SOURCE_TARBALL=http://tarballs.openstack.org/openstackid/openstackid-latest.tar.gz -LARAVEL_ENV=dev \ No newline at end of file +LARAVEL_ENV=dev +RELEASE_NAME=openstackid-latest.tar.gz +SOURCE_ROOT=http://tarballs.openstack.org/openstackid/ \ No newline at end of file