From 5604c1277d9a750a3bfec064d43e191ec3a33e04 Mon Sep 17 00:00:00 2001 From: Pierre Ozoux <pierre@ozoux.net> Date: Thu, 24 Feb 2022 11:44:16 +0100 Subject: [PATCH] Adds migrations. --- ...-01-2022-migrate-nuage-liiibre-to-minio.sh | 0 migrations/12-06-2021-harmonize-nc.yml | 0 migrations/2022-02-03-update-nc-21.sh | 0 .../2022-02-07-sync-half-nc-1st-part.sh | 0 .../2022-02-08-sync-half-nc-2nd-part.sh | 0 migrations/2022-02-08-sync-hd-1st-part.sh | 0 migrations/2022-02-08-sync-hd-2nd-part.sh | 0 migrations/2022-02-14-check-pdf-status.sh | 14 ++++++++++++ ...-09-2021-investigation-harmonisation-Nc.sh | 0 migrations/30-09-2021-group-mapping-Nc.sh | 0 .../migrations/2022-02-16-sync-rc-1st-part.sh | 13 +++++++++++ .../migrations/2022-02-16-sync-rc-2nd-part.sh | 11 ++++++++++ scripts/change_stockage_rc_first_sync.sh | 22 +++++++++++++++++++ scripts/change_stockage_rc_second_sync.sh | 19 ++++++++++++++++ 14 files changed, 79 insertions(+) mode change 100644 => 100755 migrations/12-01-2022-migrate-nuage-liiibre-to-minio.sh mode change 100644 => 100755 migrations/12-06-2021-harmonize-nc.yml mode change 100644 => 100755 migrations/2022-02-03-update-nc-21.sh mode change 100644 => 100755 migrations/2022-02-07-sync-half-nc-1st-part.sh mode change 100644 => 100755 migrations/2022-02-08-sync-half-nc-2nd-part.sh mode change 100644 => 100755 migrations/2022-02-08-sync-hd-1st-part.sh mode change 100644 => 100755 migrations/2022-02-08-sync-hd-2nd-part.sh create mode 100755 migrations/2022-02-14-check-pdf-status.sh mode change 100644 => 100755 migrations/24-09-2021-investigation-harmonisation-Nc.sh mode change 100644 => 100755 migrations/30-09-2021-group-mapping-Nc.sh create mode 100644 migrations/migrations/2022-02-16-sync-rc-1st-part.sh create mode 100644 migrations/migrations/2022-02-16-sync-rc-2nd-part.sh create mode 100644 scripts/change_stockage_rc_first_sync.sh create mode 100644 scripts/change_stockage_rc_second_sync.sh diff --git a/migrations/12-01-2022-migrate-nuage-liiibre-to-minio.sh b/migrations/12-01-2022-migrate-nuage-liiibre-to-minio.sh old mode 100644 new mode 100755 diff --git a/migrations/12-06-2021-harmonize-nc.yml b/migrations/12-06-2021-harmonize-nc.yml old mode 100644 new mode 100755 diff --git a/migrations/2022-02-03-update-nc-21.sh b/migrations/2022-02-03-update-nc-21.sh old mode 100644 new mode 100755 diff --git a/migrations/2022-02-07-sync-half-nc-1st-part.sh b/migrations/2022-02-07-sync-half-nc-1st-part.sh old mode 100644 new mode 100755 diff --git a/migrations/2022-02-08-sync-half-nc-2nd-part.sh b/migrations/2022-02-08-sync-half-nc-2nd-part.sh old mode 100644 new mode 100755 diff --git a/migrations/2022-02-08-sync-hd-1st-part.sh b/migrations/2022-02-08-sync-hd-1st-part.sh old mode 100644 new mode 100755 diff --git a/migrations/2022-02-08-sync-hd-2nd-part.sh b/migrations/2022-02-08-sync-hd-2nd-part.sh old mode 100644 new mode 100755 diff --git a/migrations/2022-02-14-check-pdf-status.sh b/migrations/2022-02-14-check-pdf-status.sh new file mode 100755 index 0000000..f09c3d3 --- /dev/null +++ b/migrations/2022-02-14-check-pdf-status.sh @@ -0,0 +1,14 @@ +#!/bin/bash -eu + +for deploy in `kubectl get deploy -l app.kubernetes.io/component=app,app.kubernetes.io/name=nextcloud -A --no-headers -o custom-columns=":metadata.name"`; do + export NS=`echo $deploy | sed 's/-app//g' | cut -d'-' -f2-` + echo -n . + if ! kubectl -n ${NS} exec -it deploy/$deploy -- php occ app:list | grep -q files_pdfviewer:; then + echo app disabled $NS + fi + if kubectl -n ${NS} exec deploy/$deploy -- php occ config:app:get onlyoffice defFormats 2>&1 | grep -q pdf; then + if kubectl -n ${NS} exec deploy/$deploy -- php occ config:app:get onlyoffice defFormats 2>&1 | jq '.pdf' | grep -q true; then + echo oo $NS + fi + fi +done diff --git a/migrations/24-09-2021-investigation-harmonisation-Nc.sh b/migrations/24-09-2021-investigation-harmonisation-Nc.sh old mode 100644 new mode 100755 diff --git a/migrations/30-09-2021-group-mapping-Nc.sh b/migrations/30-09-2021-group-mapping-Nc.sh old mode 100644 new mode 100755 diff --git a/migrations/migrations/2022-02-16-sync-rc-1st-part.sh b/migrations/migrations/2022-02-16-sync-rc-1st-part.sh new file mode 100644 index 0000000..b55a7e4 --- /dev/null +++ b/migrations/migrations/2022-02-16-sync-rc-1st-part.sh @@ -0,0 +1,13 @@ +#!/bin/bash -eu + +for rc in `kubectl get ing -l app.kubernetes.io/name=Rocketchat -A --no-headers -o custom-columns=":metadata.name" | sed s/-app//g |grep -v "redirect\|beta\|test"`; do + export NS=`echo $rc | cut -d"-" -f2-` + export SUBDOMAIN=`echo $rc | cut -d"-" -f1` + export BucketURL=`kubectl -n ${NS} get cm ${rc}-config -o json | jq -r ".data.OVERWRITE_SETTING_FileUpload_S3_BucketURL"` + if [ "$BucketURL" = "https://s3.standard.indie.host" ]; then + if ! kubectl get secret -n ${NS} ${rc}-s3-new | grep -q new; then + echo Syncing $rc ... + /root/domains/common/scripts/change_stockage_rc_first_sync.sh + fi + fi +done diff --git a/migrations/migrations/2022-02-16-sync-rc-2nd-part.sh b/migrations/migrations/2022-02-16-sync-rc-2nd-part.sh new file mode 100644 index 0000000..1d76154 --- /dev/null +++ b/migrations/migrations/2022-02-16-sync-rc-2nd-part.sh @@ -0,0 +1,11 @@ +#!/bin/bash -eu + +for rc in `kubectl get ing -l app.kubernetes.io/name=Rocketchat -A --no-headers -o custom-columns=":metadata.name" | sed s/-app//g |grep -v "redirect\|beta\|test"`; do + export NS=`echo $rc | cut -d"-" -f2-` + export SUBDOMAIN=`echo $rc | cut -d"-" -f1` + export BucketURL=`kubectl -n ${NS} get cm ${SUBDOMAIN}-${NS}-config -o json | jq -r ".data.OVERWRITE_SETTING_FileUpload_S3_BucketURL"` + if [ "$BucketURL" = "https://s3.standard.indie.host" ]; then + echo Syncing $rc ... + /root/domains/common/scripts/change_stockage_rc_second_sync.sh + fi +done diff --git a/scripts/change_stockage_rc_first_sync.sh b/scripts/change_stockage_rc_first_sync.sh new file mode 100644 index 0000000..861f9ab --- /dev/null +++ b/scripts/change_stockage_rc_first_sync.sh @@ -0,0 +1,22 @@ +#!/bin/bash -eu + +#export NS=liiib-re +#export SUBDOMAIN=pad + +source /root/domains/common/scripts/functions.sh + +export APP=${SUBDOMAIN}-${NS} +export S3_ENDPOINT=https://hot-objects.liiib.re +export STORAGE_CLASS=hot + +# Create new hot bucket +export AWS_ACCESS_KEY_ID=${APP} +export SECRET_NAME=${APP}-s3-new +create_bucket + +kubectl -n liiib-re get secret s3-ro --export -o yaml 2> /dev/null | kubectl -n ${NS} apply -f - +kubectl -n ${NS} get secret ${APP}-s3 --export -o yaml 2> /dev/null | sed "s/${APP}-s3/${APP}-backup/g" | kubectl -n ${NS} apply -f - + +cd ~/domains/${NS}/${SUBDOMAIN} +libre apply ~/domains/common/nextcloud/other-manifests/sync-job.yml +kubectl -n ${NS} wait --for=condition=complete --timeout=-1s job/${APP}-sync-buckets diff --git a/scripts/change_stockage_rc_second_sync.sh b/scripts/change_stockage_rc_second_sync.sh new file mode 100644 index 0000000..1117370 --- /dev/null +++ b/scripts/change_stockage_rc_second_sync.sh @@ -0,0 +1,19 @@ +#!/bin/bash -eu + +#export NS=liiib-re +#export SUBDOMAIN=nuage + +export APP=${SUBDOMAIN}-${NS} + +kubectl -n ${NS} scale --replicas=0 deployment/${APP}-app +cd ~/domains/${NS}/${SUBDOMAIN} +kubectl -n ${NS} delete job/${SUBDOMAIN}-${NS}-sync-buckets +libre apply ~/domains/common/nextcloud/other-manifests/sync-job.yml +kubectl -n ${NS} wait --for=condition=complete --timeout=-1s job/${SUBDOMAIN}-${NS}-sync-buckets + +kubectl -n ${NS} get configmap ${APP}-config --export -o json 2> /dev/null | jq '.data["OVERWRITE_SETTING_FileUpload_S3_BucketURL"]="hot-objects.liiib.re"' | kubectl -n ${NS} apply -f - + +kubectl -n ${NS} delete secret ${APP}-s3 +kubectl -n ${NS} get secret ${APP}-s3-new --export -o yaml 2> /dev/null | sed "s/${APP}-s3-new/${APP}-s3/g" | kubectl -n ${NS} apply -f - + +kubectl -n ${NS} scale --replicas=2 deployment/${APP}-app -- GitLab