#!/bin/bash ## Should be executable N time in a row with same result. . lib/common set -e LOGS=/var/log/opensem 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=( "$LOGS" ) 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 rotated_count=$(relation-get rotated-count 2>/dev/null) || true rotated_count=${rotated_count:-52} ## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME" file_put "$DST" <