31 lines
895 B
Bash
31 lines
895 B
Bash
#!/bin/bash
|
|
|
|
# Script to create secret file from template
|
|
# Usage: ./create-secret-file-from-template.sh /path/to/template /path/to/output
|
|
|
|
TEMPLATE_FILE="${1:-lottery-config.properties.template}"
|
|
OUTPUT_FILE="${2:-/run/secrets/lottery-config.properties}"
|
|
OUTPUT_DIR=$(dirname "$OUTPUT_FILE")
|
|
|
|
# Check if template exists
|
|
if [ ! -f "$TEMPLATE_FILE" ]; then
|
|
echo "❌ Template file not found: $TEMPLATE_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Create output directory if it doesn't exist
|
|
mkdir -p "$OUTPUT_DIR"
|
|
|
|
# Copy template to output
|
|
cp "$TEMPLATE_FILE" "$OUTPUT_FILE"
|
|
|
|
# Set secure permissions (read-only for owner, no access for others)
|
|
chmod 600 "$OUTPUT_FILE"
|
|
|
|
echo "✅ Secret file created at $OUTPUT_FILE"
|
|
echo "⚠️ IMPORTANT: Edit this file and replace all placeholder values with your actual configuration!"
|
|
echo "⚠️ After editing, ensure permissions are secure: chmod 600 $OUTPUT_FILE"
|
|
|
|
|
|
|