diff --git a/deploy/clone-pro-to-test.sh b/deploy/clone-pro-to-test.sh index 71059f2b..9e09c2a1 100644 --- a/deploy/clone-pro-to-test.sh +++ b/deploy/clone-pro-to-test.sh @@ -3,13 +3,13 @@ set -e -u -o pipefail # Actions: # -# - Clone instance in proj-dhis-prod to localhost. -# - Setup of the local docker +# - In PRO: Create docker image and push to Harbor. +# - In TEST: Pull docker from Harbor and start. -# Requirements: Open vendorlink (ip-pro + ip-tst) before running the script: +# Requirements: Open vendorlink (spintldhis01, stintldhis01) cd "$(dirname "$0")" source "./lib.sh" -#run boone-ip-pro bash push-pro-docker.sh -run boone-ip-test bash deploy-test-from-pro.sh +run spintldhis01 bash push-pro-docker.sh +run stintldhis01 bash deploy-test-from-pro.sh diff --git a/deploy/deploy-test-from-pro.sh b/deploy/deploy-test-from-pro.sh index ee59643a..1de1e26d 100755 --- a/deploy/deploy-test-from-pro.sh +++ b/deploy/deploy-test-from-pro.sh @@ -6,29 +6,39 @@ script_dir=$(pwd) source "./lib.sh" source "./tasks.sh" -post_clone() { - local url=$1 - set_email_password "$url" - change_server_name "$url" "SP Platform - Test" - set_logos "$url" "$script_dir/test-icons" -} +image_test="docker.eyeseetea.com/samaritans/dhis2-data:40.4.0-sp-ip-test" start_from_pro() { + local url=$1 + local image_test_running + + image_test_running=$(d2-docker list | grep RUN | awk '{print $1}' | grep -m1 ip-test) || true + if test "$image_test_running"; then + d2-docker commit "$image_test_running" + d2-docker copy "$image_test_running" "backup/sp-ip-test-$(timestamp)" + d2-docker stop "$image_test_running" + fi + d2-docker pull "$image_pro" - d2-docker commit "$image_test" - d2-docker copy "$image_test" "backup/sp-ip-test-$(timestamp)" - d2-docker stop "$image_test" d2-docker copy "$image_pro" "$image_test" - - sudo /usr/local/bin/start-dhis2-test + sudo image=$image_test /usr/local/bin/start-dhis2-test wait_for_dhis2_server "$url" } +post_clone() { + local url=$1 + + #set_email_password "$url" + change_server_name "$url" "SP Platform - Test" + set_logos "$url" "$script_dir/test-icons" +} + main() { local url url=$(get_url 80) - start_from_pro + + start_from_pro "$url" post_clone "$url" } diff --git a/deploy/lib.sh b/deploy/lib.sh index e92b3056..298e1adc 100755 --- a/deploy/lib.sh +++ b/deploy/lib.sh @@ -3,7 +3,6 @@ script_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]:-$0}")")" source "$script_dir/auth.sh" export image_pro="docker.eyeseetea.com/eyeseetea/dhis2-data:2.36.11.1-sp-ip-pro" -export image_test="docker.eyeseetea.com/samaritans/dhis2-data:2.36.11.1-sp-ip-test" export image_dev="docker.eyeseetea.com/samaritans/dhis2-data:2.36.11.1-sp-ip-dev" export image_training="docker.eyeseetea.com/samaritans/dhis2-data:2.36.11.1-sp-ip-training" @@ -59,6 +58,7 @@ get_user_role_ids() { change_server_name() { local url=$1 title=$2 + debug "Change server name: $title" curl -sS -X POST "$url/api/systemSettings/applicationTitle" \ -d "$title" -H "Content-Type: application/json" @@ -66,6 +66,7 @@ change_server_name() { join_by() { local IFS="$1" + shift echo "$*" }