-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·64 lines (49 loc) · 1.8 KB
/
entrypoint.sh
File metadata and controls
executable file
·64 lines (49 loc) · 1.8 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
#!/bin/bash
set -e
messageJiraSecret=$(cat << EOF
WARNING: Jira functionality will be limited.
To use Jira integration features, please specify JIRA_CLIENT_SECRET environment variable.
For example, "-e JIRA_CLIENT_SECRET=secret" on "docker run".
EOF
)
messageClientId=$(cat << EOF
WARNING: Yandex Tracker functionality will be limited.
To use Yandex Tracker integration features, please specify CLIENT_ID environment variable.
For example, "-e CLIENT_ID=clientid" on "docker run".
EOF
)
messageJiraClientId=$(cat << EOF
WARNING: Jira functionality will be limited.
To use Jira integration features, please specify JIRA_CLIENT_ID environment variable.
For example, "-e JIRA_CLIENT_ID=jiraclientid" on "docker run".
EOF
)
auto_config() {
local config_file="${CONFIG_FILE:-./public/local/api/config.json}"
local output_file="${OUTPUT_FILE:-./temp.json}"
local missing_vars=0
if [ -z "$JIRA_CLIENT_SECRET" ]; then
echo "$messageJiraSecret"
missing_vars=$((missing_vars+1))
fi
if [ -z "$CLIENT_ID" ]; then
echo "$messageClientId"
missing_vars=$((missing_vars+1))
fi
if [ -z "$JIRA_CLIENT_ID" ]; then
echo "$messageJiraClientId"
missing_vars=$((missing_vars+1))
fi
if [ "$missing_vars" -eq 3 ]; then
echo "Error: All required environment variables are missing (JIRA_CLIENT_SECRET, CLIENT_ID, JIRA_CLIENT_ID). At least one of them must be provided for the application to work correctly."
exit 1
fi
# Replace values in file with values from variables
jq --arg client_id "$CLIENT_ID" --arg jira_client_id "$JIRA_CLIENT_ID" \
'.auth.params.client_id = $client_id | .jiraAuth.params.client_id = $jira_client_id' \
public/local/api/config.json > "$output_file"
# Delete temporary file
cat "$output_file" > "$config_file" && rm "$output_file"
}
auto_config
exec "$@"