-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.sh
65 lines (54 loc) · 1.62 KB
/
utils.sh
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
#!/bin/bash
get_license_key() {
read -p "Enter your license key (Get one for free instantly at $SELF_HOSTING_URI): " user_input
if [[ $user_input =~ ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$ ]]; then
echo $user_input
else
echo $INVALID_LICENSE_KEY
return 1
fi
}
get_host() {
read -p "What public host name or public IP address are you using for this setup (e.g. localhost, app.quadratic.com, or other): " user_input
# TODO: validate host
echo $user_input
}
checkout() {
git clone $REPO
cd quadratic-selfhost
git checkout
}
parse_profile() {
# automatically export all variables
set -a
[[ -f ".env" ]] && source .env
# disable auto export
set +a
values=()
variables=(
"DATABASE_IN_DOCKER_COMPOSE"
"PUBSUB_IN_DOCKER_COMPOSE"
"CADDY_IN_DOCKER_COMPOSE"
"ORY_IN_DOCKER_COMPOSE"
"QUADRATIC_CLIENT_IN_DOCKER_COMPOSE"
"QUADRATIC_API_IN_DOCKER_COMPOSE"
"QUADRATIC_MULTIPLAYER_IN_DOCKER_COMPOSE"
"QUADRATIC_FILES_IN_DOCKER_COMPOSE"
"QUADRATIC_FILES_URL_INTERNAL"
"QUADRATIC_FILES_URL_EXTERNAL"
"QUADRATIC_CONNECTION_IN_DOCKER_COMPOSE"
)
for var_name in "${variables[@]}"; do
local var_value=$(eval echo \$$var_name)
if [ "$var_value" == "true" ]; then
# store the lowercase variable name
var_name_stripped=$(echo "$var_name" | sed 's/_IN_DOCKER_COMPOSE//g')
var_name_lower=$(echo "$var_name_stripped" | awk '{print tolower($0)}')
values+=("--profile ${var_name_lower}")
fi
done
echo "${values[@]}"
}
generate_random_encryption_key() {
openssl rand -hex 32
}