Browse Source

pg_isready can use SSL

Grant Limberg 3 years ago
parent
commit
f44b122262
1 changed files with 11 additions and 4 deletions
  1. 11 4
      ext/central-controller-docker/main.sh

+ 11 - 4
ext/central-controller-docker/main.sh

@@ -79,10 +79,17 @@ echo "{
 }    
 }    
 " > /var/lib/zerotier-one/local.conf
 " > /var/lib/zerotier-one/local.conf
 
 
-until /usr/pgsql-10/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do
-	echo "Waiting for PostgreSQL...";
-	sleep 2;
-done
+if [ -n "$DB_SERVER_CA" ]; then
+    until /usr/pgsql-10/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT} -d "sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}"; do
+	    echo "Waiting for PostgreSQL...";
+	    sleep 2;
+    done
+else
+    until /usr/pgsql-10/bin/pg_isready -h ${ZT_DB_HOST} -p ${ZT_DB_PORT}; do
+	    echo "Waiting for PostgreSQL...";
+	    sleep 2;
+    done
+fi
 
 
 export GLIBCXX_FORCE_NEW=1
 export GLIBCXX_FORCE_NEW=1
 export GLIBCPP_FORCE_NEW=1
 export GLIBCPP_FORCE_NEW=1