57 lines
2.0 KiB
Bash
Executable File
57 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Setup Environment Variables Script
|
|
echo "Setting up environment variables..."
|
|
|
|
# Copy the docker-compose.env to .env if it doesn't exist
|
|
if [ ! -f .env ]; then
|
|
echo "Creating .env file from docker-compose.env..."
|
|
cp docker-compose.env .env
|
|
echo "✅ .env file created successfully!"
|
|
else
|
|
echo "⚠️ .env file already exists. Skipping..."
|
|
fi
|
|
|
|
# Generate secure secrets if they haven't been changed from defaults
|
|
echo ""
|
|
echo "Checking for default secrets..."
|
|
|
|
# Function to generate a random string (alphanumeric only)
|
|
generate_secret() {
|
|
openssl rand -hex 32
|
|
}
|
|
|
|
# Simple approach: create a new .env file with replacements
|
|
if grep -q "your-jwt-secret-here-change-this-in-production" .env; then
|
|
echo "Generating new JWT_SECRET..."
|
|
sed "s/your-jwt-secret-here-change-this-in-production/$(generate_secret)/g" .env > .env.tmp && mv .env.tmp .env
|
|
fi
|
|
|
|
if grep -q "your-admin-jwt-secret-here-change-this-in-production" .env; then
|
|
echo "Generating new ADMIN_JWT_SECRET..."
|
|
sed "s/your-admin-jwt-secret-here-change-this-in-production/$(generate_secret)/g" .env > .env.tmp && mv .env.tmp .env
|
|
fi
|
|
|
|
if grep -q "your-app-keys-here-change-this-in-production" .env; then
|
|
echo "Generating new APP_KEYS..."
|
|
sed "s/your-app-keys-here-change-this-in-production/$(generate_secret)/g" .env > .env.tmp && mv .env.tmp .env
|
|
fi
|
|
|
|
if grep -q "your-api-token-salt-here-change-this-in-production" .env; then
|
|
echo "Generating new API_TOKEN_SALT..."
|
|
sed "s/your-api-token-salt-here-change-this-in-production/$(generate_secret)/g" .env > .env.tmp && mv .env.tmp .env
|
|
fi
|
|
|
|
if grep -q "your-transfer-token-salt-here-change-this-in-production" .env; then
|
|
echo "Generating new TRANSFER_TOKEN_SALT..."
|
|
sed "s/your-transfer-token-salt-here-change-this-in-production/$(generate_secret)/g" .env > .env.tmp && mv .env.tmp .env
|
|
fi
|
|
|
|
echo ""
|
|
echo "✅ Environment setup complete!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Review and modify the .env file if needed"
|
|
echo "2. Run: docker-compose up -d"
|
|
echo ""
|
|
echo "Note: The .env file is gitignored for security reasons." |