IDEMPIERE-4441 More shellcheck (#254)

Fix issue caused by previous commit - RUN_SyncDB broken
This commit is contained in:
Carlos Ruiz 2020-09-14 21:03:55 +02:00 committed by GitHub
parent 7c096a4901
commit 51844316df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 49 deletions

View File

@ -79,7 +79,7 @@ apply_script()
OUTFILE="$2"
FILE="$3"
echo "Applying $SCRIPT"
$CMD > "$OUTFILE" 2>&1 < "$SCRIPT"
$CMD < "$SCRIPT" > "$OUTFILE" 2>&1
APPLIED=Y
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
then
@ -158,7 +158,7 @@ select count(*) from ad_migrationscript where name='$BASEFIX';" | $SILENTCMD | s
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"
SUPPORTEMAIL=$(echo "set heading 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-Transfer-Encoding: 7bit"
echo "Content-Disposition: inline"
echo -e "$MSGERROR"
printf '%s' "$MSGERROR"
echo "================================="
cat "$ATTACH"
echo
@ -222,15 +222,8 @@ set echo off
select name from ad_migrationscript;" | $SILENTCMD | sed -e 's:^ ::' | grep -v '^$' | sort > $TMPFOLDER/lisDB_$$.txt
# Create list of files in the migration folder
: > $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
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
MSGERROR=""
# extract and process the list of pending files
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt
@ -288,7 +281,7 @@ then
do
OUTFILE=$TMPFOLDER/SyncDB_out_$$/$(basename "$FILE" .sql).out
echo "Applying $FILE"
$CMD > "$OUTFILE" 2>&1 < "$FILE"
$CMD < "$FILE" > "$OUTFILE" 2>&1
if grep -E "$ERROR_STRINGS" "$OUTFILE" > /dev/null 2>&1
then
echo "Found error in $SCRIPT"

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Author: Carlos Ruiz - globalqss
# 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
# Create list of files in the migration folder
: > $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
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
MSGERROR=""
APPLIED=N
# 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 ]
then
mkdir $TMPFOLDER/SyncDB_out_$$
cat $TMPFOLDER/lisPENDING_$$.txt | while read -r FILE
while read -r FILE
do
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
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
break
fi
done
done < $TMPFOLDER/lisPENDING_$$.txt
else
if [ -s $TMPFOLDER/lisFS_$$.txt ]
then

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Author: Carlos Ruiz - globalqss
# Script to synchronize the database with latest migration scripts allowing a remote monitored way
@ -173,7 +173,7 @@ process_fix()
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"
SUPPORTEMAIL=$($SILENTCMD -c "select supportemail from ad_system" | sed -e 's/ //g')
SENDMAIL=$(command -v sendmail)
@ -191,7 +191,7 @@ notify_error()
echo "Content-Type: text/plain; charset=\"UTF-8\""
echo "Content-Transfer-Encoding: 7bit"
echo "Content-Disposition: inline"
echo -e "$MSGERROR"
printf '%s' "$MSGERROR"
echo "================================="
cat "$ATTACH"
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
# Create list of files in the migration folder
: > $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
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
MSGERROR=""
# extract and process the list of pending files
comm -13 $TMPFOLDER/lisDB_$$.txt $TMPFOLDER/lisFS_$$.txt > $TMPFOLDER/lisPENDING_$$.txt

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Author: Carlos Ruiz - globalqss
# 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
# Create list of files in the migration folder
: > $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
find . -type f -wholename "*/${ADEMPIERE_DB_PATH}/*.sql" ! -wholename "./processes_post_migration/${ADEMPIERE_DB_PATH}/*" | sed -e 's:.*/::' | sort > $TMPFOLDER/lisFS_$$.txt
MSGERROR=""
APPLIED=N
# 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 ]
then
mkdir $TMPFOLDER/SyncDB_out_$$
cat $TMPFOLDER/lisPENDING_$$.txt | while read -r FILE
while read -r FILE
do
SCRIPT=$(find . -name "$FILE" | grep "/$ADEMPIERE_DB_PATH/")
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
break
fi
done
done < $TMPFOLDER/lisPENDING_$$.txt
else
if [ -s $TMPFOLDER/lisFS_$$.txt ]
then