#!/bin/bash file_env() { local SECRET_NAME=$1 local SECRET_PATH="/run/secrets/$SECRET_NAME" # Check if the secret file exists if [[ -f "$SECRET_PATH" ]]; then # Read the secret value local SECRET_VALUE=$(<"$SECRET_PATH") # Export as an environment variable eval "export $2=\"$SECRET_VALUE\"" else echo "Secret file not found: $SECRET_PATH" fi } file_env "jwt_secret" "JWT_SECRET" file_env "db_password" "DB_PASSWORD" file_env "smtp_password" "EMAIL_PASS" file_env "mastodon_client_secret" "MASTODON_CLIENT_SECRET" file_env "instagram_app_secret" "INSTAGRAM_APP_SECRET" export DATABASE_URL="postgresql://postiz-user:${DB_PASSWORD}@postiz-postgres:5432/postiz-db-local" pnpm run pm2