-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
56 lines (39 loc) · 1.75 KB
/
entrypoint.sh
File metadata and controls
56 lines (39 loc) · 1.75 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
MY=(
[ROLE]=app
[RUN_AS]=www
[APP_NAME]="${APP_NAME:-TurnKey Matomo}"
[APP_USER]="${APP_USER:-admin}"
[APP_MAIL]="${APP_MAIL:-admin@example.com}"
[APP_PASS]="${APP_PASS:-}"
[APP_SITE]="${APP_SITE:-}" # unused for now
[DB_HOST]="${DB_HOST:-127.0.0.1}"
[DB_USER]="${DB_USER:-matomo}"
[DB_NAME]="${DB_NAME:-matomo}"
[DB_PASS]="${DB_PASS:-$(secret consume DB_PASS)}"
[DB_PREFIX]="${DB_PREFIX:-matomo_}"
)
passthrough_unless 'php-fpm' "$@"
INITDB="${OUR[INITDBS]}/matomo.sql"
add vhosts matomo
web_extract_src matomo
random_if_empty APP_PASS
SQL="${OUR[SRCDIR]}/matomo-3.11.0.sql"
sed -i "s|#__|${MY[DB_PREFIX]}|" "${SQL}"
cp "${OUR[SRCDIR]}/config.ini.php" "${OUR[WEBDIR]}/config"
sed -i "s|host = \".*\"|host = \"${MY[DB_HOST]}\"|" "${OUR[WEBDIR]}/config/config.ini.php"
sed -i "s|username = \".*\"|username = \"${MY[DB_USER]}\"|" "${OUR[WEBDIR]}/config/config.ini.php"
sed -i "s|password = \".*\"|password = \"${MY[DB_PASS]}\"|" "${OUR[WEBDIR]}/config/config.ini.php"
sed -i "s|dbname = \".*\"|dbname = \"${MY[DB_NAME]}\"|" "${OUR[WEBDIR]}/config/config.ini.php"
sed -i "s|salt = \".*\"|salt = \"$(mcookie)\"|" "${OUR[WEBDIR]}/config/config.ini.php"
cp "${SQL}" "${INITDB}"
unset SQL
PASS_HASH="$(php -r "echo password_hash(md5('${APP_PASS}'), PASSWORD_DEFAULT);")"
# add trusted host
echo "UPDATE matomo_option SET option_value='${APP_HOST}' WHERE option_name='matomoUrl';" >> "${INITDB}"
sed -i "s|trusted_hosts\[\] = \".*\"|trusted hosts\[\] = \"${APP_HOST}\"|" "${OUR[WEBDIR]}/config/config.ini.php"
# update admin user
echo "UPDATE matomo_user SET email='${APP_MAIL}';" >> "${INITDB}"
echo "UPDATE matomo_user SET password='${PASS_HASH}'" >> "${INITDB}"
chown -R www-data:www-data "${OUR[WEBDIR]}"
#reload_vhosts
run "$@"