[Mapbender-commits] r5536 - trunk/mapbender/resources/db
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Sat Feb 20 05:14:40 EST 2010
Author: tbaschetti
Date: 2010-02-20 05:14:40 -0500 (Sat, 20 Feb 2010)
New Revision: 5536
Modified:
trunk/mapbender/resources/db/update.sh
Log:
dropped nonexistent support for mysql-databases and ISO-8859-1 character set
cleaned up a little bit
Modified: trunk/mapbender/resources/db/update.sh
===================================================================
--- trunk/mapbender/resources/db/update.sh 2010-02-20 10:07:40 UTC (rev 5535)
+++ trunk/mapbender/resources/db/update.sh 2010-02-20 10:14:40 UTC (rev 5536)
@@ -7,14 +7,18 @@
# Disclaimer
echo ""
echo "DISCLAIMER: Mapbender update script. USE AT YOUR OWN RISK!"
- echo "The script will run the update SQLs"
+ echo "The script will run the update SQLs to update you Mapbender database"
echo ""
echo "-------"
echo ""
- echo "./update.sh pgsql localhost 5432 mapbender postgres UTF-8"
+ echo "You can give all arguments on commandline:"
+ echo "$0 <HOST> <PORT> <DBNAME> <DBUSER>"
echo ""
+ echo "e.g."
+ echo "./update.sh localhost 5432 mapbender postgres"
+ echo ""
echo "------"
- echo "DBVERSION ENCODING HOST PORT DBNAME DBUSER"
+
echo ""
}
@@ -26,15 +30,17 @@
#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
- : ${DBVERSION:="p"}
- done
+ echo ""
+ echo "database host (e.g. localhost)?"
+ read DBHOST
+ : ${DBHOST:="localhost"}
+ echo ""
+ echo "database port (e.g. 5432 for postgres)?"
+ read DBPORT
+ : ${DBPORT:="5432"}
+
# db name
until [ -n "$DBNAME" ]
do
@@ -43,100 +49,47 @@
read DBNAME
done
- #nicer vars
- if [ "$DBVERSION" = "p" ]
- then
- DBVERSION="pgsql"
- else
- DBVERSION="mysql"
- fi
-
-
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
- # db encoding
- echo ""
- echo "database character encoding? (i)so-8859-1 or (u)tf-8?"
- read DBENCODING
- : ${DBENCODING:="u"}
-
- if ["$DBENCODING" = "i" ]
- then
- DBENCODING="ISO-8859-1"
- else
- DBENCODING="UTF-8"
- fi
-
-
#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
-
}
#show Database Configuration
function show_db_config(){
echo ""
echo "Database Configuration:"
- echo "version:" $DBVERSION
+ echo "Database:" $DBVERSION
+ echo "encoding:" $DBENCODING
echo "db host:" $DBHOST
echo "db port:" $DBPORT
echo "dbname:" $DBNAME
echo "user:" $DBUSER
- echo "encoding:" $DBENCODING
}
#show Database Configuration
function set_db_config(){
echo ""
- echo "xxxx" $1 $2 $3 $4
echo "set variables to input:"
- DBVERSION='postgreql'
- DBHOST=$2
- DBPORT=$3
- DBNAME=$4
- DBUSER=$5
+ DBHOST=$1
+ DBPORT=$2
+ DBNAME=$3
+ DBUSER=$4
}
-function run_mysql_update(){
- 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 run_pgsql_update(){
- which psql createdb > /dev/null
+ which psql > /dev/null
if [ $? -ne 0 ]
then
- echo "commando pgsql or createdb needed, but not found, exiting..."
+ echo "commando 'psql' needed, but not found, exiting..."
echo "is PostgreSQL installed?"
echo ""
exit 1;
@@ -148,25 +101,20 @@
}
-
-
#magic starts here
show_disclaimer;
-if [ $# -lt 1 ]
+
+#we only support postgres/utf8
+DBENCODING="UTF-8"
+DBVERSION="pgsql"
+
+if [ $# -ne 4 ]
then
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;
- echo ""
- echo "set variables to input:"
- DBVERSION=$1
- DBHOST=$2
- DBPORT=$3
- DBNAME=$4
- DBUSER=$5
- DBENCODING=$6
+ set_db_config $@;
fi;
show_db_config;
@@ -174,15 +122,7 @@
then
echo "Updating Postgres Database"
run_pgsql_update;
-else
- echo "Upting Mysql Database"
- run_mysql_update;
- 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