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.

50 lines
1.1 KiB

  1. #!/bin/bash
  2. ## Should be executable N time in a row with same result.
  3. . lib/common
  4. set -e
  5. named_uid=$(docker_get_uid "$SERVICE_NAME" "named")
  6. LOGS=/var/log/bind
  7. mkdir -p "$SERVICE_DATASTORE/$LOGS"
  8. chown -R "$named_uid" "$SERVICE_DATASTORE/$LOGS"
  9. rotated_count=$(relation-get rotated-count 2>/dev/null) || true
  10. rotated_count=${rotated_count:-52}
  11. ## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm
  12. DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME"
  13. file_put "$DST" <<EOF
  14. /var/log/docker/$SERVICE_NAME/*.log
  15. {
  16. weekly
  17. missingok
  18. dateext
  19. dateyesterday
  20. dateformat _%Y-%m-%d
  21. extension .log
  22. rotate $rotated_count
  23. compress
  24. delaycompress
  25. notifempty
  26. create 640
  27. sharedscripts
  28. postrotate
  29. dc exec $SERVICE_NAME /usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
  30. endscript
  31. }
  32. EOF
  33. config-add "\
  34. services:
  35. $MASTER_TARGET_SERVICE_NAME:
  36. volumes:
  37. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  38. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  39. $MASTER_BASE_SERVICE_NAME:
  40. volumes:
  41. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  42. "