Files
blinko-cloudron/start.sh
Andreas Düren 996aaaddfa v1.0.1: Fix seed sample images not being copied
- Add step in start.sh to copy seed files to data directory
- Ensures sample images display correctly on fresh install
2025-12-29 19:48:00 -06:00

72 lines
2.2 KiB
Bash

#!/bin/bash
set -eu
echo "=> Starting Blinko for Cloudron"
# Initialize data directory on first run
if [[ ! -f /app/data/.initialized ]]; then
echo "=> First run: initializing data directory..."
mkdir -p /app/data/.blinko
touch /app/data/.initialized
fi
# Generate NEXTAUTH_SECRET if not present
if [[ ! -f /app/data/.nextauth_secret ]]; then
echo "=> Generating NEXTAUTH_SECRET..."
openssl rand -base64 32 > /app/data/.nextauth_secret
fi
NEXTAUTH_SECRET=$(cat /app/data/.nextauth_secret)
# Set ownership
chown -R cloudron:cloudron /app/data
# Configure environment from Cloudron
export NODE_ENV=production
export DATABASE_URL="${CLOUDRON_POSTGRESQL_URL}"
export NEXTAUTH_URL="${CLOUDRON_APP_ORIGIN}"
export NEXT_PUBLIC_BASE_URL="${CLOUDRON_APP_ORIGIN}"
export NEXTAUTH_SECRET="${NEXTAUTH_SECRET}"
export TRUST_PROXY=1
export DISABLE_SECURE_COOKIE=false
# Configure mail settings if available
if [[ -n "${CLOUDRON_MAIL_SMTP_SERVER:-}" ]]; then
export SMTP_HOST="${CLOUDRON_MAIL_SMTP_SERVER}"
export SMTP_PORT="${CLOUDRON_MAIL_SMTP_PORT}"
export SMTP_USER="${CLOUDRON_MAIL_SMTP_USERNAME}"
export SMTP_PASS="${CLOUDRON_MAIL_SMTP_PASSWORD}"
export SMTP_FROM="${CLOUDRON_MAIL_FROM}"
fi
# Set timezone if configured
export TZ="${TZ:-UTC}"
# Set HOME to /app/data so Blinko stores data there
export HOME=/app/data
# Create .blinko in the data directory (writable location)
mkdir -p /app/data/.blinko
# Run database migrations
echo "=> Running database migrations..."
cd /app/code
/app/code/node_modules/.bin/prisma migrate deploy --schema=/app/code/prisma/schema.prisma
# Seed database if needed
echo "=> Checking database seed..."
node /app/code/dist/seed.js 2>/dev/null || true
# Copy seed files (sample images) if not already present
if [[ -d /app/code/prisma/seedfiles ]] && [[ ! -f /app/data/.blinko/files/pic01.png ]]; then
echo "=> Copying sample files..."
cp /app/code/prisma/seedfiles/* /app/data/.blinko/files/ 2>/dev/null || true
chown -R cloudron:cloudron /app/data/.blinko/files/
fi
# Configure NGINX
cp /app/code/nginx.conf /run/nginx.conf
echo "=> Starting supervisor..."
exec /usr/bin/supervisord --configuration /app/code/supervisor/supervisord.conf --nodaemon