* Fix import script for postgresql

- create user with the user enter password
This commit is contained in:
Heng Sin Low 2007-05-01 16:16:12 +00:00
parent efc23a1841
commit cc13fd2c5d
2 changed files with 21 additions and 14 deletions

View File

@ -15,15 +15,21 @@
@echo Re-Create user and database @echo Re-Create user and database
@echo ------------------------------------- @echo -------------------------------------
@dropdb -U postgres %ADEMPIERE_DB_NAME% @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 @set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3'
@createdb %ADEMPIERE_DB_NAME% -E UNICODE -O %ADEMPIERE_DB_USER% -U %ADEMPIERE_DB_USER% @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 -------------------------------------
@echo Import Adempiere_pg.dmp @echo Import Adempiere_pg.dmp
@echo ------------------------------------- @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 @goto end
:environment :environment
@ -33,6 +39,6 @@
:usage :usage
@echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd> @echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd>
@echo Example: %0 system/manager Adempiere Adempiere @echo Example: %0 postgres Adempiere Adempiere
:end :end

View File

@ -6,7 +6,7 @@ echo Importing Adempiere DB from $ADEMPIERE_HOME/data/Adempiere.dmp
if [ $# -le 2 ] if [ $# -le 2 ]
then then
echo "Usage: $0 <systemAccount> <AdempiereID> <AdempierePWD>" echo "Usage: $0 <systemAccount> <AdempiereID> <AdempierePWD>"
echo "Example: $0 system/manager adempiere adempiere" echo "Example: $0 postgres adempiere adempiere"
exit 1 exit 1
fi fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ] if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
@ -23,18 +23,19 @@ echo Recreate user and database
echo ------------------------------------- echo -------------------------------------
dropdb -U postgres $ADEMPIERE_DB_NAME 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 -------------------------------------
echo Import Adempiere_pg.dmp echo Import Adempiere_pg.dmp
echo ------------------------------------- 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 ------------------------------------- export PGPASSWORD=
echo Create SQLJ
echo -------------------------------------
# $ADEMPIERE_HOME/utils/$ADEMPIERE_DB_PATH/create.sh $ADEMPIERE_DB_USER/$ADEMPIERE_DB_PASSWORD