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.

69 lines
1.5 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. RewriteRule ^js/.* - [L]
  40. RewriteCond %{REQUEST_FILENAME} !-f
  41. RewriteRule ^(.*)$ index.php/\$1 [QSA,L]
  42. EOF
  43. config-add "
  44. services:
  45. $MASTER_TARGET_SERVICE_NAME:
  46. volumes:
  47. - $GOGOCARTO_CODE:$GOGOCARTO_DIR:rw
  48. - $SERVICE_DATASTORE/var/cache/gogocarto:$GOGOCARTO_DIR/var/cache:rw
  49. - $SERVICE_DATASTORE/var/lib/gogocarto/sessions:$GOGOCARTO_DIR/var/sessions:rw
  50. - $SERVICE_DATASTORE/var/log/gogocarto:$GOGOCARTO_DIR/var/log:rw
  51. ## Required to give PHP access to this dir
  52. - $upload_dir:$GOGOCARTO_DIR/web/uploads:rw
  53. "