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.

146 lines
4.3 KiB

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