2025-02-25 06:52:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
2025-07-02 07:05:22 +00:00
|
|
|
echo "🚀 Starting Try ToolJet container initialization..."
|
2025-02-25 06:52:50 +00:00
|
|
|
|
2025-11-05 12:24:38 +00:00
|
|
|
# Step 1: Configure and Start PostgreSQL
|
2025-07-02 07:05:22 +00:00
|
|
|
echo "🔧 Configuring PostgreSQL authentication..."
|
2025-08-11 11:55:15 +00:00
|
|
|
sed -i 's/^local\s\+all\s\+postgres\s\+\(peer\|md5\)/local all postgres trust/' /etc/postgresql/16/main/pg_hba.conf >/dev/null 2>&1
|
|
|
|
|
sed -i 's/^local\s\+all\s\+all\s\+\(peer\|md5\)/local all all trust/' /etc/postgresql/16/main/pg_hba.conf >/dev/null 2>&1
|
2025-02-25 06:52:50 +00:00
|
|
|
|
2025-07-02 07:05:22 +00:00
|
|
|
echo "📈 Starting PostgreSQL..."
|
2025-02-25 06:52:50 +00:00
|
|
|
service postgresql start
|
|
|
|
|
|
2025-07-02 07:05:22 +00:00
|
|
|
echo "⏳ Waiting for PostgreSQL..."
|
|
|
|
|
until pg_isready -h localhost -p 5432; do
|
|
|
|
|
echo "PostgreSQL not ready yet, retrying..."
|
|
|
|
|
sleep 2
|
|
|
|
|
done
|
2025-08-11 11:55:15 +00:00
|
|
|
echo "✅ PostgreSQL is ready!"
|
2025-07-02 07:05:22 +00:00
|
|
|
|
2025-11-05 12:24:38 +00:00
|
|
|
# Create ToolJet user
|
2025-07-02 07:05:22 +00:00
|
|
|
psql -U postgres -tc "SELECT 1 FROM pg_roles WHERE rolname='tooljet'" | grep -q 1 || \
|
|
|
|
|
psql -U postgres -c "CREATE USER tooljet WITH PASSWORD 'postgres' SUPERUSER;" >/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Export default port if not set
|
2025-02-25 06:52:50 +00:00
|
|
|
export PORT=${PORT:-80}
|
|
|
|
|
|
2025-08-11 11:55:15 +00:00
|
|
|
supervisord -c /etc/supervisor/conf.d/supervisord.conf &
|
|
|
|
|
SUPERVISOR_PID=$!
|
|
|
|
|
|
|
|
|
|
echo "🎉 All services started successfully!"
|
|
|
|
|
echo "📍 ToolJet should be accessible at http://localhost"
|
|
|
|
|
|
|
|
|
|
# Wait on background processes
|
2025-11-05 12:24:38 +00:00
|
|
|
wait $SUPERVISOR_PID
|