From 3af59e942305bdb124f7da9f4b23e87b049c1a3a Mon Sep 17 00:00:00 2001 From: pedro Date: Fri, 19 Jan 2024 11:01:49 +0100 Subject: [PATCH] bugfix namespace, build__all script, simple pilots - build__all.sh - build__common.sh (includes common_start and common_end) which simplifies pilots --- build__all.sh | 17 +++++++++++++++++ build__common.sh | 43 ++++++++++++++++++++++++++++++++++++++++++ build__pilot-lafede.sh | 25 ++++++------------------ build__pilot-pangea.sh | 31 ++++++++++++++++++++++++++++++ build__pilot-setem.sh | 26 ++++++------------------- build__pilot-xo9b.sh | 26 ++++++------------------- 6 files changed, 109 insertions(+), 59 deletions(-) create mode 100755 build__all.sh create mode 100644 build__common.sh create mode 100755 build__pilot-pangea.sh diff --git a/build__all.sh b/build__all.sh new file mode 100755 index 0000000..7118f35 --- /dev/null +++ b/build__all.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e +set -u +# DEBUG +set -x + +main() { + action="${action:-deploy}" + export deployment='prod' + ./build__pilot-xo9b.sh + ./build__pilot-setem.sh + ./build__pilot-lafede.sh + ./build__pilot-pangea.sh +} + +main "${@}" diff --git a/build__common.sh b/build__common.sh new file mode 100644 index 0000000..f44905a --- /dev/null +++ b/build__common.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +set -e +set -u +# DEBUG +#set -x + +common_start() { + figlet "${pilot}" + + deployment="${1:-${deployment:-}}" + action="${action:-deploy}" + + # detach on production deployment + if [ "${deployment}" = 'prod' ]; then + detach='-d' + fi + + # ensure uses pilot-pangea branch + ( + cd ./IdHub + git checkout ${pilot} + ) + + # some pilots might use idhub1 and/or idhub2 + idhub1="idhub1__${pilot}" + idhub2="idhub2__${pilot}" + + # force recreate + rm -rf "./${idhub1}" "./${idhub2}" +} + +common_end() { + + idhub_dc_f="docker-compose__${pilot}.yml" + docker compose -p ${pilot} -f ${idhub_dc_f} down -v || true + make idhub_build + + if [ "${action:-}" = "deploy" ]; then + docker compose -p ${pilot} -f ${idhub_dc_f} up ${detach:-} + fi + +} diff --git a/build__pilot-lafede.sh b/build__pilot-lafede.sh index 097796a..d51aab2 100755 --- a/build__pilot-lafede.sh +++ b/build__pilot-lafede.sh @@ -7,24 +7,14 @@ set -x # a wallet and verifier idhub for pilot-lafede main() { - deployment="${1:-}" - - # detach on production deployment - if [ "${deployment}" = 'prod' ]; then - detach='-d' - fi - - # ensure uses pilot-lafede branch - ( - cd ./IdHub - git checkout pilot-lafede - ) + # includes functions: + # common_start + # common_end + . ./build__common.sh pilot='pilot-lafede' - local idhub1="idhub1__${pilot}" - # force recreate - rm -rf "./${idhub1}" + common_start # detect if is new if [ ! -f "./${idhub1}" ]; then @@ -33,10 +23,7 @@ main() { rm -f "${idhub1}/db.sqlite3" fi - idhub_dc_f="docker-compose__${pilot}.yml" - docker compose -p ${pilot} -f ${idhub_dc_f} down -v || true - make idhub_build \ - && docker compose -p ${pilot} -f ${idhub_dc_f} up ${detach:-} + common_end } main "${@}" diff --git a/build__pilot-pangea.sh b/build__pilot-pangea.sh new file mode 100755 index 0000000..dba6a33 --- /dev/null +++ b/build__pilot-pangea.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e +set -u +# DEBUG +set -x + +# a wallet and verifier idhub for pilot-pangea +main() { + # includes functions: + # common_start + # common_end + . ./build__common.sh + + pilot='pilot-pangea' + + 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 +} + +main "${@}" diff --git a/build__pilot-setem.sh b/build__pilot-setem.sh index 75f7345..3381c43 100755 --- a/build__pilot-setem.sh +++ b/build__pilot-setem.sh @@ -7,25 +7,14 @@ set -x # a wallet and verifier idhub for pilot-setem main() { - deployment="${1:-}" - - # detach on production deployment - if [ "${deployment}" = 'prod' ]; then - detach='-d' - fi - - # ensure uses pilot-setem branch - ( - cd ./IdHub - git checkout pilot-setem - ) + # includes functions: + # common_start + # common_end + . ./build__common.sh pilot='pilot-setem' - local idhub1="idhub1__${pilot}" - local idhub2="idhub2__${pilot}" - # force recreate - rm -rf "./${idhub1}" "./${idhub2}" + common_start # detect if is new if [ ! -f "./${idhub1}" ] && [ ! -f "./${idhub2}" ]; then @@ -36,10 +25,7 @@ main() { rm -f "${idhub2}/db.sqlite3" fi - idhub_dc_f="docker-compose__${pilot}.yml" - docker compose -p ${pilot} -f ${idhub_dc_f} down -v || true - make idhub_build \ - && docker compose -p ${pilot} -f ${idhub_dc_f} up ${detach:-} + common_end } main "${@}" diff --git a/build__pilot-xo9b.sh b/build__pilot-xo9b.sh index 9e5a31f..7de50bd 100755 --- a/build__pilot-xo9b.sh +++ b/build__pilot-xo9b.sh @@ -7,25 +7,14 @@ set -x # a wallet and verifier idhub for pilot-xo9b main() { - deployment="${1:-}" - - # detach on production deployment - if [ "${deployment}" = 'prod' ]; then - detach='-d' - fi - - # ensure uses pilot-xo9b branch - ( - cd ./IdHub - git checkout pilot-xo9b - ) + # includes functions: + # common_start + # common_end + . ./build__common.sh pilot='pilot-xo9b' - local idhub1="idhub1__${pilot}" - local idhub2="idhub2__${pilot}" - # force recreate - rm -rf "./${idhub1}" "./${idhub2}" + common_start # detect if is new if [ ! -f "./${idhub1}" ] && [ ! -f "./${idhub2}" ]; then @@ -36,10 +25,7 @@ main() { rm -f "${idhub2}/db.sqlite3" fi - idhub_dc_f="docker-compose__${pilot}.yml" - docker compose -p ${pilot} -f ${idhub_dc_f} down -v || true - make idhub_build \ - && docker compose -p ${pilot} -f ${idhub_dc_f} up ${detach:-} + common_end } main "${@}"