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.

140 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. ## 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. USE_AS_SAAS=false
  73. USE_AS_SAAS_PRIVATE=false
  74. CONTACT_EMAIL=contact@localhost.fr
  75. INSTANCE_NAME=GoGoCarto
  76. ###> symfony/swiftmailer-bundle ###
  77. # For Gmail as a transport, use: "gmail://username:password@localhost"
  78. # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
  79. # Delivery is disabled by default via "null://localhost"
  80. MAILER_URL=gmail://test.gogocarto:creerdescartesagogo@localhost
  81. FROM_EMAIL=test.gogocarto@gmail.com
  82. MAX_EMAIL_PER_HOUR=70
  83. ###< symfony/swiftmailer-bundle ###
  84. ###> hwi/oauth-bundle ###
  85. OAUTH_COMMUNS_ID=disabled
  86. OAUTH_COMMUNS_SECRET=disabled
  87. OAUTH_GOOGLE_ID=disabled
  88. OAUTH_GOOGLE_SECRET=disabled
  89. OAUTH_FACEBOOK_ID=disabled
  90. OAUTH_FACEBOOK_SECRET=disabled
  91. ###< hwi/oauth-bundle ###
  92. ###> sentry/sentry-symfony ###
  93. # Log errors nicely with sentry. Create your account on sentry.io and provide the DSN here
  94. # exple: SENTRY_DSN=https://6145d1aac36c429781fc1b0f79b0da48@sentry.io/1402018
  95. SENTRY_DSN=
  96. ###< sentry/sentry-symfony ###
  97. ###> Matomo integration - see docs/matomo.md ###
  98. MATOMO_URL=
  99. MATOMO_SITE_ID=
  100. MATOMO_USER_TOKEN=
  101. ###< Matomo ###
  102. EOF
  103. }
  104. symphony() {
  105. export COMPOSE_IGNORE_ORPHANS=true
  106. ## We don't want post deploy that is doing the final http initialization.
  107. compose --debug -q --no-init --no-post-deploy --no-pre-deploy \
  108. --without-relation="$SERVICE_NAME":web-proxy \
  109. run \
  110. "${symphony_docker_run_opts[@]}" \
  111. -T --rm -w /opt/apps/"$SERVICE_NAME" \
  112. --entrypoint php \
  113. -u www-data "$SERVICE_NAME" bin/console "$@" | cat
  114. return "${PIPESTATUS[0]}"
  115. }