2008-11-05 20:09:05 +07:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-10-10 10:42:04 +07:00
|
|
|
# $Id: ImportAdempiere.sh,v 1.10 2005/12/20 07:12:17 jjanke Exp $
|
|
|
|
echo Adempiere Database Import $Revision: 1.10 $
|
|
|
|
|
|
|
|
echo Importing Adempiere DB from $ADEMPIERE_HOME/data/ExpDat.dmp
|
|
|
|
|
|
|
|
if [ $# -le 2 ]
|
|
|
|
then
|
|
|
|
echo "Usage: $0 <systemAccount> <AdempiereID> <AdempierePWD> <PostgresPWD>"
|
|
|
|
echo "Example: $0 postgres adempiere adempiere postgrespwd"
|
|
|
|
exit 1
|
|
|
|
fi
|
2008-08-23 02:57:53 +07:00
|
|
|
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" -o "$ADEMPIERE_DB_SERVER" = "" -o "$ADEMPIERE_DB_PORT" = "" ]
|
2007-10-10 10:42:04 +07:00
|
|
|
then
|
|
|
|
echo "Please make sure that the environment variables are set correctly:"
|
|
|
|
echo " ADEMPIERE_HOME e.g. /Adempiere"
|
2008-08-23 02:57:53 +07:00
|
|
|
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"
|
2007-10-10 10:42:04 +07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2008-08-23 02:57:53 +07:00
|
|
|
PGPASSWORD=$4
|
|
|
|
export PGPASSWORD
|
2007-10-10 10:42:04 +07:00
|
|
|
echo -------------------------------------
|
|
|
|
echo Recreate user and database
|
|
|
|
echo -------------------------------------
|
2008-08-23 02:57:53 +07:00
|
|
|
dropdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $ADEMPIERE_DB_NAME
|
2007-10-10 10:42:04 +07:00
|
|
|
|
2008-08-23 02:57:53 +07:00
|
|
|
dropuser -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres $2
|
2007-10-10 10:42:04 +07:00
|
|
|
|
|
|
|
ADEMPIERE_CREATE_ROLE_SQL="CREATE ROLE $2 SUPERUSER LOGIN PASSWORD '$3'"
|
2008-08-23 02:57:53 +07:00
|
|
|
psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
|
2007-10-10 10:42:04 +07:00
|
|
|
ADEMPIERE_CREATE_ROLE_SQL=
|
|
|
|
|
2008-08-23 02:57:53 +07:00
|
|
|
PGPASSWORD=$3
|
|
|
|
export PGPASSWORD
|
|
|
|
createdb -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
|
2007-10-10 10:42:04 +07:00
|
|
|
|
|
|
|
echo -------------------------------------
|
|
|
|
echo Import Adempiere_pg.dmp
|
|
|
|
echo -------------------------------------
|
2008-08-23 02:57:53 +07:00
|
|
|
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
|
2007-10-10 10:42:04 +07:00
|
|
|
|
2008-08-23 02:57:53 +07:00
|
|
|
PGPASSWORD=
|
|
|
|
export PGPASSWORD
|