-
Notifications
You must be signed in to change notification settings - Fork 12
/
postDeploy.sh
97 lines (82 loc) · 2.68 KB
/
postDeploy.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
for arg
do
case "${arg}" in
--version=* )
VERSION="${arg#*=}"
;;
--version-migrate=* )
VERSION_MIGRATE="${arg#*=}"
;;
--instance=* )
INSTANCE="${arg#*=}"
;;
esac
done
ROOT=/var/www
case "${VERSION}" in
prod_test ) # prod_test is a special case
ROOT+="/prod/${INSTANCE}"
;;
dev | test )
ROOT+="/${VERSION}/${INSTANCE}"
;;
* )
ROOT+="/${INSTANCE}/${VERSION}"
;;
esac
declare -a json_files_dist=(
"${ROOT}/api/config/rdex/clients.json"\
"${ROOT}/api/config/rdex/operator.json"\
"${ROOT}/api/config/rdex/providers.json"\
"${ROOT}/api/config/publicTransport/providers.json"\
"${ROOT}/api/config/params/modules.json"\
"${ROOT}/api/config/params/contacts.json"\
"${ROOT}/api/config/params/analytics.json"\
"${ROOT}/client/config/geocomplete/palette.json"\
"${ROOT}/api/config/params/commands.json"\
"${ROOT}/api/config/csvExport/csvExport.json"\
"${ROOT}/api/config/params/reminders.json"\
"${ROOT}/api/config/params/eecService.json"\
"${ROOT}/api/config/geodata/geopointfix.json"\
"${ROOT}/api/config/packages/service_account.json"
)
# if json file does not exist, copy it from .dist file
for json_file in "${json_files_dist[@]}"
do
[ -f "${json_file}" ] || cp "${json_file}.dist" "${json_file}"
done
DOMAINS_FILE="${ROOT}/api/config/user/domains.json"
SSO_FILE="${ROOT}/api/config/user/sso.json"
# if json file does not exist, create it with empty braces
for json_file in "${DOMAINS_FILE}" "${SSO_FILE}"
do
[ -f "${json_file}" ] || echo "{}" >"${json_file}"
done
# Migrations
cd ${ROOT}/api
php bin/console doctrine:migrations:migrate --env=${VERSION_MIGRATE} -n
# Migrations instance
cd ${ROOT}/client
php bin/console doctrine:migrations:migrate --env=${VERSION_MIGRATE} -n
# Crontab update
python3 ${ROOT}/scripts/updateCrontab.py --env=${VERSION_MIGRATE}
# External Cgu Mango
EXTERNAL_CGU_DIRECTORY=${ROOT}/client/public/externalCgu
[ -d "${EXTERNAL_CGU_DIRECTORY}" ] || mkdir -p "${EXTERNAL_CGU_DIRECTORY}"
cd "${EXTERNAL_CGU_DIRECTORY}"
wget -N https://www.mangopay.com/terms/PSP/PSP_MANGOPAY_FR.pdf
# clear cache
cd ${ROOT}/api
php bin/console cache:clear --env=${VERSION_MIGRATE}
cd ${ROOT}/client
php bin/console cache:clear --env=${VERSION_MIGRATE}
# Remove maintenance page
rm ${ROOT}/api/public/maintenance.enable ${ROOT}/client/public/maintenance.enable
# Fixtures for test
if [ "${VERSION}" = "test" ]
then
cd ${ROOT}/api
php bin/console doctrine:fixtures:load -n -v --append --group=basic --env=${VERSION_MIGRATE}
php bin/console doctrine:fixtures:load -n -v --append --group=solidary --env=${VERSION_MIGRATE}
fi