core-jgi/utils/postgresql/ImportAdempiere.sh

45 lines
1.5 KiB
Bash
Raw Normal View History

# $Id: ImportAdempiere.sh,v 1.10 2005/12/20 07:12:17 jjanke Exp $
echo Adempiere Database Import $Revision: 1.10 $
2006-11-17 10:14:43 +07:00
echo Importing Adempiere DB from $ADEMPIERE_HOME/data/Adempiere_pg.dmp
2006-11-17 10:14:43 +07:00
if [ $# -le 2 ]
then
echo "Usage: $0 <systemAccount> <AdempiereID> <AdempierePWD> <PostgresPwd>"
echo "Example: $0 postgres adempiere adempiere postgresPwd"
2006-11-17 10:14:43 +07:00
exit 1
fi
if [ "$ADEMPIERE_HOME" = "" -o "$ADEMPIERE_DB_NAME" = "" ]
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"
exit 1
fi
export PGPASSWORD=$4
2006-11-17 10:14:43 +07:00
echo -------------------------------------
echo Recreate user and database
2006-11-17 10:14:43 +07:00
echo -------------------------------------
dropdb -U postgres $ADEMPIERE_DB_NAME
dropuser -U postgres $2
ADEMPIERE_CREATE_ROLE_SQL="CREATE ROLE $2 SUPERUSER LOGIN PASSWORD '$3'"
psql -U postgres -c "$ADEMPIERE_CREATE_ROLE_SQL"
ADEMPIERE_CREATE_ROLE_SQL=
export PGPASSWORD=$3
2008-08-02 00:02:05 +07:00
createdb -E UNICODE -O $2 -U $2 $ADEMPIERE_DB_NAME
2006-11-17 10:14:43 +07:00
echo -------------------------------------
echo Import Adempiere_pg.dmp
2006-11-17 10:14:43 +07:00
echo -------------------------------------
2007-12-02 23:17:12 +07:00
ADEMPIERE_ALTER_ROLE_SQL="ALTER ROLE $2 SET search_path TO adempiere, sqlj, pg_catalog"
2007-11-02 16:51:12 +07:00
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
2007-11-02 16:51:12 +07:00
ADEMPIERE_ALTER_ROLE_SQL=
export PGPASSWORD=