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.
 
 

93 lines
2.3 KiB

#!/bin/bash
## Should be executable N time in a row with same result.
set -e
uid_gid=$(docker_get_uid_gid "$SERVICE_NAME" "rsync" "rsync")
uid=${uid_gid%%$'\n'*}
gid=${uid_gid#*$'\n'}
LOGS=/var/log/rsync
mkdir -p "$SERVICE_DATASTORE/$LOGS"
touch "$SERVICE_DATASTORE/$LOGS/ssh-cmd-validate.log"
chown -v "$uid" "$SERVICE_DATASTORE/$LOGS" "$SERVICE_DATASTORE/$LOGS/ssh-cmd-validate.log"
chmod -v 0640 "$SERVICE_DATASTORE/$LOGS/ssh-cmd-validate.log"
touch "$SERVICE_DATASTORE/$LOGS/ssh-admin-cmd-validate.log"
chown -v "$uid:$gid" "$SERVICE_DATASTORE/$LOGS" "$SERVICE_DATASTORE/$LOGS/ssh-admin-cmd-validate.log"
chmod -v 0660 "$SERVICE_DATASTORE/$LOGS/ssh-admin-cmd-validate.log"
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" <<EOF
/var/log/docker/$SERVICE_NAME/ssh-cmd-validate.log
{
weekly
missingok
dateext
dateyesterday
dateformat _%Y-%m-%d
extension .log
rotate $rotated_count
compress
delaycompress
notifempty
## XXXvlab: see https://github.com/logrotate/logrotate/issues/650
## for the syntax headache (and it relies on correct version of logrotate)
create 0640 :$uid :0
sharedscripts
}
/var/log/docker/$SERVICE_NAME/ssh-admin-cmd-validate.log
{
weekly
missingok
dateext
dateyesterday
dateformat _%Y-%m-%d
extension .log
rotate $rotated_count
compress
delaycompress
notifempty
## XXXvlab: see https://github.com/logrotate/logrotate/issues/650
## for the syntax headache (and it relies on correct version of logrotate)
create 0660 :$uid :$gid
sharedscripts
}
/var/log/docker/$SERVICE_NAME/target_*_rsync.log
{
weekly
missingok
dateext
dateyesterday
dateformat _%Y-%m-%d
extension .log
rotate $rotated_count
compress
delaycompress
notifempty
create 0640 :0 :0
sharedscripts
}
EOF
config-add "\
services:
$MASTER_TARGET_SERVICE_NAME:
volumes:
- $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
- $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
$MASTER_BASE_SERVICE_NAME:
volumes:
- $SERVICE_DATASTORE$LOGS:$LOGS:rw
"