-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimetracker.sh
executable file
·72 lines (66 loc) · 1.76 KB
/
timetracker.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
66
67
68
69
70
71
72
#!/bin/bash
# Copyright (C) 2024 Devexperts Solutions IE Limited
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
check_env_var() {
if [ -z "${!1}" ]; then
echo "Error: $1 is not set in the .env file."
exit 1
fi
}
if [ -f .env ]; then
set -a
source .env
set +a
else
echo ".env file not found."
exit 1
fi
check_env_var "VERSION_NUMBER"
check_env_var "OAUTH_CONSUMER_KEY"
check_env_var "OAUTH_ACCESS_TOKEN"
check_env_var "OAUTH_PRIVATE_KEY"
check_env_var "OAUTH_SECRET"
check_env_var "JIRA_URL"
check_env_var "JTT_WEBAPP_HOST"
compose_ssl="docker-compose --profile proxy-ssl"
compose_no_ssl="docker-compose --profile proxy-no-ssl"
case $1 in
init)
check_env_var "FULL_CHAIN_PEM"
check_env_var "PRIVATE_KEY_PEM"
docker network create backend 2>/dev/null || true
docker volume create dumps 2>/dev/null || true
envsubst '${JTT_WEBAPP_HOST} ${FULL_CHAIN_PEM} ${PRIVATE_KEY_PEM}' < proxy/nginx.conf.template > proxy/nginx.conf
;;
init-no-ssl)
docker network create backend 2>/dev/null || true
docker volume create dumps 2>/dev/null || true
envsubst '${JTT_WEBAPP_HOST}' < proxy/nginx.no-ssl.conf.template > proxy/nginx.no-ssl.conf
;;
start)
$compose_ssl up -d
;;
start-no-ssl)
$compose_no_ssl up -d
;;
stop)
$compose_ssl down
;;
stop-no-ssl)
$compose_no_ssl down
;;
restart)
$compose_ssl down && $compose_ssl up -d
;;
restart-no-ssl)
$compose_no_ssl down && $compose_no_ssl up -d
;;
update)
$compose_ssl down
$compose_ssl up -d
;;
*)
echo "Unknown parameter. Doing nothing"
;;
esac