[Mapbender-commits] r4281 - branches/2.6/resources/db

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jul 1 12:20:20 EDT 2009


Author: tbaschetti
Date: 2009-07-01 12:20:20 -0400 (Wed, 01 Jul 2009)
New Revision: 4281

Added:
   branches/2.6/resources/db/install_2.6.bat
Log:
Database Install script for windows.


Added: branches/2.6/resources/db/install_2.6.bat
===================================================================
--- branches/2.6/resources/db/install_2.6.bat	                        (rev 0)
+++ branches/2.6/resources/db/install_2.6.bat	2009-07-01 16:20:20 UTC (rev 4281)
@@ -0,0 +1,157 @@
+ at echo off
+REM Script to install Mapbender 2.6
+REM
+setlocal
+REM Delete old Logfiles
+del log_*.txt
+del err_*.txt
+echo.
+echo ==============================================================================
+:PREP
+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
+echo psql found
+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.6"
+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
+echo to 2.6rc1
+psql -U %DBUSER% -f pgsql/%USEDBENC%/update/update_2.5.1_to_2.6rc1_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 echo update to 2.6
+rem mysql %DBNAME% -p -u %DBUSER% < mysql/%USEDBENC%/update/update_2.5.1_to_2.6rc1_mysql_%USEDBENC%.sql >> log_update.txt 2>> err_update.txt
+
+
+
+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 



More information about the Mapbender_commits mailing list