first commit
This commit is contained in:
88
opensem/hooks/publish_dir-relation-joined
Executable file
88
opensem/hooks/publish_dir-relation-joined
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
. lib/common
|
||||
|
||||
set -e
|
||||
|
||||
domain=$(relation-get domain) || exit 1
|
||||
url=$(relation-get url) || exit 1
|
||||
|
||||
location=$CONFIGSTORE/$BASE_SERVICE_NAME/var/www/$domain
|
||||
|
||||
php_fpm_service=$(service:traverse "$SERVICE_NAME":php-fpm) || {
|
||||
err "Could not find php-fpm service for $SERVICE_NAME"
|
||||
exit 1
|
||||
}
|
||||
|
||||
uid_gid=$(get_service_base_image_dir_uid_gid "$php_fpm_service" /var/www/html) || {
|
||||
err "Could not determine uid:gid for $php_fpm_service of dir /var/www/html"
|
||||
exit 1
|
||||
}
|
||||
gid="${uid_gid#* }"
|
||||
|
||||
dirs=(
|
||||
/var/cache/opensem/bootstrap
|
||||
/var/cache/opensem/framework
|
||||
/var/lib/opensem/views
|
||||
/var/lib/opensem/sessions
|
||||
/var/lib/opensem/app
|
||||
/var/lib/opensem/app/public
|
||||
/var/log/opensem
|
||||
)
|
||||
|
||||
|
||||
to_create=()
|
||||
volumes=""
|
||||
for d in "${dirs[@]}"; do
|
||||
fdir="${SERVICE_DATASTORE}$d"
|
||||
if [ -d "$fdir" ]; then
|
||||
find "$fdir" \! -gid "$gid" -print0 | while read-0 f; do
|
||||
chgrp -v "$gid" "$f" || return 1
|
||||
done
|
||||
find "$fdir" \! -perm -g+rwx -print0 | while read-0 f; do
|
||||
chmod -v g+rwx "$f" || return 1
|
||||
done
|
||||
else
|
||||
to_create+=("$fdir")
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "${#to_create[@]}" -gt 0 ]; then
|
||||
mkdir -p "${to_create[@]}" || return 1
|
||||
chgrp -v "${gid}" "${to_create[@]}" || return 1
|
||||
chmod g+rwx "${to_create[@]}" || return 1
|
||||
fi
|
||||
|
||||
opensem:config-set APP_URL "$url"
|
||||
|
||||
dev=$(options-get dev 2>/dev/null) || true
|
||||
if [ -n "$dev" ]; then
|
||||
# if ! [ -d "$dev" ]; then
|
||||
# err "The 'dev' option is set to '$dev' but this is not a directory."
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
OPENSEM_CODE="$dev"
|
||||
fi
|
||||
|
||||
|
||||
service:docker-compose:directive-merge "$MASTER_TARGET_SERVICE_NAME" <<EOF
|
||||
volumes:
|
||||
- $SERVICE_DATASTORE/var/lib/opensem/app/public:/var/www/$domain/storage:ro
|
||||
EOF
|
||||
|
||||
config-add "
|
||||
services:
|
||||
$php_fpm_service:
|
||||
volumes:
|
||||
# - $OPENSEM_CODE/public:/var/www/$domain:ro
|
||||
- $OPENSEM_CODE:/opt/apps/$SERVICE_NAME:ro
|
||||
- $SERVICE_DATASTORE/var/cache/opensem/bootstrap:/opt/apps/$SERVICE_NAME/bootstrap/cache:rw
|
||||
- $SERVICE_DATASTORE/var/cache/opensem/framework:/opt/apps/$SERVICE_NAME/storage/framework/cache:rw
|
||||
- $SERVICE_DATASTORE/var/lib/opensem/views:/opt/apps/$SERVICE_NAME/storage/framework/views:rw
|
||||
- $SERVICE_DATASTORE/var/lib/opensem/sessions:/opt/apps/$SERVICE_NAME/storage/framework/sessions:rw
|
||||
## Required to give PHP write access to this dir
|
||||
- $SERVICE_DATASTORE/var/lib/opensem/app:/opt/apps/$SERVICE_NAME/storage/app:rw
|
||||
- $SERVICE_DATASTORE/var/lib/opensem/app/public:/opt/apps/$SERVICE_NAME/storage/app/public:rw
|
||||
|
||||
"
|
||||
Reference in New Issue
Block a user