From a98fc02ef70cb80f2132760d556b977e3669f3a0 Mon Sep 17 00:00:00 2001 From: havelight-ee Date: Thu, 16 Feb 2023 16:21:38 +0900 Subject: [PATCH] =?UTF-8?q?script=20=EB=82=B4=EC=9A=A9=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/03-ddl-dml/postgres/pg.sh | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 roles/cmoa_install/files/03-ddl-dml/postgres/pg.sh diff --git a/roles/cmoa_install/files/03-ddl-dml/postgres/pg.sh b/roles/cmoa_install/files/03-ddl-dml/postgres/pg.sh new file mode 100644 index 0000000..e78730d --- /dev/null +++ b/roles/cmoa_install/files/03-ddl-dml/postgres/pg.sh @@ -0,0 +1,33 @@ +#!/bin/bash +if [ -z "$BASH_VERSION" ]; then exec bash "$0" "$@"; exit; fi + +namespace=$1 + +if [[ ${namespace} == "" ]]; then + echo "[Usage] $0 " + exit +fi + +kubectl -n ${namespace} wait --for=condition=ready pod/${postgres} --timeout=1200s + +pg_check=`sh postgres_check_data imxc` + +if [[ ${pg_check} == 1 ]]; then + echo "pg data already!" + exit +fi + +echo "pg data insert start" + +postgres=`kubectl get pods -n ${namespace} | grep postgres | awk '{print $1}'` + + +kubectl cp postgres_insert_ddl.psql ${postgres}:/postgres_insert_ddl.psql -n ${namespace} +kubectl cp postgres_insert_dml.psql ${postgres}:/postgres_insert_dml.psql -n ${namespace} + +sleep 10 + +kubectl exec -it ${postgres} -n ${namespace} -- bash -c "PGPASSWORD='eorbahrhkswp' && /usr/bin/psql -h 'localhost' -U 'admin' -d 'postgresdb' -f /postgres_insert_ddl.psql" +kubectl exec -it ${postgres} -n ${namespace} -- bash -c "PGPASSWORD='eorbahrhkswp' && /usr/bin/psql -h 'localhost' -U 'admin' -d 'postgresdb' -f /postgres_insert_dml.psql" + +