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.

67 lines
1.4 KiB

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