This commit is contained in:
Yehonal
2016-08-30 15:28:01 +02:00
26 changed files with 140 additions and 248 deletions

View File

@@ -27,22 +27,25 @@ fi
function assemble() {
# to lowercase
database=$1
database=${1,,}
start_sql=$2
with_base=$3
with_updates=$4
with_custom=$5
var_base="DB_"$database"_PATHS"
base=${!var_base}
uc=${database^^}
var_updates="DB_"$database"_UPDATE_PATHS"
updates=${!var_updates}
name="DB_"$uc"_PATHS"
v="$name[@]"
base=("${!v}")
var_custom="DB_"$database"_CUSTOM_PATHS"
custom=${!var_custom}
name="DB_"$uc"_UPDATE_PATHS"
v="$name[@]"
updates=("${!v}")
echo $updates
name='DB_'$uc'_CUSTOM_PATHS'
v="$name[@]"
custom=("${!v}")
suffix_base="_base"
@@ -95,11 +98,12 @@ function assemble() {
n="registry__$hash"
if [[ -z ${!n} ]]; then
if [ ! -e $updFile ]; then
echo "" > $updFile
echo "-- assembled updates" > $updFile
fi
printf -v "registry__${hash}" %s "$file"
echo "-- New update sql: "$file
echo "-- $file"
cat "$entry" >> $updFile
fi
done
@@ -109,7 +113,7 @@ function assemble() {
fi
if [ $with_custom = true ]; then
custFile=$OUTPUT_FOLDER$database$suffix_custom"_"$curTime".sql"
custFile=$OUTPUT_FOLDER$database$suffix_custom".sql"
if [ ! ${#custom[@]} -eq 0 ]; then
echo "Generating $OUTPUT_FOLDER$database$suffix_custom ..."
@@ -124,19 +128,12 @@ function assemble() {
continue
fi
file=$(basename "$entry")
hash=$($MD5_CMD "$entry")
hash="${hash%% *}" #remove file path
n="registry__$hash"
if [[ -z ${!n} ]]; then
if [ ! -e $custFile ]; then
echo "" > $custFile
fi
printf -v "registry__${hash}" %s "$file"
echo "-- New custom sql: "$file
cat "$entry" >> $custFile
if [[ ! -e $custFile ]]; then
echo "-- assembled custom" > "$custFile"
fi
echo "-- $file" >> $custFile
cat "$entry" >> $custFile
done
fi
done
@@ -145,24 +142,24 @@ function assemble() {
}
function run() {
echo "===== STARTING PROCESS ====="
echo "===== STARTING PROCESS ====="
mkdir -p $OUTPUT_FOLDER
mkdir -p $OUTPUT_FOLDER
for db in ${DATABASES[@]}
do
assemble "$db" $version".sql" $1 $2 $3
done
for db in ${DATABASES[@]}
do
assemble "$db" $version".sql" $1 $2 $3
done
echo "" > $reg_file
echo "" > $reg_file
for k in ${!registry__*}
do
n=$k
echo "$k='${!n}';" >> "$reg_file"
done
for k in ${!registry__*}
do
n=$k
echo "$k='${!n}';" >> "$reg_file"
done
echo "===== DONE ====="
echo "===== DONE ====="
}
PS3='Please enter your choice: '
@@ -182,11 +179,11 @@ do
run false true false
break #avoid loop
;;
"Create only customs")
"Create only customs")
run false false true
break #avoid loop
;;
"Clean registry")
"Clean registry")
rm "$reg_file"
break #avoid loop
;;

View File

@@ -89,7 +89,7 @@ function import() {
echo "DROP PROCEDURE IF EXISTS \`updateDb\`;" >> "$newFile";
fi;
#rm $entry;
rm $entry;
oldDate=$dateToday
oldCnt=$cnt

0
bin/runners/run-engine Executable file → Normal file
View File