From cc13fd2c5d5390d0ac9bcf3b26937e8d0032a046 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 1 May 2007 16:16:12 +0000 Subject: [PATCH] * Fix import script for postgresql - create user with the user enter password --- utils/postgresql/ImportAdempiere.bat | 16 +++++++++++----- utils/postgresql/ImportAdempiere.sh | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/utils/postgresql/ImportAdempiere.bat b/utils/postgresql/ImportAdempiere.bat index 6b4286e701..18523b9bd9 100644 --- a/utils/postgresql/ImportAdempiere.bat +++ b/utils/postgresql/ImportAdempiere.bat @@ -15,15 +15,21 @@ @echo Re-Create user and database @echo ------------------------------------- @dropdb -U postgres %ADEMPIERE_DB_NAME% -@dropuser -U postgres %ADEMPIERE_DB_USER% -@createuser -U postgres -a -d %ADEMPIERE_DB_USER% -P -@createdb %ADEMPIERE_DB_NAME% -E UNICODE -O %ADEMPIERE_DB_USER% -U %ADEMPIERE_DB_USER% +@dropuser -U postgres %2 +@set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3' +@psql -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%" +@set ADEMPIERE_CREATE_ROLE_SQL= + +PGPASSWORD=%3 +@createdb %ADEMPIERE_DB_NAME% -E UNICODE -O %2 -U %2 @echo ------------------------------------- @echo Import Adempiere_pg.dmp @echo ------------------------------------- -@psql -d %ADEMPIERE_DB_NAME% -U %ADEMPIERE_DB_USER% -f %ADEMPIERE_HOME%/data/Adempiere_pg.dmp +@psql -d %ADEMPIERE_DB_NAME% -U %2 -c "drop schema sqlj cascade" +@psql -d %ADEMPIERE_DB_NAME% -U %2 -f %ADEMPIERE_HOME%/data/Adempiere_pg.dmp +PGPASSWORD= @goto end :environment @@ -33,6 +39,6 @@ :usage @echo Usage: %0 -@echo Example: %0 system/manager Adempiere Adempiere +@echo Example: %0 postgres Adempiere Adempiere :end diff --git a/utils/postgresql/ImportAdempiere.sh b/utils/postgresql/ImportAdempiere.sh index ea2ceb66bf..b84cd786a8 100644 --- a/utils/postgresql/ImportAdempiere.sh +++ b/utils/postgresql/ImportAdempiere.sh @@ -6,7 +6,7 @@ echo Importing Adempiere DB from $ADEMPIERE_HOME/data/Adempiere.dmp if [ $# -le 2 ] then echo "Usage: $0 " - echo "Example: $0 system/manager adempiere adempiere" + echo "Example: $0 postgres adempiere adempiere" exit 1 fi if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] @@ -23,18 +23,19 @@ echo Recreate user and database echo ------------------------------------- dropdb -U postgres $ADEMPIERE_DB_NAME -dropuser -U postgres $ADEMPIERE_DB_USER +dropuser -U postgres $2 -createuser -U postgres -a -d $ADEMPIERE_DB_USER -P +ADEMPIERE_CREATE_ROLE_SQL="CREATE ROLE $2 SUPERUSER LOGIN PASSWORD '$3'" +psql -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL" +ADEMPIERE_CREATE_ROLE_SQL= -createdb $ADEMPIERE_DB_NAME -E UNICODE -O $ADEMPIERE_DB_USER -U $ADEMPIERE_DB_USER +export PGPASSWORD=$3 +createdb $ADEMPIERE_DB_NAME -E UNICODE -O $2 -U $2 echo ------------------------------------- echo Import Adempiere_pg.dmp echo ------------------------------------- -psql -d $ADEMPIERE_DB_NAME -U $ADEMPIERE_DB_USER -f $ADEMPIERE_HOME/data/Adempiere_pg.dmp +psql -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade" +psql -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/Adempiere_pg.dmp -echo ------------------------------------- -echo Create SQLJ -echo ------------------------------------- -# $ADEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/create.sh $ADEMPIERE_DB_USER/$ADEMPIERE_DB_PASSWORD +export PGPASSWORD= \ No newline at end of file