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

This commit is contained in:
Andreas Düren 2025-03-16 23:24:56 +01:00
parent 6f6741dfb5
commit 64b7570cc6

View File

@ -748,6 +748,19 @@ mkdir -p /app/data/go/pkg/mod /app/data/go/cache
chmod -R 777 /app/data/go chmod -R 777 /app/data/go
chown -R cloudron:cloudron /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 # Fix database migration state if needed
echo "==> Checking database migration state" echo "==> Checking database migration state"
if [ -d "$SERVER_DIR/cmd/museum" ]; then if [ -d "$SERVER_DIR/cmd/museum" ]; then
@ -756,12 +769,6 @@ if [ -d "$SERVER_DIR/cmd/museum" ]; then
# Create migrations log directory # Create migrations log directory
mkdir -p /app/data/logs/migrations 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" echo "==> Forcing migration version to 25"
# Execute as the cloudron user but use a proper script instead of env cd # Execute as the cloudron user but use a proper script instead of env cd
cat > /tmp/run_migration.sh <<EOF cat > /tmp/run_migration.sh <<EOF
@ -785,19 +792,6 @@ fi
echo "==> Starting Museum server" echo "==> Starting Museum server"
cd "$SERVER_DIR" 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 # Check if there's a pre-built binary
MUSEUM_BIN="" MUSEUM_BIN=""
if [ -f "$SERVER_DIR/bin/museum" ] && [ -x "$SERVER_DIR/bin/museum" ]; then if [ -f "$SERVER_DIR/bin/museum" ] && [ -x "$SERVER_DIR/bin/museum" ]; then