chg: dev: [opensem] move php dir creation from `publish-dir to php-fpm`
This commit is contained in:
66
opensem/hooks/php_fpm-relation-joined
Executable file
66
opensem/hooks/php_fpm-relation-joined
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
. lib/common
|
||||
|
||||
set -e
|
||||
|
||||
uid_gid=$(get_service_base_image_dir_uid_gid "$MASTER_TARGET_SERVICE_NAME" /var/www/html) || {
|
||||
err "Could not determine uid:gid for $MASTER_TARGET_SERVICE_NAME of dir /var/www/html"
|
||||
exit 1
|
||||
}
|
||||
gid="${uid_gid#* }"
|
||||
|
||||
dirs=(
|
||||
/var/cache/opensem/bootstrap
|
||||
/var/cache/opensem/framework
|
||||
/var/cache/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
|
||||
|
||||
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:
|
||||
- $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/cache/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
|
||||
EOF
|
||||
Reference in New Issue
Block a user