[Mapbender-commits] r5541 - trunk/mapbender/resources/db

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sat Feb 20 06:13:04 EST 2010


Author: tbaschetti
Date: 2010-02-20 06:13:04 -0500 (Sat, 20 Feb 2010)
New Revision: 5541

Modified:
   trunk/mapbender/resources/db/install.sh
Log:
dropped mysql and ISO-8859-1 support
added support for commandline args



Modified: trunk/mapbender/resources/db/install.sh
===================================================================
--- trunk/mapbender/resources/db/install.sh	2010-02-20 11:12:49 UTC (rev 5540)
+++ trunk/mapbender/resources/db/install.sh	2010-02-20 11:13:04 UTC (rev 5541)
@@ -6,7 +6,7 @@
 function show_disclaimer() {
     # Disclaimer
     echo ""
-    echo "DISCLAIMER: this Mapbender database setup script is not stable. USE AT YOUR OWN RISK!"
+    echo "DISCLAIMER: Mapbender database setup script. 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 ""
@@ -20,7 +20,16 @@
     echo ""
     echo ""
     echo "If everything is prepared you can continue."
+    echo "-------"
     echo ""
+    echo "You can give nearly all arguments on commandline:"
+    echo "$0 <HOST> <PORT> <DBNAME> <DBTEMPLATE> <DBUSER>"
+    echo ""
+    echo "e.g."
+    echo "$0 localhost 5432 mapbender template0 postgres"
+    echo ""
+    echo "------"
+    echo ""
 }
 
 function del_logfile() {
@@ -31,63 +40,34 @@
 
 #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
+   #ask for database host
+    echo ""
+    echo "database host (e.g. localhost)?"
+    read DBHOST
+	: ${DBHOST:="localhost"}
 
-   #ask for database template
-    if [ "$DBVERSION" = "p" ]
-    then
-        echo ""
-        echo "database template to use (just hit return for default template0)?"
-        read DBTEMPLATE
-        : ${DBTEMPLATE:="template0"}
-    fi
+   #ask for database port
+    echo ""
+    echo "database port (e.g. 5432 for postgres)?"
+    read DBPORT
+	: ${DBPORT:="5432"}     
+        
     # db name
     until [ -n "$DBNAME" ]
     do
         echo ""
         echo "database name?"
         read DBNAME
-    done
+    done    
 
-    #nicer vars
-    if [  "$DBVERSION" = "p" ]
-    then
-        DBVERSION="pgsql"
-    else
-        DBVERSION="mysql"
-    fi
-
-    if [  "$DBENCODING" = "i" ]
-    then
-        DBENCODING="ISO-8859-1"
-    else
-        DBENCODING="UTF-8"
-    fi
-
+	#ask for database template
+        echo ""
+        echo "database template to use (just hit return for default template0)?"
+        read DBTEMPLATE
+        : ${DBTEMPLATE:="template0"}
+   
     echo ""
-    echo "database host (e.g. localhost)?"
-    read DBHOST
-	: ${DBHOST:="localhost"}
-
-    echo ""
-    echo "database port (e.g. 5432 for postgres, 3306 for mysql)?"
-    read DBPORT
-	: ${DBPORT:="5432"}
-
-    echo ""
     echo "database user?"
     read DBUSER
 
@@ -100,6 +80,18 @@
 
 }
 
+#set Database Configuration from commandline
+function set_db_config(){
+	echo ""
+    echo "set variables to input:"
+	DBHOST=$1
+	DBPORT=$2
+	DBNAME=$3
+	DBTEMPLATE=$4
+	DBUSER=$5
+}
+
+
 #show Database Configuration
 function show_db_config(){
     echo ""
@@ -118,46 +110,14 @@
 
 }
 
-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 "Your password will be asked several times, this is normal"
-    echo "creating database"
-    if [ $DBENCODING = "ISO-8859-1" ]
-    then
-        mysql -e "create database $DBNAME CHARACTER SET latin1 COLLATE latin1_german1_ci;" -p$DBPASSWORD -u $DBUSER
-    else
-        mysql -e "create database $DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;" -p$DBPASSWORD -u $DBUSER
-    fi
-	echo "creating schema"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/mysql_schema_2.5.sql > log_schema.txt 2> err_schema.txt
-	echo "loading data"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/mysql_data_2.5.sql > log_data.txt 2> err_data.txt
-	echo "update to 2.5.1rc1"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.5_to_2.5.1rc1_mysql_$DBENCODING.sql > log_update.txt 2> err_update.txt
-	echo "update to 2.5.1"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.5.1rc1_to_2.5.1_mysql_$DBENCODING.sql >> log_update.txt 2>> err_update.txt
-	echo "update to 2.6rc1"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.5.1_to_2.6rc1_mysql_$DBENCODING.sql >> log_update.txt 2>> err_update.txt
-	echo "update to 2.6"
-	mysql $DBNAME -p$DBPASSWORD -u $DBUSER -h $DBHOST -P $DBPORT < mysql/$DBENCODING/update/update_2.6rc1_to_2.6_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 "commando psql or createdb needed, but not found, exiting..."
         echo "is PostgreSQL installed?"
         echo ""
         exit 1;
@@ -242,13 +202,23 @@
 #magic starts here
 show_disclaimer;
 
-echo "Continue? (y)es or (n)o"
-read disclaimer
-if test $disclaimer != "y"
+# we only support postgresql and utf-8
+DBENCODING="UTF-8"
+DBVERSION="pgsql"
+if [ $# -ne 5 ]
 then
-	exit 1
-fi
-get_db_config;
+	echo "Continue? (y)es or (n)o"
+	read disclaimer
+	if test $disclaimer != "y"
+	then
+		exit 1
+	fi
+	echo "get_db_config - variables have to be set"	
+	get_db_config;
+else
+	echo "set_db_config - variables where passed when the script was called"
+	set_db_config $@;
+fi;
 show_db_config;
 echo "Look ok? Start Install? (y)es or (n)o"
 read ANSWER
@@ -257,15 +227,8 @@
     exec $0
 fi
 
-if [ $DBVERSION = "pgsql" ]
-then
-    echo "Creating Postgres Database with encoding:$DBENCODING"
-    create_pgsql_db;
-else
-    echo "Creating Mysql Database with encoding:$DBENCODING"
-    create_mysql_db;
-    echo ""
-fi
+echo "Creating Mapbender administration database"
+create_pgsql_db;
 
 set_permissions;
 compile_po;



More information about the Mapbender_commits mailing list