matomo.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env bash
  2. while true;do ls | grep -q dockerbunker.sh;if [[ $? == 0 ]];then BASE_DIR=$PWD;break;else cd ../;fi;done
  3. PROPER_NAME="Matomo"
  4. SERVICE_NAME="$(echo -e "${PROPER_NAME,,}" | tr -d '[:space:]')"
  5. PROMPT_SSL=1
  6. safe_to_keep_volumes_when_reconfiguring=1
  7. declare -a environment=( "data/env/dockerbunker.env" "data/include/init.sh" )
  8. for env in "${environment[@]}";do
  9. [[ -f "${BASE_DIR}"/$env ]] && source "${BASE_DIR}"/$env
  10. done
  11. declare -A WEB_SERVICES
  12. declare -a containers=( "${SERVICE_NAME}-service-dockerbunker" "${SERVICE_NAME}-db-dockerbunker" )
  13. declare -A volumes=( [${SERVICE_NAME}-data-vol-1]="/var/www/html/config" [${SERVICE_NAME}-db-vol-1]="/var/lib/mysql" )
  14. declare -a add_to_network=( "${SERVICE_NAME}-service-dockerbunker" )
  15. declare -a networks=( "dockerbunker-${SERVICE_NAME}" )
  16. declare -A IMAGES=( [service]="matomo" [db]="mariadb:10.2" )
  17. [[ -z $1 ]] && options_menu
  18. configure() {
  19. pre_configure_routine
  20. echo -e "# \e[4mMatomo Settings\e[0m"
  21. set_domain
  22. # avoid tr illegal byte sequence in macOS when generating random strings
  23. if [[ $OSTYPE =~ "darwin" ]];then
  24. if [[ $LC_ALL ]];then
  25. oldLC_ALL=$LC_ALL
  26. export LC_ALL=C
  27. else
  28. export LC_ALL=C
  29. fi
  30. fi
  31. cat <<-EOF >> ${SERVICE_ENV}
  32. SSL_CHOICE=${SSL_CHOICE}
  33. LE_EMAIL=${LE_EMAIL}
  34. # ------------------------------
  35. # General Settings
  36. # ------------------------------
  37. SERVICE_DOMAIN=${SERVICE_DOMAIN}
  38. # ------------------------------
  39. # Matomo SQL database configuration
  40. # ------------------------------
  41. MYSQL_DATABASE=matomo
  42. MYSQL_USER=matomo
  43. # Please use long, random alphanumeric strings (A-Za-z0-9)
  44. MYSQL_PASSWORD=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 28)
  45. MYSQL_ROOT_PASSWORD=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 28)
  46. EOF
  47. if [[ $OSTYPE =~ "darwin" ]];then
  48. [[ $oldLC_ALL ]] && export LC_ALL=$oldLC_ALL || unset LC_ALL
  49. fi
  50. post_configure_routine
  51. }
  52. # i think this can/should go now... if it goes, change tests in letsencrypt function (\$1, \$2 \$* etc)
  53. if [[ $1 == "letsencrypt" ]];then
  54. $1 $*
  55. else
  56. $1
  57. fi