[Mapbender-commits] r5165 - trunk/mapbender/resources/db
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sat Dec 12 07:39:17 EST 2009
Author: astrid_emde
Date: 2009-12-12 07:39:17 -0500 (Sat, 12 Dec 2009)
New Revision: 5165
Added:
trunk/mapbender/resources/db/update.sh
Log:
script to update an existing Mapbender installation
Added: trunk/mapbender/resources/db/update.sh
===================================================================
--- trunk/mapbender/resources/db/update.sh (rev 0)
+++ trunk/mapbender/resources/db/update.sh 2009-12-12 12:39:17 UTC (rev 5165)
@@ -0,0 +1,146 @@
+#!/bin/bash
+#
+# create database for mapbender
+#
+
+function show_disclaimer() {
+ # Disclaimer
+ echo ""
+ echo "DISCLAIMER: this Mapbender database setup script is not stable. USE AT YOUR OWN RISK!"
+ echo "The script will create a database for you and will import the Mapbender data to the new database"
+ echo "It will also compile the Mapbender.mo files"
+ echo ""
+ echo "To run this script you have to set the following options"
+ # echo " * set the right to execute on this install script"
+ # echo " * set the right to execute on mapbender/tools/i18n_update_mo.sh"
+ # echo " * write access to mapbender/log"
+ # echo " * write access to mapbender/http/tmp"
+ # echo " * write access to mapbender/resources/locale/ and subdirectories"
+ echo " * provide a database user that can create a database"
+ echo ""
+ echo ""
+ echo "If everything is prepared you can continue."
+ echo ""
+}
+
+function del_logfile() {
+ rm log_*.txt
+ rm err_*.txt
+
+}
+
+#get Database Configuration
+function get_db_config(){
+ until [ "$DBVERSION" = "p" -o "$DBVERSION" = "m" ]
+ do
+ echo ""
+ echo "database version? (p)ostgresql or (m)ysql?"
+ read DBVERSION
+ done
+
+ # db encoding
+ until [ "$DBENCODING" = "i" -o "$DBENCODING" = "u" ]
+ do
+ echo ""
+ echo "database character encoding? (i)so-8859-1 or (u)tf-8?"
+ read DBENCODING
+ done
+
+
+ # db name
+ until [ -n "$DBNAME" ]
+ do
+ echo ""
+ echo "database name?"
+ read DBNAME
+ done
+
+ #nicer vars
+ if [ "$DBVERSION" = "p" ]
+ then
+ DBVERSION="pgsql"
+ else
+ DBVERSION="mysql"
+ fi
+
+
+ echo ""
+ echo "database host (e.g. localhost)?"
+ read DBHOST
+
+ echo ""
+ echo "database port (e.g. 5432 for postgres, 3306 for mysql)?"
+ read DBPORT
+
+
+ echo ""
+ echo "database user?"
+ read DBUSER
+
+#using a password via commandline oder as shell var could lead to security problems, so we don't do it
+# echo ""
+# echo "Password for $DBUSER (will not be shown)?"
+# stty -echo
+# read DBPASSWORD
+# stty echo
+
+}
+
+function create_mysql_db(){
+ which mysql > /dev/null
+ if [ $? -ne 0 ]
+ then
+ echo "commando mysql, but not found, exiting..."
+ echo "is mysql installed?"
+ echo ""
+ exit 1;
+ fi
+
+ echo "update to 2.6.1"
+ mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.6_to_2.6.1_mysql_$DBENCODING.sql >> log_update.txt 2>> err_update.txt
+ echo "update to 2.7"
+ mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.6.1_to_2.7_mysql_$DBENCODING.sql >> log_update.txt 2>> err_update.txt
+
+
+}
+
+#Create Database (Postgres)
+function create_pgsql_db(){
+ which psql createdb > /dev/null
+ if [ $? -ne 0 ]
+ then
+ echo "commando pgsql or createdb needed, but not found, exiting..."
+ echo "is PostgreSQL installed?"
+ echo ""
+ exit 1;
+ fi
+ echo "update to 2.6.1"
+ psql -U $DBUSER -h $DBHOST -p $DBPORT -f pgsql/$DBENCODING/update/update_2.6_to_2.6.1_pgsql_$DBENCODING.sql $DBNAME >> log_update.txt 2>> err_update.txt
+ echo "update to 2.7"
+ psql -U $DBUSER -h $DBHOST -p $DBPORT -f pgsql/$DBENCODING/update/update_2.6.1_to_2.7rc1_pgsql_$DBENCODING.sql $DBNAME >> log_update.txt 2>> err_update.txt
+
+}
+
+
+
+#magic starts here
+show_disclaimer;
+get_db_config;
+show_db_config;
+
+if [ $DBVERSION = "pgsql" ]
+then
+ echo "Updating Postgres Database"
+ create_pgsql_db;
+else
+ echo "Upting Mysql Database"
+ create_mysql_db;
+ echo ""
+fi
+
+
+
+echo ""
+echo "Update finished...check the log and error files to see if an error occured.";
+
+
More information about the Mapbender_commits
mailing list