Skip to content

Commit

Permalink
Use bash arrays to keep args to update_database
Browse files Browse the repository at this point in the history
When OVERPASS_META was set to "no", then update_database was failing to parse
arguments. By using arrays it is no longer a problem.

Closes: #12
  • Loading branch information
wiktorn committed May 22, 2019
1 parent 89ada3f commit be98c86
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 150 deletions.
18 changes: 8 additions & 10 deletions 0.7.53/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.54.10/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.54.12/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.54.13/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.54.9/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.54/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.55.1/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
18 changes: 8 additions & 10 deletions 0.7.55.2/bin/update_overpass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@ DIFF_FILE=/db/diffs/changes.osm

(
set -e
UPDATE_ARGS=("--compression-method=${OVERPASS_COMPRESSION}" "--map-compression-method=${OVERPASS_COMPRESSION}" "--flush-size=${OVERPASS_FLUSH_SIZE}")
if [[ "${OVERPASS_META}" == "attic" ]] ; then
META="--keep-attic"
UPDATE_ARGS+=("--keep-attic")
elif [[ "${OVERPASS_META}" == "yes" ]] ; then
META="--meta"
else
META=""
UPDATE_ARGS+=("--meta")
fi

if [[ ! -d /db/diffs ]] ; then
mkdir /db/diffs
fi

if /app/bin/dispatcher --show-dir | grep -q File_Error ; then
DB_DIR="--db-dir=/db/db"
else
DB_DIR=""
UPDATE_ARGS+=("--db-dir=/db/db")
fi

while `true` ; do
Expand All @@ -42,8 +39,9 @@ DIFF_FILE=/db/diffs/changes.osm
else
echo "/db/diffs/changes.osm exists. Trying to apply again."
fi
echo /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}"
cat "${DIFF_FILE}" | /app/bin/update_database "${DB_DIR}" "${META}" --compression-method="${OVERPASS_COMPRESSION}" --map-compression-method="${OVERPASS_COMPRESSION}" --flush-size="${OVERPASS_FLUSH_SIZE}"

echo /app/bin/update_database "${UPDATE_ARGS[@]}"
cat "${DIFF_FILE}" | /app/bin/update_database "${UPDATE_ARGS[@]}"
rm "${DIFF_FILE}"

if [[ "${OSMIUM_STATUS}" -eq 3 ]]; then
Expand All @@ -56,4 +54,4 @@ DIFF_FILE=/db/diffs/changes.osm
# for now, until pyosmium-get-changes status code gets cleared
break
done
) 2>&1 | tee -a /db/changes.log
) 2>&1 | tee -a /db/changes.log
Loading

0 comments on commit be98c86

Please sign in to comment.