BT [ 2063691 ] Postgresql scripts should specify database host

https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2063691&group_id=176962
Added host and port to postgresql scripts
This commit is contained in:
Carlos Ruiz 2008-08-22 19:57:53 +00:00
parent becce9b627
commit cdb5a5f46f
10 changed files with 94 additions and 58 deletions

View File

@ -21,6 +21,7 @@
@SET ADEMPIERE_DB_USER=@ADEMPIERE_DB_USER@
@SET ADEMPIERE_DB_PASSWORD=@ADEMPIERE_DB_PASSWORD@
@SET ADEMPIERE_DB_URL=@ADEMPIERE_DB_URL@
@SET ADEMPIERE_DB_PORT=@ADEMPIERE_DB_PORT@
@Rem Oracle specifics
@SET ADEMPIERE_DB_PATH=@ADEMPIERE_DB_PATH@

View File

@ -31,6 +31,8 @@ ADEMPIERE_DB_PASSWORD=@ADEMPIERE_DB_PASSWORD@
export ADEMPIERE_DB_PASSWORD
ADEMPIERE_DB_URL=@ADEMPIERE_DB_URL@
export ADEMPIERE_DB_URL
ADEMPIERE_DB_PORT=@ADEMPIERE_DB_PORT@
export ADEMPIERE_DB_PORT
# Oracle Specifics ...
ADEMPIERE_DB_PATH=@ADEMPIERE_DB_PATH@

View File

@ -6,11 +6,13 @@
@if (%ADEMPIERE_HOME%) == () goto environment
@if (%ADEMPIERE_DB_NAME%) == () goto environment
@if (%ADEMPIERE_DB_SERVER%) == () goto environment
@if (%ADEMPIERE_DB_PORT%) == () goto environment
@Rem Must have parameter: userAccount
@if (%1) == () goto usage
@set PGPASSWORD=%2
pg_dump -U %1 %ADEMPIERE_DB_NAME% > %ADEMPIERE_HOME%\data\ExpDat.dmp
pg_dump -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U %1 %ADEMPIERE_DB_NAME% > %ADEMPIERE_HOME%\data\ExpDat.dmp
@set PGPASSWORD=
@cd %ADEMPIERE_HOME%\Data
@ -21,7 +23,9 @@ pg_dump -U %1 %ADEMPIERE_DB_NAME% > %ADEMPIERE_HOME%\data\ExpDat.dmp
:environment
@Echo Please make sure that the enviroment variables are set correctly:
@Echo ADEMPIERE_HOME e.g. D:\ADEMPIERE2
@Echo ADEMPIERE_DB_NAME e.g. ADEMPIERE.ADEMPIERE.org
@Echo ADEMPIERE_DB_NAME e.g. adempiere or xe
@Echo ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org
@Echo ADEMPIERE_DB_PORT e.g. 5432 or 1521
:usage
@echo Usage: %0 <userAccount>

View File

@ -10,17 +10,21 @@ if [ $# -eq 0 ]
echo "Example: $0 adempiere adempiere"
exit 1
fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
then
echo "Please make sure that the environment variables are set correctly:"
echo " ADEMPIERE_HOME e.g. /Adempiere"
echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org"
echo " ADEMPIERE_DB_NAME e.g. adempiere or xe"
echo " ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org"
echo " ADEMPIERE_DB_PORT e.g. 5432 or 1521"
exit 1
fi
export PGPASSWORD=$2
pg_dump --no-owner -U $1 $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/ExpDat.dmp
export PGPASSWORD=
PGPASSWORD=$2
export PGPASSWORD
pg_dump -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT --no-owner -U $1 $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/ExpDat.dmp
PGPASSWORD=
export PGPASSWORD
cd $ADEMPIERE_HOME/data
jar cvfM ExpDat.jar ExpDat.dmp

View File

@ -6,6 +6,8 @@
@if (%ADEMPIERE_HOME%) == () goto environment
@if (%ADEMPIERE_DB_NAME%) == () goto environment
@if (%ADEMPIERE_DB_SERVER%) == () goto environment
@if (%ADEMPIERE_DB_PORT%) == () goto environment
@Rem Must have parameters systemAccount AdempiereID AdempierePwd PostgresPwd
@if (%1) == () goto usage
@if (%2) == () goto usage
@ -16,28 +18,30 @@
@echo -------------------------------------
@echo Re-Create user and database
@echo -------------------------------------
@dropdb -U postgres %ADEMPIERE_DB_NAME%
@dropuser -U postgres %2
@dropdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %ADEMPIERE_DB_NAME%
@dropuser -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %2
@set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3'
@psql -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
@set ADEMPIERE_CREATE_ROLE_SQL=
@set PGPASSWORD=%3
@createdb -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
@createdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
@echo -------------------------------------
@echo Import Adempiere_pg.dmp
@echo -------------------------------------
@psql -d %ADEMPIERE_DB_NAME% -U %2 -c "drop schema sqlj cascade"
@psql -d %ADEMPIERE_DB_NAME% -U %2 -f %ADEMPIERE_HOME%/data/ExpDat.dmp
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -c "drop schema sqlj cascade"
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -f %ADEMPIERE_HOME%/data/ExpDat.dmp
@set PGPASSWORD=
@goto end
:environment
@Echo Please make sure that the enviroment variables are set correctly:
@Echo ADEMPIERE_HOME e.g. D:\Adempiere
@Echo ADEMPIERE_DB_NAME e.g. dev1.adempiere.org
@Echo ADEMPIERE_HOME e.g. D:\ADEMPIERE2
@Echo ADEMPIERE_DB_NAME e.g. adempiere or xe
@Echo ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org
@Echo ADEMPIERE_DB_PORT e.g. 5432 or 1521
:usage
@echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd> <postgresPwd>

View File

@ -9,34 +9,39 @@ if [ $# -le 2 ]
echo "Example: $0 postgres adempiere adempiere postgrespwd"
exit 1
fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
then
echo "Please make sure that the environment variables are set correctly:"
echo " ADEMPIERE_HOME e.g. /Adempiere"
echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org"
echo " ADEMPIERE_DB_NAME e.g. adempiere or xe"
echo " ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org"
echo " ADEMPIERE_DB_PORT e.g. 5432 or 1521"
exit 1
fi
export PGPASSWORD=$4
PGPASSWORD=$4
export PGPASSWORD
echo -------------------------------------
echo Recreate user and database
echo -------------------------------------
dropdb -U postgres $ADEMPIERE_DB_NAME
dropdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $ADEMPIERE_DB_NAME
dropuser -U postgres $2
dropuser -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $2
ADEMPIERE_CREATE_ROLE_SQL="CREATE ROLE $2 SUPERUSER LOGIN PASSWORD '$3'"
psql -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
ADEMPIERE_CREATE_ROLE_SQL=
export PGPASSWORD=$3
createdb -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
PGPASSWORD=$3
export PGPASSWORD
createdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
echo -------------------------------------
echo Import Adempiere_pg.dmp
echo -------------------------------------
psql -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade"
psql -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/ExpDat.dmp
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade"
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/ExpDat.dmp
export PGPASSWORD=
PGPASSWORD=
export PGPASSWORD

View File

@ -4,17 +4,21 @@ echo Adempiere PostgreSQL Database Export $Revision: 1.3 $
echo Saving database reference@$ADEMPIERE_DB_NAME to $ADEMPIERE_HOME/data/Adempiere_pg.dmp
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
then
echo "Please make sure that the environment variables are set correctly:"
echo " ADEMPIERE_HOME e.g. /Adempiere"
echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org"
echo " ADEMPIERE_DB_NAME e.g. adempiere or xe"
echo " ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org"
echo " ADEMPIERE_DB_PORT e.g. 5432 or 1521"
exit 1
fi
export PGPASSWORD=reference
pg_dump --no-owner -U reference $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/Adempiere_pg.dmp
export PGPASSWORD=
PGPASSWORD=reference
export PGPASSWORD
pg_dump -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT --no-owner -U reference $ADEMPIERE_DB_NAME > $ADEMPIERE_HOME/data/Adempiere_pg.dmp
PGPASSWORD=
export PGPASSWORD
cd $ADEMPIERE_HOME/data
jar cvfM Adempiere_pg.jar Adempiere_pg.dmp

View File

@ -6,6 +6,8 @@
@if (%ADEMPIERE_HOME%) == () goto environment
@if (%ADEMPIERE_DB_NAME%) == () goto environment
@if (%ADEMPIERE_DB_SERVER%) == () goto environment
@if (%ADEMPIERE_DB_PORT%) == () goto environment
@Rem Must have parameters systemAccount AdempiereID AdempierePwd
@if (%1) == () goto usage
@if (%2) == () goto usage
@ -15,22 +17,22 @@
@echo -------------------------------------
@echo Re-Create user and database
@echo -------------------------------------
@dropdb -U postgres %ADEMPIERE_DB_NAME%
@dropuser -U postgres %2
@dropdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %ADEMPIERE_DB_NAME%
@dropuser -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres %2
@set ADEMPIERE_CREATE_ROLE_SQL=CREATE ROLE %2 SUPERUSER LOGIN PASSWORD '%3'
@psql -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -U postgres -c "%ADEMPIERE_CREATE_ROLE_SQL%"
@set ADEMPIERE_CREATE_ROLE_SQL=
@set PGPASSWORD=%3
@createdb -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
@createdb -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -E UNICODE -O %2 -U %2 %ADEMPIERE_DB_NAME%
@echo -------------------------------------
@echo Import Adempiere_pg.dmp
@echo -------------------------------------
@set ADEMPIERE_ALTER_ROLE_SQL=ALTER ROLE %2 SET search_path TO adempiere, sqlj, pg_catalog
@psql -d %ADEMPIERE_DB_NAME% -U %2 -c "%ADEMPIERE_ALTER_ROLE_SQL%"
@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
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -c "%ADEMPIERE_ALTER_ROLE_SQL%"
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -c "drop schema sqlj cascade"
@psql -h %ADEMPIERE_DB_SERVER% -p %ADEMPIERE_DB_PORT% -d %ADEMPIERE_DB_NAME% -U %2 -f %ADEMPIERE_HOME%/data/Adempiere_pg.dmp
@set ADEMPIERE_ALTER_ROLE_SQL=
@ -39,8 +41,10 @@
:environment
@Echo Please make sure that the enviroment variables are set correctly:
@Echo ADEMPIERE_HOME e.g. D:\Adempiere
@Echo ADEMPIERE_DB_NAME e.g. dev1.adempiere.org
@Echo ADEMPIERE_HOME e.g. D:\ADEMPIERE2
@Echo ADEMPIERE_DB_NAME e.g. adempiere or xe
@Echo ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org
@Echo ADEMPIERE_DB_PORT e.g. 5432 or 1521
:usage
@echo Usage: %0 <systemAccount> <AdempiereID> <AdempierePwd> <PostgresPwd>

View File

@ -9,36 +9,40 @@ if [ $# -le 2 ]
echo "Example: $0 postgres adempiere adempiere postgresPwd"
exit 1
fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
then
echo "Please make sure that the environment variables are set correctly:"
echo " ADEMPIERE_HOME e.g. /Adempiere"
echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org"
echo " ADEMPIERE_DB_NAME e.g. adempiere or xe"
echo " ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org"
echo " ADEMPIERE_DB_PORT e.g. 5432 or 1521"
exit 1
fi
export PGPASSWORD=$4
PGPASSWORD=$4
export PGPASSWORD
echo -------------------------------------
echo Recreate user and database
echo -------------------------------------
dropdb -U postgres $ADEMPIERE_DB_NAME
dropdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $ADEMPIERE_DB_NAME
dropuser -U postgres $2
dropuser -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $2
ADEMPIERE_CREATE_ROLE_SQL="CREATE ROLE $2 SUPERUSER LOGIN PASSWORD '$3'"
psql -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
ADEMPIERE_CREATE_ROLE_SQL=
export PGPASSWORD=$3
createdb -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
PGPASSWORD=$3
export PGPASSWORD
createdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
echo -------------------------------------
echo Import Adempiere_pg.dmp
echo -------------------------------------
ADEMPIERE_ALTER_ROLE_SQL="ALTER ROLE $2 SET search_path TO adempiere, sqlj, pg_catalog"
psql -d $ADEMPIERE_DB_NAME -U $2 -c "$ADEMPIERE_ALTER_ROLE_SQL"
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
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -c "$ADEMPIERE_ALTER_ROLE_SQL"
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -c "drop schema sqlj cascade"
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -f $ADEMPIERE_HOME/data/Adempiere_pg.dmp
ADEMPIERE_ALTER_ROLE_SQL=
export PGPASSWORD=
PGPASSWORD=
export PGPASSWORD

View File

@ -7,17 +7,21 @@ if [ $# -le 2 ]
echo "Example: $0 postgres adempiere adempiere postgresPwd"
exit 1
fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
then
echo "Please make sure that the environment variables are set correctly:"
echo " ADEMPIERE_HOME e.g. /Adempiere"
echo " ADEMPIERE_DB_NAME e.g. adempiere.adempiere.org"
echo " ADEMPIERE_DB_NAME e.g. adempiere or xe"
echo " ADEMPIERE_DB_SERVER e.g. dbserver.adempiere.org"
echo " ADEMPIERE_DB_PORT e.g. 5432 or 1521"
exit 1
fi
export PGPASSWORD=$3
PGPASSWORD=$3
export PGPASSWORD
echo -------------------------------------
echo Add missing translations
echo -------------------------------------
psql -d $ADEMPIERE_DB_NAME -U $2 -f 01_add_missing_translations.sql
export PGPASSWORD=
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $2 -f 01_add_missing_translations.sql
PGPASSWORD=
export PGPASSWORD