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.

116 lines
3.5 KiB

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