IDEMPIERE-4441 More shellcheck (#254)
Fix issue caused by previous commit - RUN_SyncDB broken
This commit is contained in:
parent
7c096a4901
commit
51844316df
|
@ -79,7 +79,7 @@ apply_script()
|
||||||
OUTFILE="$2"
|
OUTFILE="$2"
|
||||||
FILE="$3"
|
FILE="$3"
|
||||||
echo "Applying $SCRIPT"
|
echo "Applying $SCRIPT"
|
||||||
$CMD > "$OUTFILE" 2>&1 < "$SCRIPT"
|
$CMD < "$SCRIPT" > "$OUTFILE" 2>&1
|
||||||
APPLIED=Y
|
APPLIED=Y
|
||||||
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
|
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
|
@ -158,7 +158,7 @@ select count(*) from ad_migrationscript where name='$BASEFIX';" | $SILENTCMD | s
|
||||||
|
|
||||||
notify_error()
|
notify_error()
|
||||||
{
|
{
|
||||||
echo -e "$MSGERROR"
|
printf '%s' "$MSGERROR"
|
||||||
printf '\n%s\n%s\n' "Error=true" "Errors were found during the process (see message above) - please inform and integrate a fix to restart this process again"
|
printf '\n%s\n%s\n' "Error=true" "Errors were found during the process (see message above) - please inform and integrate a fix to restart this process again"
|
||||||
SUPPORTEMAIL=$(echo "set heading off
|
SUPPORTEMAIL=$(echo "set heading off
|
||||||
set feedback off
|
set feedback off
|
||||||
|
@ -181,7 +181,7 @@ select supportemail from ad_system;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^
|
||||||
echo "Content-Type: text/plain; charset=\"UTF-8\""
|
echo "Content-Type: text/plain; charset=\"UTF-8\""
|
||||||
echo "Content-Transfer-Encoding: 7bit"
|
echo "Content-Transfer-Encoding: 7bit"
|
||||||
echo "Content-Disposition: inline"
|
echo "Content-Disposition: inline"
|
||||||
echo -e "$MSGERROR"
|
printf '%s' "$MSGERROR"
|
||||||
echo "================================="
|
echo "================================="
|
||||||
cat "$ATTACH"
|
cat "$ATTACH"
|
||||||
echo
|
echo
|
||||||
|
@ -222,15 +222,8 @@ set echo off
|
||||||
select name from ad_migrationscript;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
select name from ad_migrationscript;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
||||||
|
|
||||||
# Create list of files in the migration folder
|
# Create list of files in the migration folder
|
||||||
: > $TMPFOLDER/lisFS_$$.txt
|
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
|
||||||
find . -type d -name "$ADEMPIERE_DB_PATH" | grep -v "./processes_post_migration/$ADEMPIERE_DB_PATH" | while read -r FOLDER
|
|
||||||
do
|
|
||||||
cd "${FOLDER}" || exit 1
|
|
||||||
ls -- *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt
|
|
||||||
cd "$DIR_SCRIPTS" || exit 1
|
|
||||||
done
|
|
||||||
sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt
|
|
||||||
sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt
|
|
||||||
MSGERROR=""
|
MSGERROR=""
|
||||||
# extract and process the list of pending files
|
# extract and process the list of pending files
|
||||||
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt
|
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt
|
||||||
|
@ -288,7 +281,7 @@ then
|
||||||
do
|
do
|
||||||
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
||||||
echo "Applying $FILE"
|
echo "Applying $FILE"
|
||||||
$CMD > "$OUTFILE" 2>&1 < "$FILE"
|
$CMD < "$FILE" > "$OUTFILE" 2>&1
|
||||||
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
|
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
echo "Found error in $SCRIPT"
|
echo "Found error in $SCRIPT"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Author: Carlos Ruiz - globalqss
|
# Author: Carlos Ruiz - globalqss
|
||||||
# Script to synchronize the database for with latest migration scripts
|
# Script to synchronize the database for with latest migration scripts
|
||||||
|
@ -54,15 +54,8 @@ set echo off
|
||||||
select name from ad_migrationscript;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
select name from ad_migrationscript;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
||||||
|
|
||||||
# Create list of files in the migration folder
|
# Create list of files in the migration folder
|
||||||
: > $TMPFOLDER/lisFS_$$.txt
|
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
|
||||||
find . -type d -name "$ADEMPIERE_DB_PATH" | grep -v "./processes_post_migration/$ADEMPIERE_DB_PATH" | while read -r FOLDER
|
|
||||||
do
|
|
||||||
cd "${FOLDER}" || (echo "ERROR: Cannot change to folder $FOLDER"; exit 1)
|
|
||||||
ls -- *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt
|
|
||||||
cd "$DIR_SCRIPTS" || (echo "ERROR: Cannot change to folder $DIR_SCRIPTS"; exit 1)
|
|
||||||
done
|
|
||||||
sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt
|
|
||||||
sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt
|
|
||||||
MSGERROR=""
|
MSGERROR=""
|
||||||
APPLIED=N
|
APPLIED=N
|
||||||
# extract and process the list of pending files
|
# extract and process the list of pending files
|
||||||
|
@ -70,7 +63,7 @@ comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING
|
||||||
if [ -s $TMPFOLDER/lisPENDING_$$.txt ]
|
if [ -s $TMPFOLDER/lisPENDING_$$.txt ]
|
||||||
then
|
then
|
||||||
mkdir $TMPFOLDER/SyncDB_out_$$
|
mkdir $TMPFOLDER/SyncDB_out_$$
|
||||||
cat $TMPFOLDER/lisPENDING_$$.txt | while read -r FILE
|
while read -r FILE
|
||||||
do
|
do
|
||||||
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
|
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
|
||||||
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
||||||
|
@ -83,7 +76,7 @@ then
|
||||||
# Stop processing to allow user to fix the problem before processing additional files
|
# Stop processing to allow user to fix the problem before processing additional files
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done < $TMPFOLDER/lisPENDING_$$.txt
|
||||||
else
|
else
|
||||||
if [ -s $TMPFOLDER/lisFS_$$.txt ]
|
if [ -s $TMPFOLDER/lisFS_$$.txt ]
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Author: Carlos Ruiz - globalqss
|
# Author: Carlos Ruiz - globalqss
|
||||||
# Script to synchronize the database with latest migration scripts allowing a remote monitored way
|
# Script to synchronize the database with latest migration scripts allowing a remote monitored way
|
||||||
|
@ -173,7 +173,7 @@ process_fix()
|
||||||
|
|
||||||
notify_error()
|
notify_error()
|
||||||
{
|
{
|
||||||
echo -e "$MSGERROR"
|
printf '%s' "$MSGERROR"
|
||||||
printf '\n%s\n%s\n' "Error=true" "Errors were found during the process (see message above) - please inform and integrate a fix to restart this process again"
|
printf '\n%s\n%s\n' "Error=true" "Errors were found during the process (see message above) - please inform and integrate a fix to restart this process again"
|
||||||
SUPPORTEMAIL=$($SILENTCMD -c "select supportemail from ad_system" | sed -e 's/ //g')
|
SUPPORTEMAIL=$($SILENTCMD -c "select supportemail from ad_system" | sed -e 's/ //g')
|
||||||
SENDMAIL=$(command -v sendmail)
|
SENDMAIL=$(command -v sendmail)
|
||||||
|
@ -191,7 +191,7 @@ notify_error()
|
||||||
echo "Content-Type: text/plain; charset=\"UTF-8\""
|
echo "Content-Type: text/plain; charset=\"UTF-8\""
|
||||||
echo "Content-Transfer-Encoding: 7bit"
|
echo "Content-Transfer-Encoding: 7bit"
|
||||||
echo "Content-Disposition: inline"
|
echo "Content-Disposition: inline"
|
||||||
echo -e "$MSGERROR"
|
printf '%s' "$MSGERROR"
|
||||||
echo "================================="
|
echo "================================="
|
||||||
cat "$ATTACH"
|
cat "$ATTACH"
|
||||||
echo
|
echo
|
||||||
|
@ -222,15 +222,8 @@ done < $TMPFOLDER/lisERR_$$.txt
|
||||||
echo "select name from ad_migrationscript" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
echo "select name from ad_migrationscript" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
||||||
|
|
||||||
# Create list of files in the migration folder
|
# Create list of files in the migration folder
|
||||||
: > $TMPFOLDER/lisFS_$$.txt
|
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
|
||||||
find . -type d -name "$ADEMPIERE_DB_PATH" | grep -v "./processes_post_migration/$ADEMPIERE_DB_PATH" | while read -r FOLDER
|
|
||||||
do
|
|
||||||
cd "${FOLDER}" || exit 1
|
|
||||||
ls -- *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt
|
|
||||||
cd "$DIR_SCRIPTS" || exit 1
|
|
||||||
done
|
|
||||||
sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt
|
|
||||||
sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt
|
|
||||||
MSGERROR=""
|
MSGERROR=""
|
||||||
# extract and process the list of pending files
|
# extract and process the list of pending files
|
||||||
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt
|
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Author: Carlos Ruiz - globalqss
|
# Author: Carlos Ruiz - globalqss
|
||||||
# Script to synchronize the database for with latest migration scripts
|
# Script to synchronize the database for with latest migration scripts
|
||||||
|
@ -51,15 +51,8 @@ cd "$DIR_SCRIPTS" || (echo "ERROR: Cannot change to folder $DIR_SCRIPTS"; exit 1
|
||||||
echo "select name from ad_migrationscript" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
echo "select name from ad_migrationscript" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
|
||||||
|
|
||||||
# Create list of files in the migration folder
|
# Create list of files in the migration folder
|
||||||
: > $TMPFOLDER/lisFS_$$.txt
|
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
|
||||||
find . -type d -name "$ADEMPIERE_DB_PATH" | grep -v "./processes_post_migration/$ADEMPIERE_DB_PATH" | while read -r FOLDER
|
|
||||||
do
|
|
||||||
cd "${FOLDER}" || (echo "ERROR: Cannot change to folder $FOLDER"; exit 1)
|
|
||||||
ls -- *.sql 2>/dev/null >> $TMPFOLDER/lisFS_$$.txt
|
|
||||||
cd "$DIR_SCRIPTS" || (echo "ERROR: Cannot change to folder $DIR_SCRIPTS"; exit 1)
|
|
||||||
done
|
|
||||||
sort -o $TMPFOLDER/lisFS_$$.txt $TMPFOLDER/lisFS_$$.txt
|
|
||||||
sort -o $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisDB_$$.txt
|
|
||||||
MSGERROR=""
|
MSGERROR=""
|
||||||
APPLIED=N
|
APPLIED=N
|
||||||
# extract and process the list of pending files
|
# extract and process the list of pending files
|
||||||
|
@ -67,7 +60,7 @@ comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING
|
||||||
if [ -s $TMPFOLDER/lisPENDING_$$.txt ]
|
if [ -s $TMPFOLDER/lisPENDING_$$.txt ]
|
||||||
then
|
then
|
||||||
mkdir $TMPFOLDER/SyncDB_out_$$
|
mkdir $TMPFOLDER/SyncDB_out_$$
|
||||||
cat $TMPFOLDER/lisPENDING_$$.txt | while read -r FILE
|
while read -r FILE
|
||||||
do
|
do
|
||||||
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
|
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
|
||||||
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
|
||||||
|
@ -80,7 +73,7 @@ then
|
||||||
# Stop processing to allow user to fix the problem before processing additional files
|
# Stop processing to allow user to fix the problem before processing additional files
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done < $TMPFOLDER/lisPENDING_$$.txt
|
||||||
else
|
else
|
||||||
if [ -s $TMPFOLDER/lisFS_$$.txt ]
|
if [ -s $TMPFOLDER/lisFS_$$.txt ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue