From 679cffb72dd87048bbebabe0892435984f872a9b Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 9 Nov 2018 21:33:47 -0200 Subject: [PATCH] IDEMPIERE-3655 Improve installer to include migration scripts and syncApplied / add optional folder parameter to process out of migration --- .../utils.unix/RUN_SyncDB.sh | 2 +- .../utils.unix/oracle/SyncDB.sh | 18 +++++++++++++++--- .../utils.unix/postgresql/SyncDB.sh | 18 +++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/org.adempiere.server-feature/utils.unix/RUN_SyncDB.sh b/org.adempiere.server-feature/utils.unix/RUN_SyncDB.sh index 3d8d4c67fc..e4756a1a40 100644 --- a/org.adempiere.server-feature/utils.unix/RUN_SyncDB.sh +++ b/org.adempiere.server-feature/utils.unix/RUN_SyncDB.sh @@ -7,4 +7,4 @@ fi . ./myEnvironment.sh Server echo Synchronize iDempiere Database - $IDEMPIERE_HOME \($ADEMPIERE_DB_NAME\) -sh $ADEMPIERE_DB_PATH/SyncDB.sh "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD" "$ADEMPIERE_DB_PATH" +sh $ADEMPIERE_DB_PATH/SyncDB.sh "$ADEMPIERE_DB_USER" "$ADEMPIERE_DB_PASSWORD" "$ADEMPIERE_DB_PATH" $* diff --git a/org.adempiere.server-feature/utils.unix/oracle/SyncDB.sh b/org.adempiere.server-feature/utils.unix/oracle/SyncDB.sh index ed6a40b4ac..66f9d8ca5f 100644 --- a/org.adempiere.server-feature/utils.unix/oracle/SyncDB.sh +++ b/org.adempiere.server-feature/utils.unix/oracle/SyncDB.sh @@ -30,8 +30,20 @@ ADEMPIERE_DB_PATH=$3 CMD="sqlplus $ADEMPIERE_DB_USER/$ADEMPIERE_DB_PASSWORD@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME" SILENTCMD="sqlplus -S $ADEMPIERE_DB_USER/$ADEMPIERE_DB_PASSWORD@$ADEMPIERE_DB_SERVER:$ADEMPIERE_DB_PORT/$ADEMPIERE_DB_NAME" ERROR_STRINGS="^(ORA-[0-9]+:|TNS-|PLS-)" +DIR_POST=$IDEMPIERE_HOME/migration +if [ "x$4" = "x" ] +then + DIR_SCRIPTS=$IDEMPIERE_HOME/migration +else + if [ `expr substr "$4" 1 1` = "/" ] + then + DIR_SCRIPTS="$4" + else + DIR_SCRIPTS="$IDEMPIERE_HOME/$4" + fi +fi -cd $IDEMPIERE_HOME/migration +cd "$DIR_SCRIPTS" # Create list of files already applied - registered in AD_MigrationScript table echo "set heading off @@ -47,7 +59,7 @@ find -type d -name $ADEMPIERE_DB_PATH | grep -v "./processes_post_migration/$ADE do cd "${FOLDER}" ls *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt - cd $IDEMPIERE_HOME/migration + cd "$DIR_SCRIPTS" done sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt @@ -82,7 +94,7 @@ else fi if [ x$APPLIED = xY ] then - cd $IDEMPIERE_HOME/migration + cd "$DIR_POST" for FILE in processes_post_migration/$ADEMPIERE_DB_PATH/*.sql do OUTFILE=$TMPFOLDER/SyncDB_out_$$/`basename "$FILE" .sql`.out diff --git a/org.adempiere.server-feature/utils.unix/postgresql/SyncDB.sh b/org.adempiere.server-feature/utils.unix/postgresql/SyncDB.sh index db1da0aa8b..a3f4767f6e 100644 --- a/org.adempiere.server-feature/utils.unix/postgresql/SyncDB.sh +++ b/org.adempiere.server-feature/utils.unix/postgresql/SyncDB.sh @@ -32,8 +32,20 @@ ADEMPIERE_DB_PATH=$3 CMD="psql -h $ADEMPIERE_DB_SERVER -p $ADEMPIERE_DB_PORT -d $ADEMPIERE_DB_NAME -U $ADEMPIERE_DB_USER" SILENTCMD="$CMD -q -t" ERROR_STRINGS="^(ERROR:|FEHLER:|FATAL:|ERRO:)" +DIR_POST=$IDEMPIERE_HOME/migration +if [ "x$4" = "x" ] +then + DIR_SCRIPTS=$IDEMPIERE_HOME/migration +else + if [ `expr substr "$4" 1 1` = "/" ] + then + DIR_SCRIPTS="$4" + else + DIR_SCRIPTS="$IDEMPIERE_HOME/$4" + fi +fi -cd $IDEMPIERE_HOME/migration +cd "$DIR_SCRIPTS" # Create list of files already applied - registered in AD_MigrationScript table echo "select name from ad_migrationscript" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt @@ -44,7 +56,7 @@ find -type d -name $ADEMPIERE_DB_PATH | grep -v "./processes_post_migration/$ADE do cd "${FOLDER}" ls *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt - cd $IDEMPIERE_HOME/migration + cd "$DIR_SCRIPTS" done sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt @@ -79,7 +91,7 @@ else fi if [ x$APPLIED = xY ] then - cd $IDEMPIERE_HOME/migration + cd "$DIR_POST" for FILE in processes_post_migration/$ADEMPIERE_DB_PATH/*.sql do OUTFILE=$TMPFOLDER/SyncDB_out_$$/`basename "$FILE" .sql`.out