diff --git a/start.sh b/start.sh index ec0b397..7cb4c04 100644 --- a/start.sh +++ b/start.sh @@ -70,68 +70,101 @@ if [[ ! -f /app/data/.initialized ]]; then # Create an S3 configuration file template cat > /app/data/config/s3.env.template < IMPORTANT: S3 storage configuration required" - echo " 1. Edit the file at /app/data/config/s3.env.template" - echo " 2. Fill in your S3 credentials" - echo " 3. Rename the file to s3.env" - echo " 4. Restart the app" - - # Create test S3 configuration for Wasabi - echo "==> Creating S3 configuration for testing with Wasabi" - cat > /app/data/config/s3.env < Test S3 configuration created for Wasabi" + echo "==> Please configure your S3 storage as follows:" + echo "1. Log into your Cloudron dashboard" + echo "2. Go to the app's configuration page" + echo "3. Edit the file /app/data/config/s3.env" + echo "4. Restart the app" # Mark initialization as complete touch /app/data/.initialized echo "==> Initialization complete" fi -# Check if s3.env exists -if [[ ! -f /app/data/config/s3.env ]]; then - echo "==> ERROR: S3 configuration not found" - echo " Please configure S3 storage by editing /app/data/config/s3.env.template" - echo " and renaming it to s3.env, then restart the app." - exit 1 +# Check if configuration exists +if [ ! -f "/app/data/config/s3.env" ]; then + echo "==> First run - creating configuration template" + mkdir -p /app/data/config + + # Create a template S3 configuration file + echo "==> Creating S3 configuration template" + cat > /app/data/config/s3.env.template < IMPORTANT: S3 storage configuration required" + echo "==> Please configure your S3 storage as follows:" + echo "1. Log into your Cloudron dashboard" + echo "2. Go to the app's configuration page" + echo "3. Edit the file /app/data/config/s3.env" + echo "4. Restart the app" +else + echo "==> Using existing S3 configuration" fi -# Load S3 environment variables -source /app/data/config/s3.env +# Check if s3.env is empty +if [ ! -s "/app/data/config/s3.env" ]; then + echo "==> WARNING: S3 configuration file is empty. The app will not function correctly until configured." + echo "==> Please refer to the template at /app/data/config/s3.env.template for instructions." +fi -# Print S3 configuration (without sensitive values) +# Source S3 configuration +if [ -f /app/data/config/s3.env ]; then + echo "==> Sourcing S3 configuration from /app/data/config/s3.env" + source /app/data/config/s3.env +fi + +# Display S3 configuration (masking sensitive values) echo "==> S3 Configuration:" echo "Endpoint: ${S3_ENDPOINT}" echo "Region: ${S3_REGION}" echo "Bucket: ${S3_BUCKET}" -echo "Prefix: ${S3_PREFIX:-ente/}" +echo "Prefix: ${S3_PREFIX:-}" # Create museum.yaml for proper S3 configuration echo "==> Creating museum.yaml configuration" @@ -139,7 +172,7 @@ cat > /app/data/config/museum.yaml < Found Museum source in cmd/museum, running with go run" cd "$SERVER_DIR" - # Instead of modifying go.mod, set environment variables for compatibility + # Set environment variables for compatibility echo "==> Setting Go environment variables for compatibility" export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod -modcacherw" # Use local toolchain to avoid downloading required version export GOTOOLCHAIN=local - # For Wasabi specific settings - if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then - echo "==> Detected Wasabi S3 endpoint, adjusting settings" - echo "==> Adding -mod=mod to go run to ignore version mismatch" - cd "$SERVER_DIR" && \ - /usr/local/bin/gosu cloudron:cloudron env GOCACHE=/app/data/go/cache GOMODCACHE=/app/data/go/pkg/mod PORT=8080 GIN_MODE=release go run -modfile=/app/data/go/go.mod -mod=mod cmd/museum/main.go --port 8080 \ - --storage.s3.endpoint="${S3_ENDPOINT}" \ - --storage.s3.region="${S3_REGION}" \ - --storage.s3.bucket="${S3_BUCKET}" \ - --storage.s3.accessKey="${S3_ACCESS_KEY}" \ - --storage.s3.secretKey="${S3_SECRET_KEY}" \ - --storage.s3.prefix="${S3_PREFIX:-ente/}" \ - --storage.s3.forcePathStyle=true \ - --storage.s3.areLocalBuckets=false \ - --storage.type="s3" \ - --config.path="/app/data/config/museum.yaml" \ - --database.sslmode="disable" \ - --log.level=debug > /app/data/logs/museum-server.log 2>&1 & - else - cd "$SERVER_DIR" && \ - /usr/local/bin/gosu cloudron:cloudron env GOCACHE=/app/data/go/cache GOMODCACHE=/app/data/go/pkg/mod PORT=8080 GIN_MODE=release go run -modfile=/app/data/go/go.mod -mod=mod cmd/museum/main.go --port 8080 \ - --storage.s3.endpoint="${S3_ENDPOINT}" \ - --storage.s3.region="${S3_REGION}" \ - --storage.s3.bucket="${S3_BUCKET}" \ - --storage.s3.accessKey="${S3_ACCESS_KEY}" \ - --storage.s3.secretKey="${S3_SECRET_KEY}" \ - --storage.s3.prefix="${S3_PREFIX:-ente/}" \ - --storage.s3.forcePathStyle=true \ - --storage.s3.areLocalBuckets=false \ - --storage.type="s3" \ - --config.path="/app/data/config/museum.yaml" \ - --database.sslmode="disable" \ - --log.level=debug > /app/data/logs/museum-server.log 2>&1 & - fi + # Launch the server with S3 configuration + echo "==> Starting Museum server with S3 configuration" + cd "$SERVER_DIR" && \ + /usr/local/bin/gosu cloudron:cloudron env GOCACHE=/app/data/go/cache GOMODCACHE=/app/data/go/pkg/mod PORT=8080 GIN_MODE=release go run -modfile=/app/data/go/go.mod -mod=mod cmd/museum/main.go --port 8080 \ + --storage.s3.endpoint="${S3_ENDPOINT}" \ + --storage.s3.region="${S3_REGION}" \ + --storage.s3.bucket="${S3_BUCKET}" \ + --storage.s3.accessKey="${S3_ACCESS_KEY}" \ + --storage.s3.secretKey="${S3_SECRET_KEY}" \ + --storage.s3.prefix="${S3_PREFIX:-}" \ + --storage.s3.forcePathStyle=true \ + --storage.s3.areLocalBuckets=false \ + --storage.type="s3" \ + --config.path="/app/data/config/museum.yaml" \ + --database.sslmode="disable" \ + --log.level=debug > /app/data/logs/museum-server.log 2>&1 & SERVER_PID=$! echo "==> Museum server started with PID $SERVER_PID" @@ -709,7 +724,7 @@ else --storage.s3.bucket="${S3_BUCKET}" \ --storage.s3.accessKey="${S3_ACCESS_KEY}" \ --storage.s3.secretKey="${S3_SECRET_KEY}" \ - --storage.s3.prefix="${S3_PREFIX:-ente/}" \ + --storage.s3.prefix="${S3_PREFIX:-}" \ --storage.s3.forcePathStyle=true \ --storage.s3.areLocalBuckets=false \ --storage.type="s3" \