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.

116 lines
3.5 KiB

  1. # -*- mode: shell-script -*-
  2. GOGOCARTO_CODE="$SERVICE_CONFIGSTORE/opt/apps/gogocarto"
  3. GOGOCARTO_RELEASE=3.1.3-56-g6b8ba361
  4. GOGOCARTO_URL=https://docker.0k.io/downloads/gogocarto-"${GOGOCARTO_RELEASE}".tar.bz2
  5. gogocarto:init() {
  6. current_version=""
  7. if [ -d "${GOGOCARTO_CODE}" ]; then
  8. current_version=$(cat "${GOGOCARTO_CODE}"/.version) || {
  9. err "Couldn't find ${GOGOCARTO_CODE}/.version file."
  10. echo " Your config dir is in a broken state." >&2
  11. return 1
  12. }
  13. else
  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,.inited-*,.env} || return 1
  27. else
  28. err "Can't find the '.git' directory in ${GOGOCARTO_CODE}."
  29. return 1
  30. fi
  31. curl "$GOGOCARTO_URL" | tar xjv || {
  32. err "Couldn't download $GOGOCARTO_URL."
  33. return 1
  34. }
  35. echo "$GOGOCARTO_RELEASE" > .version
  36. git add -A . &&
  37. git commit -m "Release $GOGOCARTO_RELEASE"
  38. fi
  39. }
  40. gogocarto:config() {
  41. APP_ENV=$(options-get app-env 2>/dev/null) || true
  42. APP_ENV=${APP_ENV:-prod}
  43. cat <<EOF > "${GOGOCARTO_CODE}"/.env
  44. ###> symfony/framework-bundle ###
  45. APP_ENV=$APP_ENV
  46. APP_SECRET=82ec369b81caab5446ddfc3b5edb4d00
  47. CSRF_PROTECTION=$(
  48. [ "$APP_ENV" == "prod" ] &&
  49. echo "true" ||
  50. echo "false") ## active csrf protection on production servers
  51. #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
  52. #TRUSTED_HOSTS='^localhost|example\.com$'
  53. ###< symfony/framework-bundle ###
  54. ###> vich upload ###
  55. IMAGES_MAX_FILESIZE=8M # for public images upload
  56. IMAGE_RESIZE_WIDTH=1000 # in pixel
  57. FILES_MAX_FILESIZE=1M # for other public file upload
  58. ###> vich upload ###
  59. USE_AS_SAAS=false
  60. CONTACT_EMAIL=contact@localhost.fr
  61. INSTANCE_NAME=GoGoCarto
  62. ###> symfony/swiftmailer-bundle ###
  63. # For Gmail as a transport, use: "gmail://username:password@localhost"
  64. # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
  65. # Delivery is disabled by default via "null://localhost"
  66. MAILER_URL=gmail://test.gogocarto:creerdescartesagogo@localhost
  67. FROM_EMAIL=test.gogocarto@gmail.com
  68. ###< symfony/swiftmailer-bundle ###
  69. ###> hwi/oauth-bundle ###
  70. OAUTH_COMMUNS_ID=disabled
  71. OAUTH_COMMUNS_SECRET=disabled
  72. OAUTH_GOOGLE_ID=disabled
  73. OAUTH_GOOGLE_SECRET=disabled
  74. OAUTH_FACEBOOK_ID=disabled
  75. OAUTH_FACEBOOK_SECRET=disabled
  76. ###< hwi/oauth-bundle ###
  77. ###> sentry/sentry-symfony ###
  78. # Log errors nicely with sentry. Create your account on sentry.io and provide the DSN here
  79. # exple: SENTRY_DSN=https://6145d1aac36c429781fc1b0f79b0da48@sentry.io/1402018
  80. SENTRY_DSN=
  81. ###< sentry/sentry-symfony ###
  82. EOF
  83. }
  84. symphony() {
  85. export COMPOSE_IGNORE_ORPHANS=true
  86. ## We don't want post deploy that is doing the final http initialization.
  87. compose --debug -q --no-init --no-post-deploy \
  88. --without-relation="$SERVICE_NAME":web-proxy \
  89. run \
  90. "${symphony_docker_run_opts[@]}" \
  91. -T --rm -w /opt/apps/gogocarto \
  92. --entrypoint php \
  93. -u www-data "$SERVICE_NAME" bin/console "$@" | cat
  94. return "${PIPESTATUS[0]}"
  95. }