[icinga-checkins] icinga.org: icinga-core/mfriedrich/cgis: idoutils: add update-version-schema for updating the idoutils db schema versions automagically , independant of update-version #1616

git at icinga.org git at icinga.org
Thu Jun 9 14:11:43 CEST 2011


Module: icinga-core
Branch: mfriedrich/cgis
Commit: 0cd3b5225bae669849419b36a2a07290655cc19a
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=0cd3b5225bae669849419b36a2a07290655cc19a

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Sat Jun  4 14:07:11 2011 +0200

idoutils: add update-version-schema for updating the idoutils db schema versions automagically, independant of update-version #1616

refs #1616

---

 Changelog                        |    1 +
 module/idoutils/include/ido2db.h |    2 +-
 update-version                   |   10 ------
 update-version-schema            |   61 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/Changelog b/Changelog
index 6c2fc0b..68f6830 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ Icinga 1.5.x Change Log
 1.5.0 - ??/08/2011
 
 ENHANCEMENTS
+* idoutils: add update-version-schema for updating the idoutils db schema versions automagically, independant of update-version #1616
 
 FIXES
 * core: remove duplicated unlinks for check result files with multiple results #1615
diff --git a/module/idoutils/include/ido2db.h b/module/idoutils/include/ido2db.h
index fa84824..bcf92a0 100644
--- a/module/idoutils/include/ido2db.h
+++ b/module/idoutils/include/ido2db.h
@@ -16,7 +16,7 @@
 #define IDO2DB_DATE "08-17-2011"
 #define IDO2DB_VERSION "1.5.0"
 
-#define IDO2DB_SCHEMA_VERSION "1.4.0"
+#define IDO2DB_SCHEMA_VERSION "1.5.0"
 
 /*************** RDBMS headers *************/
 
diff --git a/update-version b/update-version
index 4e31c1d..b99db4e 100755
--- a/update-version
+++ b/update-version
@@ -94,14 +94,4 @@ perl -i -p -e "s/FILE2SOCK_DATE \".*\"/FILE2SOCK_DATE \"$SHORTDATE\"/;" module/i
 perl -i -p -e "s/LOG2IDO_VERSION \".*\"/LOG2IDO_VERSION \"$newversion\"/;" module/idoutils/src/log2ido.c
 perl -i -p -e "s/LOG2IDO_DATE \".*\"/LOG2IDO_DATE \"$SHORTDATE\"/;" module/idoutils/src/log2ido.c
 
-# Update dbversion in IDOUtils
-# mysql INSERT INTO icinga_dbversion (name, version) VALUES ('idoutils', '1.3.0') ON DUPLICATE KEY UPDATE version='1.3.0';
-# pgsql SELECT updatedbversion('1.3.0');
-# oracle DEFINE ICINGA_VERSION=1.3.0
-
-perl -i -p -e "s/VALUES \(\'idoutils\', \'.*\'\)/VALUES \(\'idoutils\', \'$newversion\'\)/;" module/idoutils/db/mysql/mysql.sql
-perl -i -p -e "s/version=\'.*\'/version=\'$newversion\'/;" module/idoutils/db/mysql/mysql.sql
-perl -i -p -e "s/updatedbversion\(\'.*\'\)/updatedbversion\(\'$newversion\'\)/;" module/idoutils/db/pgsql/pgsql.sql
-perl -i -p -e "s/ICINGA_VERSION=.*/ICINGA_VERSION=$newversion/;" module/idoutils/db/oracle/oracle.sql
-
 
diff --git a/update-version-schema b/update-version-schema
new file mode 100755
index 0000000..510d52f
--- /dev/null
+++ b/update-version-schema
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# Get date (two formats)
+if [ -n "$2" ]; then
+    LONGDATE=`date -d "$2" "+%B %d, %Y"`
+    SHORTDATE=`date -d "$2" "+%m-%d-%Y"`
+else
+    LONGDATE=`date "+%B %d, %Y"`
+    SHORTDATE=`date "+%m-%d-%Y"`
+fi
+
+# Current version number
+CURRENTVERSION=1.5.0
+
+# Last date
+LASTDATE=08-17-2011
+
+if [ "x$1" = "x" ]
+then
+	echo "Usage: $0 <version number | \"newdate\"> [revision date]"
+	echo ""
+	echo "Run this script with the name of the new version (i.e \"2.0b1\") to"
+	echo "update version number and modification date in files."
+	echo "Use the \"newdate\" argument if you want to keep the current version"
+	echo "number and just update the modification date."
+	echo ""
+	echo "Current version=$CURRENTVERSION"
+	echo "Current Modification date=$LASTDATE"
+	echo ""
+	exit 1
+fi
+
+# Keep track of last version, as it is needed to update quickstart guide pages
+lastversion=$CURRENTVERSION
+
+# What's the new version number (if any)?
+newversion=$1
+if [ "x$newversion" = "xnewdate" ]
+then
+    # No new version number, just a new version date
+    newversion=$CURRENTVERSION
+fi
+
+# Update this file with version number and last date
+perl -i -p -e "s/^CURRENTVERSION=.*/CURRENTVERSION=$newversion/;" update-version-schema
+perl -i -p -e "s/^LASTDATE=.*/LASTDATE=$SHORTDATE/;" update-version-schema
+
+# Update schema version in IDOUtils
+perl -i -p -e "s/IDO2DB_SCHEMA_VERSION \".*\"/IDO2DB_SCHEMA_VERSION \"$newversion\"/;" module/idoutils/include/ido2db.h
+
+# Update dbversion in IDOUtils
+# mysql INSERT INTO icinga_dbversion (name, version) VALUES ('idoutils', '1.3.0') ON DUPLICATE KEY UPDATE version='1.3.0';
+# pgsql SELECT updatedbversion('1.3.0');
+# oracle DEFINE ICINGA_VERSION=1.3.0
+
+perl -i -p -e "s/VALUES \(\'idoutils\', \'.*\'\)/VALUES \(\'idoutils\', \'$newversion\'\)/;" module/idoutils/db/mysql/mysql.sql
+perl -i -p -e "s/version=\'.*\'/version=\'$newversion\'/;" module/idoutils/db/mysql/mysql.sql
+perl -i -p -e "s/updatedbversion\(\'.*\'\)/updatedbversion\(\'$newversion\'\)/;" module/idoutils/db/pgsql/pgsql.sql
+perl -i -p -e "s/ICINGA_VERSION=.*/ICINGA_VERSION=$newversion/;" module/idoutils/db/oracle/oracle.sql
+
+





More information about the icinga-checkins mailing list