fork 0k-charms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.7 KiB

  1. # -*- mode: shell-script -*-
  2. MATOMO_DIR="/opt/apps/matomo"
  3. MATOMO_CODE="$SERVICE_CONFIGSTORE$MATOMO_DIR"
  4. MATOMO_RELEASE=4.16.0
  5. MATOMO_URL=https://github.com/matomo-org/matomo/archive/"${MATOMO_RELEASE}".tar.gz
  6. #MATOMO_URL=https://docker.0k.io/downloads/matomo-"${MATOMO_RELEASE}".tar.gz
  7. MATOMO_CONFIG_FILE="${MATOMO_CODE}"/config/config.ini.php
  8. matomo:init() {
  9. current_version=""
  10. if [ -d "${MATOMO_CODE}" ]; then
  11. current_version=$(cat "${MATOMO_CODE}"/.version) || {
  12. err "Couldn't find ${MATOMO_CODE}/.version file."
  13. echo " Your config dir is in a broken state." >&2
  14. return 1
  15. }
  16. else
  17. mkdir -p "${MATOMO_CODE}" &&
  18. cd "${MATOMO_CODE}" &&
  19. git init . &&
  20. git config user.email "root@localhost" &&
  21. git config user.name "Root" || {
  22. err "Couldn't create directory ${MATOMO_CODE}, or init it with git."
  23. return 1
  24. }
  25. fi
  26. if [ "$current_version" != "$MATOMO_RELEASE" ]; then
  27. cd "${MATOMO_CODE}" || return 1
  28. [ -d "$MATOMO_CODE"/.git ] || {
  29. err "Can't find the '.git' directory in ${MATOMO_CODE}."
  30. return 1
  31. }
  32. rm -rf "$MATOMO_CODE"/* "$MATOMO_CODE"/{.version,.inited-*} || return 1
  33. curl -L "$MATOMO_URL" | tar xzv || {
  34. #if [ -f "$MATOMO_URL" ]; then
  35. # git checkout HEAD
  36. #else
  37. # rmdir "$MATOMO_URL"
  38. #fi
  39. err "Couldn't download $MATOMO_URL."
  40. return 1
  41. }
  42. mv matomo-*/* matomo-*/{.bowerrc,.lfsconfig} . && rmdir matomo-*
  43. echo "$MATOMO_RELEASE" > .version
  44. git add -A . &&
  45. git commit -m "Release $MATOMO_RELEASE"
  46. fi
  47. }
  48. matomo:config() {
  49. [ -f "$MATOMO_CONFIG_FILE" ] || {
  50. cat <<EOF > "$MATOMO_CONFIG_FILE"
  51. ; <?php exit; ?> DO NOT REMOVE THIS LINE
  52. ; file automatically generated or modified by Matomo; you can manually override the default values in global.ini.php by redefining them in this file.
  53. EOF
  54. }
  55. crudini --get "$MATOMO_CONFIG_FILE" General salt >dev/null || {
  56. salt=$(dd if=/dev/urandom bs=1 count=16 2>/dev/null | hexdump -v -e '/1 "%02x"')
  57. crudini --set "$MATOMO_CONFIG_FILE" General salt \"$salt\"
  58. crudini --set "$MATOMO_CONFIG_FILE" General installation_in_progress 1
  59. }
  60. }
  61. matomo:curl() {
  62. local url="$1"
  63. curl "$url"
  64. }
  65. # matomo:wizard() {
  66. # PAGES=(
  67. # "systemCheck"
  68. # "databaseSetup"
  69. # "tablesCreation"
  70. # "setupSuperUser"
  71. # "setupSuperUser"
  72. # "firstWebsiteSetup"
  73. # "firstWebsiteSetup"
  74. # "trackingCode"
  75. # "finished"
  76. # )
  77. # matomo:curl
  78. # }