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.

66 lines
1.4 KiB

  1. #!/bin/bash
  2. . lib/common
  3. set -e
  4. domain=$(relation-get domain) || exit 1
  5. url=$(relation-get url) || exit 1
  6. # location=$CONFIGSTORE/$BASE_SERVICE_NAME/var/www/$domain
  7. upload_dir="${SERVICE_DATASTORE}/var/www/$domain/uploads"
  8. if [ -d "$upload_dir" ]; then
  9. uid_gid=$(stat --format=%u:%g "$upload_dir")
  10. else
  11. err "Upload dir '${upload_dir}' was not created. Can't continue."
  12. exit 1
  13. fi
  14. dirs=(
  15. /var/cache/gogocarto
  16. /var/lib/gogocarto/sessions
  17. /var/log/gogocarto
  18. )
  19. to_create=()
  20. for dir in "${dirs[@]}"; do
  21. fdir="${SERVICE_DATASTORE}${dir}"
  22. if ! [ -d "$fdir" ]; then
  23. to_create+=("$fdir")
  24. fi
  25. done
  26. if [ "${#to_create[@]}" -gt 0 ]; then
  27. mkdir -p "${to_create[@]}" &&
  28. chown -v "$uid_gid" "${to_create[@]}" &&
  29. chmod -v g+rwx "${to_create[@]}"
  30. fi
  31. cat <<EOF >> "${GOGOCARTO_CODE}"/.env
  32. BASE_PROTOCOL=${url%%://*}
  33. BASE_URL=$domain
  34. BASE_PATH=/index.php
  35. EOF
  36. cat <<EOF > "${GOGOCARTO_CODE}"/web/.htaccess
  37. Options -MultiViews
  38. RewriteEngine On
  39. RewriteCond %{REQUEST_FILENAME} !-f
  40. RewriteRule ^(.*)$ index.php/\$1 [QSA,L]
  41. EOF
  42. config-add "
  43. services:
  44. $MASTER_TARGET_SERVICE_NAME:
  45. volumes:
  46. - $SERVICE_CONFIGSTORE/opt/apps/gogocarto:/opt/apps/gogocarto:rw
  47. - $SERVICE_DATASTORE/var/cache/gogocarto:/opt/apps/gogocarto/var/cache:rw
  48. - $SERVICE_DATASTORE/var/lib/gogocarto/sessions:/opt/apps/gogocarto/var/sessions:rw
  49. - $SERVICE_DATASTORE/var/log/gogocarto:/opt/apps/gogocarto/var/log:rw
  50. "