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