forked from idempiere/idempiere
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RUN_SyncDBDev.sh
executable file
·69 lines (65 loc) · 2.47 KB
/
RUN_SyncDBDev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
IDEMPIERE_HOME=$( dirname "$( readlink -f "${BASH_SOURCE[0]}")" )
if [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
echo "
Usage: ${BASH_SOURCE[0]} [property_file] [migration_folder]
Called without parameters it tries to get the database connection information from the file $IDEMPIERE_HOME/idempiere.properties
This requires that install.app or install.console.app has been previously executed in eclipse.
If the first parameter is a file, then the script tries to obtain the connection information from such properties file.
Optionally you can pass one or more migration folders at the end in order to process them.
If no migration folder is passed then it processes the folder $IDEMPIERE_HOME/migration
When called with parameter -h or --help prints this help message"
exit 0
fi
if [ "$#" -gt 0 ]
then
if [ -s "$1" ]
then
PROPFILE="$(dirname "$1")/$(basename "$1")"
shift
fi
fi
if [ -z "$PROPFILE" ]
then
if [ -s "$IDEMPIERE_HOME/idempiere.properties" ]
then
PROPFILE="$IDEMPIERE_HOME/idempiere.properties"
fi
fi
if [ -z "$PROPFILE" ]
then
echo "There is no idempiere.properties in folder $IDEMPIERE_HOME.
Please run first install.app or install.console.app within eclipse"
exit 1
fi
cd "$IDEMPIERE_HOME" || (echo "Cannot cd to $IDEMPIERE_HOME"; exit 1)
CONN=$(grep "^Connection=.*type" "$PROPFILE")
if [ -z "$CONN" ]
then
echo "There is no Connection definition in the properties file $PROPFILE, or Connection is encrypted"
exit 1
fi
ADEMPIERE_DB_NAME="$(expr "$CONN" : ".*DBname.=\(.*\),BQ.=")"
ADEMPIERE_DB_SERVER="$(expr "$CONN" : ".*DBhost.=\(.*\),DBport.=")"
ADEMPIERE_DB_PORT="$(expr "$CONN" : ".*DBport.=\(.*\),DBname.=")"
ADEMPIERE_DB_USER="$(expr "$CONN" : ".*UID.=\(.*\),PWD.=")"
if [ "x$ADEMPIERE_DB_USER" = "x" ]
then
ADEMPIERE_DB_USER="$(expr "$CONN" : ".*UID.=\(.*\)\]")"
fi
ADEMPIERE_DB_PASSWORD="$(expr "$CONN" : ".*PWD.=\(.*\)]")"
if [ "x$ADEMPIERE_DB_PASSWORD" = "x" ]
then
ADEMPIERE_DB_PASSWORD="$( $IDEMPIERE_HOME/org.adempiere.server-feature/utils.unix/getVar.sh ADEMPIERE_DB_PASSWORD )"
fi
ADEMPIERE_DB_PATH="$(expr "$CONN" : ".*type.=\(.*\),DBhost.=")"
ADEMPIERE_DB_PATH="${ADEMPIERE_DB_PATH,,}"
export IDEMPIERE_HOME
export ADEMPIERE_DB_NAME
export ADEMPIERE_DB_SERVER
export ADEMPIERE_DB_PORT
export ADEMPIERE_DB_USER
export ADEMPIERE_DB_PASSWORD
export ADEMPIERE_DB_PATH
bash "org.adempiere.server-feature/utils.unix/$ADEMPIERE_DB_PATH/SyncDB.sh" "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD" "$ADEMPIERE_DB_PATH" "$@"