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.

136 lines
4.0 KiB

  1. # -*- mode: shell-script -*-
  2. GOGOCARTO_DIR="/opt/apps/gogocarto"
  3. GOGOCARTO_CODE="$SERVICE_CONFIGSTORE$GOGOCARTO_DIR"
  4. GOGOCARTO_RELEASE=3.4.10
  5. GOGOCARTO_URL=https://docker.0k.io/downloads/gogocarto-"${GOGOCARTO_RELEASE}".tar.bz2
  6. gogocarto:init() {
  7. current_version=""
  8. if [ -e "${GOGOCARTO_CODE}/.version" ]; then
  9. current_version="$(cat "${GOGOCARTO_CODE}/.version")" || return 1
  10. fi
  11. ## Note: previous content will be removed, if not in `.git` and no
  12. ## version matching current one
  13. if ! [ -d "${GOGOCARTO_CODE}/.git" ]; then
  14. mkdir -p "${GOGOCARTO_CODE}" &&
  15. cd "${GOGOCARTO_CODE}" &&
  16. git init . &&
  17. git config user.email "root@localhost" &&
  18. git config user.name "Root" || {
  19. err "Couldn't create directory ${GOGOCARTO_CODE}, or init it with git."
  20. return 1
  21. }
  22. fi
  23. if [ "$current_version" != "$GOGOCARTO_RELEASE" ]; then
  24. cd "${GOGOCARTO_CODE}" || return 1
  25. if [ -d "$PWD"/.git ]; then
  26. rm -rf "$PWD"/* "$PWD"/{.version,.env} || return 1
  27. else
  28. err "Can't find the '.git' directory in ${GOGOCARTO_CODE}."
  29. return 1
  30. fi
  31. curl -L "$GOGOCARTO_URL" | tar xj || {
  32. err "Couldn't download $GOGOCARTO_URL."
  33. return 1
  34. }
  35. echo "$GOGOCARTO_RELEASE" > .version
  36. git add -A . || {
  37. err "'git add -A .' in '${GOGOCARTO_CODE}' failed."
  38. return 1
  39. }
  40. if git diff --staged -s --exit-code; then
  41. info "No differences with last saved version."
  42. else
  43. git commit -m "Release $GOGOCARTO_RELEASE" || {
  44. err "'git commit' failed."
  45. return 1
  46. }
  47. rm -rf "$SERVICE_DATASTORE/var/cache/gogocarto/"*
  48. fi
  49. fi
  50. }
  51. gogocarto:config() {
  52. APP_ENV=$(options-get app-env 2>/dev/null) || true
  53. APP_ENV=${APP_ENV:-prod}
  54. cat <<EOF > "${GOGOCARTO_CODE}"/.env
  55. ###> symfony/framework-bundle ###
  56. APP_ENV=${APP_ENV}
  57. APP_SECRET=82ec369b81caab5446ddfc3b5edb4d00
  58. CSRF_PROTECTION=$(
  59. [ "$APP_ENV" == "prod" ] &&
  60. echo "true" ||
  61. echo "false") ## active csrf protection on production servers
  62. #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
  63. #TRUSTED_HOSTS='^localhost|example\.com$'
  64. ###< symfony/framework-bundle ###
  65. ###> vich upload ###
  66. IMAGES_MAX_FILESIZE=8M # for public images upload
  67. IMAGE_RESIZE_WIDTH=1000 # in pixel
  68. FILES_MAX_FILESIZE=1M # for other public file upload
  69. ###> vich upload ###
  70. USE_AS_SAAS=false
  71. USE_AS_SAAS_PRIVATE=false
  72. CONTACT_EMAIL=contact@localhost.fr
  73. INSTANCE_NAME=GoGoCarto
  74. ###> symfony/swiftmailer-bundle ###
  75. # For Gmail as a transport, use: "gmail://username:password@localhost"
  76. # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
  77. # Delivery is disabled by default via "null://localhost"
  78. MAILER_URL=gmail://test.gogocarto:creerdescartesagogo@localhost
  79. FROM_EMAIL=test.gogocarto@gmail.com
  80. MAX_EMAIL_PER_HOUR=70
  81. ###< symfony/swiftmailer-bundle ###
  82. ###> hwi/oauth-bundle ###
  83. OAUTH_COMMUNS_ID=disabled
  84. OAUTH_COMMUNS_SECRET=disabled
  85. OAUTH_GOOGLE_ID=disabled
  86. OAUTH_GOOGLE_SECRET=disabled
  87. OAUTH_FACEBOOK_ID=disabled
  88. OAUTH_FACEBOOK_SECRET=disabled
  89. ###< hwi/oauth-bundle ###
  90. ###> sentry/sentry-symfony ###
  91. # Log errors nicely with sentry. Create your account on sentry.io and provide the DSN here
  92. # exple: SENTRY_DSN=https://6145d1aac36c429781fc1b0f79b0da48@sentry.io/1402018
  93. SENTRY_DSN=
  94. ###< sentry/sentry-symfony ###
  95. ###> Matomo integration - see docs/matomo.md ###
  96. MATOMO_URL=
  97. MATOMO_SITE_ID=
  98. MATOMO_USER_TOKEN=
  99. ###< Matomo ###
  100. EOF
  101. }
  102. symphony() {
  103. export COMPOSE_IGNORE_ORPHANS=true
  104. ## We don't want post deploy that is doing the final http initialization.
  105. compose --debug -q --no-init --no-post-deploy \
  106. --without-relation="$SERVICE_NAME":web-proxy \
  107. run \
  108. "${symphony_docker_run_opts[@]}" \
  109. -T --rm -w /opt/apps/gogocarto \
  110. --entrypoint php \
  111. -u www-data "$SERVICE_NAME" bin/console "$@" | cat
  112. return "${PIPESTATUS[0]}"
  113. }