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.

126 lines
3.8 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 xj || {
  33. err "Couldn't download $GOGOCARTO_URL."
  34. return 1
  35. }
  36. echo "$GOGOCARTO_RELEASE" > .version
  37. git add -A . || {
  38. err "'git add -A .' in '${GOGOCARTO_CODE}' failed."
  39. return 1
  40. }
  41. if git diff --staged -s --exit-code; then
  42. info "No differences with last saved version."
  43. else
  44. git commit -m "Release $GOGOCARTO_RELEASE" || {
  45. err "'git commit' failed."
  46. return 1
  47. }
  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. CONTACT_EMAIL=contact@localhost.fr
  72. INSTANCE_NAME=GoGoCarto
  73. ###> symfony/swiftmailer-bundle ###
  74. # For Gmail as a transport, use: "gmail://username:password@localhost"
  75. # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
  76. # Delivery is disabled by default via "null://localhost"
  77. MAILER_URL=gmail://test.gogocarto:creerdescartesagogo@localhost
  78. FROM_EMAIL=test.gogocarto@gmail.com
  79. ###< symfony/swiftmailer-bundle ###
  80. ###> hwi/oauth-bundle ###
  81. OAUTH_COMMUNS_ID=disabled
  82. OAUTH_COMMUNS_SECRET=disabled
  83. OAUTH_GOOGLE_ID=disabled
  84. OAUTH_GOOGLE_SECRET=disabled
  85. OAUTH_FACEBOOK_ID=disabled
  86. OAUTH_FACEBOOK_SECRET=disabled
  87. ###< hwi/oauth-bundle ###
  88. ###> sentry/sentry-symfony ###
  89. # Log errors nicely with sentry. Create your account on sentry.io and provide the DSN here
  90. # exple: SENTRY_DSN=https://6145d1aac36c429781fc1b0f79b0da48@sentry.io/1402018
  91. SENTRY_DSN=
  92. ###< sentry/sentry-symfony ###
  93. EOF
  94. }
  95. symphony() {
  96. export COMPOSE_IGNORE_ORPHANS=true
  97. ## We don't want post deploy that is doing the final http initialization.
  98. compose --debug -q --no-init --no-post-deploy \
  99. --without-relation="$SERVICE_NAME":web-proxy \
  100. run \
  101. "${symphony_docker_run_opts[@]}" \
  102. -T --rm -w /opt/apps/gogocarto \
  103. --entrypoint php \
  104. -u www-data "$SERVICE_NAME" bin/console "$@" | cat
  105. return "${PIPESTATUS[0]}"
  106. }