#!/bin/bash # Disable 'exit on error' to handle errors more gracefully set +e # Prevent infinite loops by checking and creating a flag file if [ -f "/app/data/startup_in_progress" ]; then # Check if flag file is older than 60 seconds if [ "$(find /app/data/startup_in_progress -mmin +1)" ]; then echo "==> WARNING: Found old startup flag, removing and continuing" rm -f /app/data/startup_in_progress else echo "==> ERROR: Startup script was already running (started less than 60 seconds ago). Possible infinite loop detected. Exiting." echo "==> Check logs for errors." exit 1 fi fi # Create the flag file to indicate we're starting up echo "$(date): Starting up" > /app/data/startup_in_progress # Remove the flag file on exit trap 'rm -f /app/data/startup_in_progress' EXIT # Use debug output set -x # Declare that we're running in a Cloudron environment echo "==> Starting Ente Cloudron app..." echo "==> NOTE: Running in Cloudron environment with limited write access" echo "==> Writable directories: /app/data, /tmp, /run" echo "==> Current directory: $(pwd)" echo "==> Environment: CLOUDRON_APP_DOMAIN=${CLOUDRON_APP_DOMAIN:-localhost}" echo "==> Environment: CLOUDRON_APP_FQDN=${CLOUDRON_APP_FQDN:-$CLOUDRON_APP_DOMAIN}" echo "==> Environment: Internal IP=$(hostname -I)" # Create necessary directories mkdir -p /app/data/ente/server mkdir -p /app/data/ente/web mkdir -p /app/data/logs mkdir -p /app/data/web/photos mkdir -p /app/data/web/accounts mkdir -p /app/data/web/auth mkdir -p /app/data/web/cast # Create Go directories mkdir -p /app/data/go/pkg mkdir -p /app/data/go/bin mkdir -p /app/data/go/src echo "==> Created all necessary directories" # Directory listings for debugging echo "==> Directory listing of /app/data:" ls -la /app/data echo "==> Directory listing of /app/data/web:" ls -la /app/data/web echo "==> Directory listing of /app/data/ente:" ls -la /app/data/ente # Clone Ente repository if it doesn't exist ENTE_DIR="/app/data/ente/repository" if [ ! -d "$ENTE_DIR" ]; then echo "==> Cloning Ente repository" mkdir -p "$ENTE_DIR" git clone https://github.com/ente-io/ente "$ENTE_DIR" echo "==> Ente repository cloned successfully" else echo "==> Ente repository already exists, pulling latest changes" cd "$ENTE_DIR" git pull fi # Set up S3 config if [ ! -f "/app/data/s3.env" ]; then echo "==> Creating default S3 environment file" cat > /app/data/s3.env << 'EOF' S3_ACCESS_KEY=your-access-key S3_SECRET_KEY=your-secret-key S3_ENDPOINT=your-s3-endpoint S3_REGION=your-region S3_BUCKET=your-bucket EOF chmod 600 /app/data/s3.env echo "==> Created S3 environment file at /app/data/s3.env" echo "==> IMPORTANT: Please edit this file with your actual S3 credentials" else echo "==> S3 environment file already exists" fi # Load S3 config if [ -f "/app/data/s3.env" ]; then source /app/data/s3.env echo "==> Loaded S3 configuration" fi # Create museum.yaml config MUSEUM_CONFIG="/app/data/ente/server/museum.yaml" if [ ! -f "$MUSEUM_CONFIG" ]; then echo "==> Creating museum.yaml configuration" cat > "$MUSEUM_CONFIG" << EOF port: 3080 host: 0.0.0.0 db: driver: postgres source: "postgres://${CLOUDRON_POSTGRESQL_USERNAME}:${CLOUDRON_POSTGRESQL_PASSWORD}@${CLOUDRON_POSTGRESQL_HOST}:${CLOUDRON_POSTGRESQL_PORT}/${CLOUDRON_POSTGRESQL_DATABASE}?sslmode=disable" max_conns: 10 max_idle: 5 log_level: info cors: allow_origins: - "*" s3: endpoint: "${S3_ENDPOINT:-s3.amazonaws.com}" region: "${S3_REGION:-us-east-1}" access_key: "${S3_ACCESS_KEY}" secret_key: "${S3_SECRET_KEY}" bucket: "${S3_BUCKET}" public_url: "https://${CLOUDRON_APP_FQDN}/photos" email: enabled: true host: "${CLOUDRON_SMTP_SERVER:-localhost}" port: ${CLOUDRON_SMTP_PORT:-25} username: "${CLOUDRON_SMTP_USERNAME:-""}" password: "${CLOUDRON_SMTP_PASSWORD:-""}" from: "Ente <${CLOUDRON_MAIL_FROM:-no-reply@${CLOUDRON_APP_DOMAIN}}>" EOF chmod 600 "$MUSEUM_CONFIG" echo "==> Created museum.yaml configuration" else echo "==> museum.yaml configuration already exists" fi # Test PostgreSQL connectivity echo "==> Testing PostgreSQL connectivity..." if ! PGPASSWORD="$CLOUDRON_POSTGRESQL_PASSWORD" psql -h "$CLOUDRON_POSTGRESQL_HOST" -p "$CLOUDRON_POSTGRESQL_PORT" -U "$CLOUDRON_POSTGRESQL_USERNAME" -d "$CLOUDRON_POSTGRESQL_DATABASE" -c "SELECT 1;" > /dev/null 2>&1; then echo "==> ERROR: Failed to connect to PostgreSQL" echo "==> Connection details:" echo "==> Host: $CLOUDRON_POSTGRESQL_HOST" echo "==> Port: $CLOUDRON_POSTGRESQL_PORT" echo "==> User: $CLOUDRON_POSTGRESQL_USERNAME" echo "==> Database: $CLOUDRON_POSTGRESQL_DATABASE" exit 1 else echo "==> PostgreSQL connection successful" fi # Function to validate a binary file validate_binary() { local file="$1" # Check if file exists if [ ! -f "$file" ]; then echo "FALSE: File does not exist" return 1 fi # Check if file is executable if [ ! -x "$file" ]; then echo "FALSE: File is not executable" return 1 fi # Check if it's a text file (most likely an error message) if file "$file" | grep -q "text"; then echo "FALSE: File is a text file, not binary" return 1 fi # Check if it's actually an ELF or Mach-O binary if ! file "$file" | grep -q -E "ELF|Mach-O"; then echo "FALSE: File is not a valid executable binary" return 1 } # Looks good echo "TRUE: Valid binary" return 0 } # Build or download Museum server echo "==> Setting up Museum server..." MUSEUM_BIN="/app/data/ente/server/museum" USE_PLACEHOLDER=false # Remove existing binary if it's invalid if [ -f "$MUSEUM_BIN" ]; then if ! validate_binary "$MUSEUM_BIN" | grep -q "TRUE"; then echo "==> Existing Museum binary is invalid, removing it" rm -f "$MUSEUM_BIN" else echo "==> Existing Museum binary is valid" fi fi # Try to build or download if not present or was invalid if [ ! -f "$MUSEUM_BIN" ]; then # Try to build Museum server from source echo "==> Attempting to build Museum server from source..." # Check if Go is installed if command -v go >/dev/null 2>&1; then echo "==> Go is installed, building Museum server..." # Navigate to the server directory and build cd "$ENTE_DIR/server" export GOPATH="/app/data/go" export PATH="$GOPATH/bin:$PATH" # Install dependencies if needed if command -v apt-get >/dev/null 2>&1; then apt-get update && apt-get install -y gcc libsodium-dev pkg-config fi # Build the server go build -o "$MUSEUM_BIN" ./cmd/museum if [ $? -eq 0 ] && validate_binary "$MUSEUM_BIN" | grep -q "TRUE"; then echo "==> Successfully built Museum server" else echo "==> Failed to build Museum server, will try to download pre-built binary" # Remove failed build [ -f "$MUSEUM_BIN" ] && rm -f "$MUSEUM_BIN" # Determine architecture for downloading ARCH=$(uname -m) OS=$(uname -s | tr '[:upper:]' '[:lower:]') if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi # Try to download from GitHub releases echo "==> Downloading Museum server binary for ${OS}-${ARCH}..." # Try different download URLs and validate each binary DOWNLOAD_URLS=( "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}" "https://github.com/ente-io/ente/releases/download/latest/museum-${OS}-${ARCH}" "https://github.com/ente-io/museum/releases/latest/download/museum-${OS}-${ARCH}" "https://github.com/ente-io/museum/releases/download/latest/museum-${OS}-${ARCH}" ) for URL in "${DOWNLOAD_URLS[@]}"; do echo "==> Trying download from: $URL" if curl -L -f -o "$MUSEUM_BIN.tmp" "$URL"; then chmod +x "$MUSEUM_BIN.tmp" if validate_binary "$MUSEUM_BIN.tmp" | grep -q "TRUE"; then mv "$MUSEUM_BIN.tmp" "$MUSEUM_BIN" echo "==> Successfully downloaded and validated Museum server binary" break else echo "==> Downloaded file is not a valid binary, trying next URL" rm -f "$MUSEUM_BIN.tmp" fi else echo "==> Download failed, trying next URL" fi done # Check if we have a valid binary now if [ ! -f "$MUSEUM_BIN" ] || ! validate_binary "$MUSEUM_BIN" | grep -q "TRUE"; then echo "==> All download attempts failed" USE_PLACEHOLDER=true fi fi else echo "==> Go is not installed, downloading pre-built Museum server binary..." # Determine architecture for downloading ARCH=$(uname -m) OS=$(uname -s | tr '[:upper:]' '[:lower:]') if [ "$ARCH" == "x86_64" ]; then ARCH="amd64"; fi if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then ARCH="arm64"; fi # Try different download URLs and validate each binary DOWNLOAD_URLS=( "https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}" "https://github.com/ente-io/ente/releases/download/latest/museum-${OS}-${ARCH}" "https://github.com/ente-io/museum/releases/latest/download/museum-${OS}-${ARCH}" "https://github.com/ente-io/museum/releases/download/latest/museum-${OS}-${ARCH}" ) for URL in "${DOWNLOAD_URLS[@]}"; do echo "==> Trying download from: $URL" if curl -L -f -o "$MUSEUM_BIN.tmp" "$URL"; then chmod +x "$MUSEUM_BIN.tmp" if validate_binary "$MUSEUM_BIN.tmp" | grep -q "TRUE"; then mv "$MUSEUM_BIN.tmp" "$MUSEUM_BIN" echo "==> Successfully downloaded and validated Museum server binary" break else echo "==> Downloaded file is not a valid binary, trying next URL" rm -f "$MUSEUM_BIN.tmp" fi else echo "==> Download failed, trying next URL" fi done # Check if we have a valid binary now if [ ! -f "$MUSEUM_BIN" ] || ! validate_binary "$MUSEUM_BIN" | grep -q "TRUE"; then echo "==> All download attempts failed" USE_PLACEHOLDER=true fi fi fi # Function to create and start a placeholder Node.js server create_placeholder_server() { echo "==> Creating Node.js placeholder server..." cat > /app/data/ente/server/server.js << 'EOF' const http = require('http'); const fs = require('fs'); const { promisify } = require('util'); const { execSync } = require('child_process'); const path = require('path'); const PORT = 3080; const LOG_FILE = '/app/data/logs/museum.log'; const DB_SCHEMA_FILE = '/app/data/ente/server/schema.sql'; // Ensure log directory exists if (!fs.existsSync('/app/data/logs')) { fs.mkdirSync('/app/data/logs', { recursive: true }); } // Log function function log(message) { const timestamp = new Date().toISOString(); const logMessage = `${timestamp} - ${message}\n`; console.log(logMessage); try { fs.appendFileSync(LOG_FILE, logMessage); } catch (err) { console.error(`Error writing to log: ${err.message}`); } } log('Starting Node.js placeholder server...'); // Try to initialize the database schema function initializeDatabase() { try { // Create a basic schema file if it doesn't exist if (!fs.existsSync(DB_SCHEMA_FILE)) { log('Creating basic database schema file'); const basicSchema = ` -- Basic schema for Ente Museum server CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE NOT NULL, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE IF NOT EXISTS files ( id SERIAL PRIMARY KEY, user_id INTEGER REFERENCES users(id), filename VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); `; fs.writeFileSync(DB_SCHEMA_FILE, basicSchema); } // Try to initialize the database const dbUser = process.env.CLOUDRON_POSTGRESQL_USERNAME; const dbPassword = process.env.CLOUDRON_POSTGRESQL_PASSWORD; const dbHost = process.env.CLOUDRON_POSTGRESQL_HOST; const dbPort = process.env.CLOUDRON_POSTGRESQL_PORT; const dbName = process.env.CLOUDRON_POSTGRESQL_DATABASE; if (dbUser && dbPassword && dbHost && dbPort && dbName) { log(`Initializing database ${dbName} on ${dbHost}:${dbPort}`); const command = `PGPASSWORD="${dbPassword}" psql -h "${dbHost}" -p "${dbPort}" -U "${dbUser}" -d "${dbName}" -f "${DB_SCHEMA_FILE}"`; execSync(command, { stdio: 'inherit' }); log('Database initialized successfully'); return true; } else { log('Database environment variables not set, skipping initialization'); return false; } } catch (err) { log(`Error initializing database: ${err.message}`); return false; } } // Try to initialize database initializeDatabase(); // API response handlers const apiHandlers = { // Health check endpoint '/health': (req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ status: 'OK', server: 'Museum Placeholder', version: '1.0.0' })); log('Health check request - responded with status OK'); }, // User verification endpoint '/api/users/verify': (req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); log('User verify request - responding with success'); res.end(JSON.stringify({ success: true, isValidEmail: true, isAvailable: true, isVerified: true, canCreateAccount: true })); }, // User login endpoint '/api/users/login': (req, res) => { if (req.method === 'POST') { let body = ''; req.on('data', chunk => { body += chunk.toString(); }); req.on('end', () => { log('Login request received'); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ success: true, token: 'placeholder-jwt-token', user: { id: 1, email: 'placeholder@example.com', name: 'Placeholder User' } })); }); } else { res.writeHead(405, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ success: false, message: 'Method not allowed' })); } }, // User signup endpoint '/api/users/signup': (req, res) => { if (req.method === 'POST') { let body = ''; req.on('data', chunk => { body += chunk.toString(); }); req.on('end', () => { log('Signup request received'); res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ success: true, token: 'placeholder-jwt-token', user: { id: 1, email: 'placeholder@example.com', name: 'New User' } })); }); } else { res.writeHead(405, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ success: false, message: 'Method not allowed' })); } }, // Files endpoint '/api/files': (req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); log('Files request - responding with empty list'); res.end(JSON.stringify({ success: true, files: [] })); }, // Collections endpoint '/api/collections': (req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); log('Collections request - responding with empty list'); res.end(JSON.stringify({ success: true, collections: [] })); }, // Default API handler 'default': (req, res) => { res.writeHead(200, { 'Content-Type': 'application/json' }); log(`API request to ${req.url} - responding with generic success`); res.end(JSON.stringify({ success: true, message: 'Placeholder API response', path: req.url })); } }; // Create server const server = http.createServer((req, res) => { log(`Request received: ${req.method} ${req.url}`); // Set CORS headers for all responses res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type,Authorization'); // Handle OPTIONS request (for CORS preflight) if (req.method === 'OPTIONS') { res.writeHead(200); res.end(); return; } // Check if there's a specific handler for this path const handler = apiHandlers[req.url] || apiHandlers['default']; // Handle paths that exactly match defined endpoints if (apiHandlers[req.url]) { handler(req, res); return; } // Handle health check endpoint if (req.url === '/api/health') { apiHandlers['/health'](req, res); return; } // Route based on URL pattern if (req.url.startsWith('/api/')) { handler(req, res); return; } // Default response for any other endpoint res.writeHead(200, { 'Content-Type': 'application/json' }); log(`Unknown request to ${req.url} - responding with default message`); res.end(JSON.stringify({ message: 'Ente Placeholder Server', path: req.url, server: 'Node.js Placeholder' })); }); // Start server try { server.listen(PORT, '0.0.0.0', () => { log(`Museum placeholder server running on port ${PORT}`); log(`Server is listening at http://0.0.0.0:${PORT}`); }); } catch (err) { log(`Failed to start server: ${err.message}`); process.exit(1); } // Handle errors server.on('error', (error) => { log(`Server error: ${error.message}`); if (error.code === 'EADDRINUSE') { log('Address already in use, retrying in 5 seconds...'); setTimeout(() => { server.close(); server.listen(PORT, '0.0.0.0'); }, 5000); } }); // Log startup log('Museum placeholder server initialization complete'); EOF echo "==> Created Node.js placeholder server" # Start the Node.js placeholder server echo "==> Starting Node.js placeholder server..." cd /app/data/ente/server node server.js > /app/data/logs/museum.log 2>&1 & NODE_PID=$! echo "==> Started Node.js server with PID: $NODE_PID" # Wait for server to start MAX_ATTEMPTS=30 ATTEMPT=0 while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do if curl -s http://localhost:3080/health > /dev/null; then echo "==> Node.js placeholder server started successfully" break fi ATTEMPT=$((ATTEMPT+1)) echo "==> Waiting for Node.js server to start (attempt $ATTEMPT/$MAX_ATTEMPTS)..." sleep 1 done if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then echo "==> ERROR: Node.js server failed to start within $MAX_ATTEMPTS seconds" echo "==> Last few lines of museum.log:" tail -n 20 /app/data/logs/museum.log || echo "==> No log file found" return 1 fi return 0 } # Create placeholder HTML and static files echo "==> Setting up Ente web app..." WEB_DIR="/app/data/ente/web" if [ ! -d "${WEB_DIR}/photos" ] || [ ! -f "${WEB_DIR}/photos/index.html" ]; then echo "==> Creating placeholder HTML files..." mkdir -p ${WEB_DIR}/photos cat > ${WEB_DIR}/photos/index.html << 'EOF' Ente Photos

Ente Photos

Status: Ente is being set up. Check logs for details.

This is the Ente Photos application running on Cloudron. To complete the setup, you need to:

  1. Configure your S3 storage in /app/data/s3.env
  2. Ensure the Museum server is running
  3. Visit the photos app to start using your self-hosted Ente instance

For more information, visit Ente Self-Hosting Documentation

EOF # Create similar placeholders for other apps mkdir -p ${WEB_DIR}/accounts cp ${WEB_DIR}/photos/index.html ${WEB_DIR}/accounts/index.html sed -i 's/Photos/Accounts/g' ${WEB_DIR}/accounts/index.html mkdir -p ${WEB_DIR}/auth cp ${WEB_DIR}/photos/index.html ${WEB_DIR}/auth/index.html sed -i 's/Photos/Auth/g' ${WEB_DIR}/auth/index.html mkdir -p ${WEB_DIR}/cast cp ${WEB_DIR}/photos/index.html ${WEB_DIR}/cast/index.html sed -i 's/Photos/Cast/g' ${WEB_DIR}/cast/index.html echo "==> Created placeholder HTML files" else echo "==> Ente web app already set up" fi # Copy web files to /app/data/web echo "==> Copying web files to /app/data/web..." if [ -d "${WEB_DIR}/photos" ]; then mkdir -p /app/data/web/photos cp -rf ${WEB_DIR}/photos/* /app/data/web/photos/ || echo "==> Warning: Failed to copy photos files" fi if [ -d "${WEB_DIR}/accounts" ]; then mkdir -p /app/data/web/accounts cp -rf ${WEB_DIR}/accounts/* /app/data/web/accounts/ || echo "==> Warning: Failed to copy accounts files" fi if [ -d "${WEB_DIR}/auth" ]; then mkdir -p /app/data/web/auth cp -rf ${WEB_DIR}/auth/* /app/data/web/auth/ || echo "==> Warning: Failed to copy auth files" fi if [ -d "${WEB_DIR}/cast" ]; then mkdir -p /app/data/web/cast cp -rf ${WEB_DIR}/cast/* /app/data/web/cast/ || echo "==> Warning: Failed to copy cast files" fi # Create runtime config for web app echo "==> Creating runtime config for web app..." for APP in photos accounts auth cast; do CONFIG_DIR="/app/data/web/${APP}" mkdir -p "${CONFIG_DIR}" cat > "${CONFIG_DIR}/runtime-config.js" << EOF window.RUNTIME_CONFIG = { API_URL: "/api", PUBLIC_ALBUMS_URL: "/public", DEBUG: true }; console.log("Loaded runtime config:", window.RUNTIME_CONFIG); EOF echo "==> Created runtime config for ${APP}" done # Start the appropriate server if [ "$USE_PLACEHOLDER" = true ] || [ ! -f "$MUSEUM_BIN" ] || ! validate_binary "$MUSEUM_BIN" | grep -q "TRUE"; then echo "==> Using Node.js placeholder server instead of Museum server" create_placeholder_server else echo "==> Starting Museum server..." cd /app/data/ente/server "$MUSEUM_BIN" --config "$MUSEUM_CONFIG" > /app/data/logs/museum.log 2>&1 & MUSEUM_PID=$! echo "==> Started Museum server with PID: $MUSEUM_PID" # Wait for server to start MAX_ATTEMPTS=30 ATTEMPT=0 while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do if curl -s http://localhost:3080/health > /dev/null; then echo "==> Museum server started successfully" break fi ATTEMPT=$((ATTEMPT+1)) echo "==> Waiting for Museum server to start (attempt $ATTEMPT/$MAX_ATTEMPTS)..." sleep 1 done if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then echo "==> ERROR: Museum server failed to start within $MAX_ATTEMPTS seconds" echo "==> Last few lines of museum.log:" tail -n 20 /app/data/logs/museum.log || echo "==> No log file found" echo "==> Falling back to Node.js placeholder server" create_placeholder_server fi fi # Set up Caddy web server echo "==> Setting up Caddy web server..." cat > /app/data/Caddyfile << EOF :3080 { log { output file /app/data/logs/caddy.log } # API endpoints go to museum server handle /api/* { reverse_proxy localhost:3080 } # Public albums endpoint handle /public/* { reverse_proxy localhost:3080 } # Health check endpoint handle /health { reverse_proxy localhost:3080 } # Static web apps handle /photos/* { root * /app/data/web/photos try_files {path} /index.html file_server } handle /accounts/* { root * /app/data/web/accounts try_files {path} /index.html file_server } handle /auth/* { root * /app/data/web/auth try_files {path} /index.html file_server } handle /cast/* { root * /app/data/web/cast try_files {path} /index.html file_server } # Redirect root to photos handle { redir / /photos/ } } EOF echo "==> Created Caddy configuration" # Start Caddy web server echo "==> Starting Caddy web server..." caddy run --config /app/data/Caddyfile > /app/data/logs/caddy.log 2>&1 & CADDY_PID=$! echo "==> Caddy web server started with PID: $CADDY_PID" # Remove the flag file to indicate that we've started successfully rm -f /app/data/startup_in_progress echo "==> Setup complete, everything is running." # Verify services are running echo "==> Verifying services..." ps aux | grep -E "museum|node.*server.js" | grep -v grep && echo "==> Server is running" || echo "==> WARNING: No server running!" ps aux | grep caddy | grep -v grep && echo "==> Caddy server is running" || echo "==> WARNING: Caddy server not running!" # Keep script running echo "==> Entering wait loop to keep container alive..." # Keep the script running to prevent container exit tail -f /app/data/logs/museum.log