From cd796ce26233440b52a7b7f0bf649bfa6588d2cd Mon Sep 17 00:00:00 2001 From: pedro Date: Tue, 6 Feb 2024 14:50:38 +0100 Subject: [PATCH] bugfix persistent idhubs were not updating code includes refactor of common functionality moved to build__common related, somehow, to #2 --- build__common.sh | 26 ++++++++++++++++++-------- build__instance-autotest.sh | 12 ++---------- build__pilot-lafede.sh | 9 ++------- build__pilot-pangea.sh | 11 ++--------- build__pilot-setem.sh | 11 ++--------- build__pilot-xo9b.sh | 11 ++--------- 6 files changed, 28 insertions(+), 52 deletions(-) diff --git a/build__common.sh b/build__common.sh index 5cd6ef8..6ea5b72 100644 --- a/build__common.sh +++ b/build__common.sh @@ -26,15 +26,25 @@ common_start() { fi ) - # some targets might use idhub1 and/or idhub2 - idhub="${idhub:-idhub__${target}}" - idhub1="${idhub1:-idhub1__${target}}" - idhub2="${idhub2:-idhub2__${target}}" + # process idhubs instances for the purpose + for idhub in ${idhubs}; do + if [ "${persistence}" = "n" ]; then + # no data persistence: cleanup previous possible data + rm -rf "./${idhub}" + fi + + # detect existing deployment + if [ -d "./${idhub}" ]; then + git -C "${idhub}" pull + # looks new + else + echo "Detected new deployment, recreating git repos ${idhub}" + cp -rp IdHub "${idhub}" + # ensure the copy does not contain a DB + rm -f "${idhub}/db.sqlite3" + fi + done - if [ "${persistence}" = "n" ]; then - # no data persistence: cleanup previous possible data - rm -rf "./${idhub}" - fi } common_end() { diff --git a/build__instance-autotest.sh b/build__instance-autotest.sh index f3d805c..283866a 100755 --- a/build__instance-autotest.sh +++ b/build__instance-autotest.sh @@ -13,21 +13,13 @@ main() { # common_end . ./build__common.sh + # vars used in common_start and end target='instance-autotest' - - idhub="idhub__${target}" - persistence='n' + idhubs='idhub' common_start - # detect if is new - if [ ! -f "./${idhub}" ]; then - echo 'Detected new deployment, recreating idhub git repo' - cp -rp IdHub "${idhub}" - rm -f "${idhub}/db.sqlite3" - fi - common_end } diff --git a/build__pilot-lafede.sh b/build__pilot-lafede.sh index ea561fc..3517c67 100755 --- a/build__pilot-lafede.sh +++ b/build__pilot-lafede.sh @@ -13,17 +13,12 @@ main() { # common_end . ./build__common.sh + # vars used in common_start and end target='pilot-lafede' + idhubs='idhub' common_start - # detect if is new - if [ ! -f "./${idhub1}" ]; then - echo 'Detected new deployment, recreating idhub git repo' - cp -rp IdHub "${idhub1}" - rm -f "${idhub1}/db.sqlite3" - fi - common_end } diff --git a/build__pilot-pangea.sh b/build__pilot-pangea.sh index f606eb0..40b70da 100755 --- a/build__pilot-pangea.sh +++ b/build__pilot-pangea.sh @@ -13,19 +13,12 @@ main() { # common_end . ./build__common.sh + # vars used in common_start and end target='pilot-pangea' + idhubs='idhub1 idhub2' common_start - # detect if is new - if [ ! -f "./${idhub1}" ] && [ ! -f "./${idhub2}" ]; then - echo 'Detected new deployment, recreating git repos idhub1 and idhub2' - cp -rp IdHub "${idhub1}" - rm -f "${idhub1}/db.sqlite3" - cp -rp IdHub "${idhub2}" - rm -f "${idhub2}/db.sqlite3" - fi - # common_end builds idhub # these are extra builds specific for this pilot make musician_build diff --git a/build__pilot-setem.sh b/build__pilot-setem.sh index ed38bb4..cb93576 100755 --- a/build__pilot-setem.sh +++ b/build__pilot-setem.sh @@ -13,19 +13,12 @@ main() { # common_end . ./build__common.sh + # vars used in common_start and end target='pilot-setem' + idhubs='idhub1 idhub2' common_start - # detect if is new - if [ ! -f "./${idhub1}" ] && [ ! -f "./${idhub2}" ]; then - echo 'Detected new deployment, recreating git repos idhub1 and idhub2' - cp -rp IdHub "${idhub1}" - rm -f "${idhub1}/db.sqlite3" - cp -rp IdHub "${idhub2}" - rm -f "${idhub2}/db.sqlite3" - fi - common_end } diff --git a/build__pilot-xo9b.sh b/build__pilot-xo9b.sh index 24ccf61..b4b8e08 100755 --- a/build__pilot-xo9b.sh +++ b/build__pilot-xo9b.sh @@ -13,19 +13,12 @@ main() { # common_end . ./build__common.sh + # vars used in common_start and end target='pilot-xo9b' + idhubs='idhub1 idhub2' common_start - # detect if is new - if [ ! -f "./${idhub1}" ] && [ ! -f "./${idhub2}" ]; then - echo 'Detected new deployment, recreating git repos idhub1 and idhub2' - cp -rp IdHub "${idhub1}" - rm -f "${idhub1}/db.sqlite3" - cp -rp IdHub "${idhub2}" - rm -f "${idhub2}/db.sqlite3" - fi - common_end }