[Mapbender-commits] r4426 - branches/2.5/resources/db
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jul 28 09:09:58 EDT 2009
Author: christoph
Date: 2009-07-28 09:09:58 -0400 (Tue, 28 Jul 2009)
New Revision: 4426
Added:
branches/2.5/resources/db/install_2.5.2.bat
branches/2.5/resources/db/install_2.5.2.sh
Log:
http://trac.osgeo.org/mapbender/ticket/303
Added: branches/2.5/resources/db/install_2.5.2.bat
===================================================================
--- branches/2.5/resources/db/install_2.5.2.bat (rev 0)
+++ branches/2.5/resources/db/install_2.5.2.bat 2009-07-28 13:09:58 UTC (rev 4426)
@@ -0,0 +1,169 @@
+ at echo off
+rem $id: $
+REM Script to install Mapbender 2.5 database
+REM
+setlocal
+REM Delete old Logfiles
+del log_*.txt
+del err_*.txt
+:PREP
+echo.
+echo ==============================================================================
+REM Disclaimer
+echo.
+echo DISCLAIMER: this Mapbender database setup script is not stable. USE AT YOUR OWN RISK!
+echo This script will create a database for you and will import the Mapbender data to the new database
+echo It will possibly also compile the Mapbender.mo files
+echo.
+echo You need:
+echo - a running postgresql or mysql database
+echo - database user with write access
+echo.
+echo If everything is prepared you can continue.
+echo.
+echo ==============================================================================
+echo.
+echo Continue?
+set /p PREPARED="(y)es or (n)o:"
+
+if %PREPARED%==y goto :PREP_OK
+if %PREPARED%==n goto :End
+goto :PREP
+:PREP_OK
+
+rem Database
+:DB_TYPE
+echo.
+echo Which Database?
+set /p DBTYPE="(p)ostgresql or (m)ysql:"
+
+if %DBTYPE%==p goto :DB_PG
+if %DBTYPE%==m goto :DB_MYSQL
+goto :DB_TYPE
+
+:DB_PG
+set USEDBTYPE=PostgreSQL
+:DB_MYSQL
+IF %USEDBTYPE%x==x set USEDBTYPE=Mysql
+
+
+REM Encoding
+:DB_ENC
+echo.
+echo Which Encoding?
+set /p DBENC="(u)tf-8 or (i)so-8859-1/latin1:"
+
+if %DBENC%==u goto :DB_UTF
+if %DBENC%==i goto :DB_ISO
+goto :DB_ENC
+
+:DB_UTF
+set USEDBENC=UTF-8
+:DB_ISO
+IF %USEDBENC%x==x set USEDBENC=ISO-8859-1
+
+
+echo.
+set /p DBUSER="Database user:"
+echo.
+
+rem Password
+rem echo.
+echo Database Password will be asked many times during install...
+
+echo.
+set /p DBNAME="Database name:"
+
+:CHOICES
+echo.
+echo Your Choices:
+echo Databasetype: %DBTYPE% - %USEDBTYPE%
+echo Encoding: %DBENC% - %USEDBENC%
+echo Database Name: %DBNAME%
+echo Database User: %DBUSER%
+echo Database Password: %DBPASSWORD% (not shown)
+echo.
+echo Looks ok, start install?
+echo.
+set /p START_INSTALL="(y)es or (n)o? "
+if %START_INSTALL%==y goto START_INSTALL
+goto PREP
+:START_INSTALL
+rem echo on
+
+if %USEDBTYPE% == PostgreSQL goto INSTPOSTGRESQL
+if %USEDBTYPE% == Mysql goto INSTMYSQL
+
+:INSTPOSTGRESQL
+REM do these exist?
+psql --version 2> nul 1> nul
+if NOT %ERRORLEVEL% == 0 goto PGNOTFOUND
+set /p DBTEMPLATE="database template to use (just hit return for default):"
+
+IF %DBTEMPLATE%x==x set DBTEMPLATE=template0
+
+echo creating db
+createdb -U %DBUSER% -E %USEDBENC% -T %DBTEMPLATE% %DBNAME% "Mapbender Database Version 2.5"
+echo creating schema
+psql -U %DBUSER% -f pgsql/pgsql_schema_2.5.sql %DBNAME% 1>log_schema.txt 2> err_schema.txt
+echo importing data
+psql -U %DBUSER% -f pgsql/%USEDBENC%/pgsql_data_2.5.sql %DBNAME% 1>log_data.txt 2> err_data.txt
+echo setting sequences
+psql -U %DBUSER% -f pgsql/pgsql_serial_set_sequences_2.5.sql %DBNAME% 1>log_sequences.txt 2> err_sequences.txt
+
+echo performing updates
+echo to 2.5.1rc1
+psql -U %DBUSER% -f pgsql/%USEDBENC%/update/update_2.5_to_2.5.1rc1_pgsql_%USEDBENC%.sql %DBNAME% 1>log_update.txt 2> err_update.txt
+echo to 2.5.1
+psql -U %DBUSER% -f pgsql/%USEDBENC%/update/update_2.5.1rc1_to_2.5.1_pgsql_%USEDBENC%.sql %DBNAME% 1>>log_update.txt 2>> err_update.txt
+
+
+goto END
+
+:INSTMYSQL
+mysql --version 2> nul 1> nul
+
+if not %ERRORLEVEL% == 0 goto MYSQLNOTFOUND
+echo creating database
+if %USEDBENC% == ISO-8859-1 mysql -u %DBUSER% -e "create database %DBNAME% character set latin1 COLLATE latin1_german1_ci;" -p
+if %USEDBENC% == UTF-8 mysql -e "create database %DBNAME% character set utf8 COLLATE utf8_general__ci;" -p
+echo creating schema
+mysql %DBNAME% -p -u %DBUSER% < mysql/mysql_schema_2.5.sql > log_schema.txt 2> err_schema.txt
+echo loading data
+mysql %DBNAME% -p -u %DBUSER% < mysql/%USEDBENC%/mysql_data_2.5.sql > log_data.txt 2> err_data.txt
+echo update to 2.5.1rc1
+mysql %DBNAME% -p -u %DBUSER% < mysql/%USEDBENC%/update/update_2.5_to_2.5.1rc1_mysql_%USEDBENC%.sql > log_update.txt 2> err_update.txt
+echo update to 2.5.1
+mysql %DBNAME% -p -u %DBUSER% < mysql/%USEDBENC%/update/update_2.5.1rc1_to_2.5.1_mysql_%USEDBENC%.sql >> log_update.txt 2>> err_update.txt
+
+
+rem update .po files
+
+echo ""
+msgfmt --version 2> nul 1> nul
+if NOT %ERRORLEVEL% == 0 goto MSGFMTNOTFOUND
+echo "Compiling .po files..."
+pushd ../../tools/
+findstr /v ^# i18n_update_mo.sh > i18n_update_mo.bat
+call i18n_update_mo.bat
+del i18n_update_mo.bat
+popd
+goto END:
+
+:MSGFMTNOTFOUND
+echo Sorry, msgfmt not found, must be in PATH-Variable, won't compile translations...
+echo Have a look at http://www.mapbender.org/Gettext#Utility_programms for msgfmt.
+goto END:
+goto END:
+:PGNOTFOUND
+echo Sorry, psql not found, must be in PATH-Variable, exiting...
+goto END
+:MYSQLNOTFOUND
+echo Sorry, mysql not found, must be in PATH-Variable, exiting...
+goto END
+
+REM End, keep Terminal session open
+:END
+endlocal
+echo Finished...check the log files to see if an error occured.
+pause
Added: branches/2.5/resources/db/install_2.5.2.sh
===================================================================
--- branches/2.5/resources/db/install_2.5.2.sh (rev 0)
+++ branches/2.5/resources/db/install_2.5.2.sh 2009-07-28 13:09:58 UTC (rev 4426)
@@ -0,0 +1,239 @@
+#!/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
+
+ #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
+ # 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
+
+ if [ "$DBENCODING" = "i" ]
+ then
+ DBENCODING="ISO-8859-1"
+ else
+ DBENCODING="UTF-8"
+ fi
+
+ 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
+
+}
+
+#show Database Configuration
+function show_db_config(){
+ echo ""
+ echo "Database Configuration:"
+ echo "version:" $DBVERSION
+ echo "encoding:" $DBENCODING
+ if [ $DBTEMPLATE ]
+ then
+ echo "postgres template:" $DBTEMPLATE
+ fi
+ echo "dbname:" $DBNAME
+ echo "user:" $DBUSER
+ 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 "MYSQL-Version not available!!!"
+ echo ""
+ exit 1
+ if [ $DBENCODING = "ISO-8859-1" ]
+ then
+ mysql -e "create database $DBNAME CHARACTER SET latin1 COLLATE latin1_german1_ci;" -p$DBPASSWORD
+ else
+ mysql -e "create database $DBNAME CHARACTER SET utf8 COLLATE utf8_general_ci;" -p$DBPASSWORD
+ fi
+ mysql $DBNAME -p$DBPASSWORD < mysql/mysql_schema_2.5.sql > log_schema.txt 2> err_schema.txt
+ mysql $DBNAME -p$DBPASSWORD < mysql/$DBENCODING/mysql_data_2.5.sql > log_data.txt 2> err_data.txt
+ mysql $DBNAME -p$DBPASSWORD < mysql/$DBENCODING/update/update_2.5_to_2.5.1rc1_mysql_$DBENCODING.sql > log_update.txt 2> err_update.txt
+ mysql $DBNAME -p$DBPASSWORD < mysql/$DBENCODING/update/update_2.5.1rc1_to_2.5.1_mysql_$DBENCODING.sql >> log_update.txt 2>> err_update.txt
+
+}
+
+#Datenbank erzeugen
+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 "Your password will be asked several times, this is normal (unless .pgpass is used)"
+ echo "creating database"
+ createdb -U $DBUSER -E $DBENCODING $DBNAME -T $DBTEMPLATE
+ echo "creating schema"
+ psql -U $DBUSER -f pgsql/pgsql_schema_2.5.sql $DBNAME > log_schema.txt 2> err_schema.txt
+ echo "loading data"
+ psql -U $DBUSER -f pgsql/$DBENCODING/pgsql_data_2.5.sql $DBNAME > log_data.txt 2> err_data.txt
+ echo "setting sequences"
+ psql -U $DBUSER -f pgsql/pgsql_serial_set_sequences_2.5.sql $DBNAME > log_sequences.txt 2> err_squences.txt
+ echo "update to 2.5.1rc1"
+ psql -U $DBUSER -f pgsql/$DBENCODING/update/update_2.5_to_2.5.1rc1_pgsql_$DBENCODING.sql $DBNAME > log_update.txt 2> err_update.txt
+ echo "update to 2.5.1"
+ psql -U $DBUSER -f pgsql/$DBENCODING/update/update_2.5.1rc1_to_2.5.1_pgsql_$DBENCODING.sql $DBNAME >> log_update.txt 2>> err_update.txt
+
+
+}
+
+function set_permissions(){
+ echo "The installer can set the permissions to the files"
+ echo "and directory for you. If you want the installer to"
+ echo "do this please enter (y)es else (n)o"
+ echo "Please note, to do this you have to be"
+ echo "read write access to the Mapbender directory"
+ echo "set permissions, (y)es or (n)?"
+ read automatic
+
+ if test $automatic != "n"
+ then
+ echo "Do you want that all files are owned by the apache webserver? (y)es or (n)o"
+ read setowner
+ if test $setowner != "n"
+ then
+ echo "Please specify the webserver user"
+ read webservuser
+ chown -R $webservuser:$webservuser ../../
+ fi
+ echo "setting permissions on /resources/locale/ and subdirectories"
+ chmod -R o+rw ../locale
+ echo "setting execute rights on mapbender/tools/i18n_update_mo.sh"
+ chmod -R o+rx ../../tools/i18n_update_mo.sh
+ # creating mapbender.conf
+ cp ../../conf/mapbender.conf-dist ../../conf/mapbender.conf
+
+ fi
+}
+
+function compile_po(){
+ echo ""
+ echo "Compiling .po files..."
+ cd ../../tools/
+ sh ./i18n_update_mo.sh
+ cd ../resources/db/
+ echo "removing permissions on /resources/locale/ and subdirectories"
+ chmod -R o-rw ../locale
+ echo "removing execute rights on mapbender/tools/i18n_update_mo.sh"
+ chmod -R o-rx ../../tools/i18n_update_mo.sh
+ echo ""
+}
+
+
+#magic starts here
+show_disclaimer;
+
+echo "Continue? (y)es or (n)o"
+read disclaimer
+if test $disclaimer != "y"
+then
+ exit 1
+fi
+get_db_config;
+show_db_config;
+echo "Look ok? Start Install? (y)es or (n)o"
+read ANSWER
+if [ $ANSWER != "y" ]
+then
+ 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
+
+set_permissions;
+compile_po;
+
+echo ""
+echo "Finished...check the log and error files to see if an error occured.";
+
+
Property changes on: branches/2.5/resources/db/install_2.5.2.sh
___________________________________________________________________
Added: svn:executable
+ *
More information about the Mapbender_commits
mailing list