#!/bin/bash # Check if the PostgreSQL data directory is empty if [ -z "$(ls -A /var/lib/postgresql/data)" ]; then echo "Initializing PostgreSQL database..." /usr/lib/postgresql/*/bin/initdb -D /var/lib/postgresql/data fi # Start the PostgreSQL server exec /usr/bin/postgres -D /var/lib/postgresql/data echo "server started successfully............."