From 20228e3d19c8cff8cbb9b5a178d03b2706fcbb1f Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Sun, 11 Sep 2022 20:23:18 +0000 Subject: [PATCH] add postgres ready check --- install.sh | 11 +++++++---- restore.sh | 10 +++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 75df6553..04b22329 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="67" +SCRIPT_VERSION="68" SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh' sudo apt install -y curl wget dirmngr gnupg lsb-release @@ -265,9 +265,12 @@ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt- sudo apt update sudo apt install -y postgresql-14 sleep 2 -sudo systemctl enable postgresql -sudo systemctl restart postgresql -sleep 5 +sudo systemctl enable --now postgresql + +until pg_isready > /dev/null; do + echo -ne "${GREEN}Waiting for PostgreSQL to be ready${NC}\n" + sleep 3 + done print_green 'Creating database for the rmm' diff --git a/restore.sh b/restore.sh index 7fca5286..0a6e990a 100755 --- a/restore.sh +++ b/restore.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="41" +SCRIPT_VERSION="42" SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh' sudo apt update @@ -200,8 +200,12 @@ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt- sudo apt update sudo apt install -y postgresql-14 sleep 2 -sudo systemctl enable postgresql -sudo systemctl restart postgresql +sudo systemctl enable --now postgresql + +until pg_isready > /dev/null; do + echo -ne "${GREEN}Waiting for PostgreSQL to be ready${NC}\n" + sleep 3 + done print_green 'Restoring MongoDB'