-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·109 lines (98 loc) · 3.33 KB
/
run.sh
File metadata and controls
executable file
·109 lines (98 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env bash
set -e
# Helper functions
function print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --mode MODE Set deployment mode (monolith|microservices) [default: monolith]"
echo " --generate-certs Generate new certificates"
echo " --chrome-flags Print Chrome flags for WebTransport"
echo " --help Print this help message"
}
# Default values
DEPLOYMENT_MODE="monolith"
GENERATE_CERTS=false
PRINT_CHROME_FLAGS=false
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--mode)
DEPLOYMENT_MODE="$2"
shift 2
;;
--generate-certs)
GENERATE_CERTS=true
shift
;;
--chrome-flags)
PRINT_CHROME_FLAGS=true
shift
;;
--help)
print_usage
exit 0
;;
*)
echo "Unknown option: $1"
print_usage
exit 1
;;
esac
done
# Validate deployment mode
if [[ "$DEPLOYMENT_MODE" != "monolith" && "$DEPLOYMENT_MODE" != "microservices" ]]; then
echo "Error: Deployment mode must be 'monolith' or 'microservices'"
exit 1
fi
# Create certs directory if it doesn't exist
mkdir -p certs
# Generate certificates if requested or if they don't exist
if [[ "$GENERATE_CERTS" = true ]] || [[ ! -f certs/cert.pem ]] || [[ ! -f certs/key.pem ]]; then
echo "Generating TLS certificates..."
./generate_certs.sh --output-dir ./certs
fi
# Extract SPKI hash if not already saved
if [[ ! -f certs/spki_hash.txt ]] || [[ "$GENERATE_CERTS" = true ]]; then
SPKI_HASH=$(openssl x509 -in certs/cert.pem -pubkey -noout | \
openssl pkey -pubin -outform der | \
openssl dgst -sha256 -binary | \
base64)
echo "$SPKI_HASH" > certs/spki_hash.txt
else
SPKI_HASH=$(cat certs/spki_hash.txt)
fi
# Print Chrome flags if requested
if [[ "$PRINT_CHROME_FLAGS" = true ]]; then
echo "To use WebTransport with Chrome, run:"
echo "-------------------------------------------------------------------------"
echo "chrome --origin-to-force-quic-on=localhost:4433,localhost:4434 --ignore-certificate-errors-spki-list=$SPKI_HASH"
echo "-------------------------------------------------------------------------"
exit 0
fi
# Stop any existing containers
echo "Stopping any existing FlappyGo! containers..."
docker-compose down || true
# Start the application
echo "Starting FlappyGo! in $DEPLOYMENT_MODE mode..."
export DEPLOYMENT_MODE=$DEPLOYMENT_MODE
docker-compose --profile $DEPLOYMENT_MODE up --build -d
# Print WebTransport URLs
echo "-------------------------------------------------------------------------"
echo "FlappyGo! is now running!"
echo
echo "Client URL: http://localhost:8080"
echo
if [[ "$DEPLOYMENT_MODE" = "monolith" ]]; then
echo "WebTransport URLs:"
echo "Game: https://localhost:4433/gameEngine/GameSession"
echo "Music: https://localhost:4433/music/MusicSession"
else
echo "WebTransport URLs:"
echo "Game: https://localhost:4433/gameEngine/GameSession"
echo "Music: https://localhost:4434/music/MusicSession"
fi
echo
echo "Your browser must be started with special flags!"
echo "-------------------------------------------------------------------------"
echo "chrome --origin-to-force-quic-on=localhost:4433,localhost:4434 --ignore-certificate-errors-spki-list=$SPKI_HASH"
echo "-------------------------------------------------------------------------"