Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion charts/kasm/templates/db-init-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,18 @@ spec:
- "-c"
args:
- |
if [[ "$DB_AUTO_INITIALIZE" == "true" ]]; then /usr/bin/startup.sh; else echo "DB already initialized."; fi
if [[ "$DB_AUTO_INITIALIZE" == "true" ]]; then
# Check if database is already initialized
echo "Checking if database is already initialized..."
if PGPASSWORD="$POSTGRES_PASSWORD" psql -h "${POSTGRES_HOST}" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "SELECT COUNT(*) FROM settings;" 2>&1 > /dev/null; then
echo "Database already initialized. Nothing to do."
exit 0
fi

# Database needs initialization - startup.sh will initialize and exit due to POST_DB_INIT_EXIT
echo "Database not initialized. Starting initialization..."
/usr/bin/startup.sh
else
echo "DB auto-initialization disabled.";
fi
{{- end }}