Commit 64b7570c authored by Andreas Düren's avatar Andreas Düren
Browse files

Fix unbound variable error by moving environment variable definitions earlier in the script

parent 6f6741df
Loading
Loading
Loading
Loading
+13 −19
Original line number Diff line number Diff line
@@ -748,6 +748,19 @@ mkdir -p /app/data/go/pkg/mod /app/data/go/cache
chmod -R 777 /app/data/go
chown -R cloudron:cloudron /app/data/go

# Set necessary environment variables - MOVED EARLIER IN THE SCRIPT
export MUSEUM_CONFIG="/app/data/config/museum.yaml"
export MUSEUM_DB_HOST="${CLOUDRON_POSTGRESQL_HOST}"
export MUSEUM_DB_PORT="${CLOUDRON_POSTGRESQL_PORT}"
export MUSEUM_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
export MUSEUM_DB_PASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
export MUSEUM_DB_NAME="${CLOUDRON_POSTGRESQL_DATABASE}"
export ENTE_LOG_LEVEL=debug
export GOMODCACHE="/app/data/go/pkg/mod"
export GOCACHE="/app/data/go/cache"
export GO111MODULE=on
export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"

# Fix database migration state if needed
echo "==> Checking database migration state"
if [ -d "$SERVER_DIR/cmd/museum" ]; then
@@ -756,12 +769,6 @@ if [ -d "$SERVER_DIR/cmd/museum" ]; then
    # Create migrations log directory
    mkdir -p /app/data/logs/migrations
    
    # Set Go environment variables
    export GOMODCACHE="/app/data/go/pkg/mod"
    export GOCACHE="/app/data/go/cache"
    export GO111MODULE=on
    export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"
    
    echo "==> Forcing migration version to 25"
    # Execute as the cloudron user but use a proper script instead of env cd
    cat > /tmp/run_migration.sh <<EOF
@@ -785,19 +792,6 @@ fi
echo "==> Starting Museum server"
cd "$SERVER_DIR"

# Set necessary environment variables
export MUSEUM_CONFIG="/app/data/config/museum.yaml"
export MUSEUM_DB_HOST="${CLOUDRON_POSTGRESQL_HOST}"
export MUSEUM_DB_PORT="${CLOUDRON_POSTGRESQL_PORT}"
export MUSEUM_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
export MUSEUM_DB_PASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
export MUSEUM_DB_NAME="${CLOUDRON_POSTGRESQL_DATABASE}"
export ENTE_LOG_LEVEL=debug
export GOMODCACHE="/app/data/go/pkg/mod"
export GOCACHE="/app/data/go/cache"
export GO111MODULE=on
export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"

# Check if there's a pre-built binary
MUSEUM_BIN=""
if [ -f "$SERVER_DIR/bin/museum" ] && [ -x "$SERVER_DIR/bin/museum" ]; then