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.

83 lines
1.7 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/ssh-admin-cmd-validate.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 660 $uid
  43. sharedscripts
  44. }
  45. /var/log/docker/$SERVICE_NAME/target_*_rsync.log
  46. {
  47. weekly
  48. missingok
  49. dateext
  50. dateyesterday
  51. dateformat _%Y-%m-%d
  52. extension .log
  53. rotate $rotated_count
  54. compress
  55. delaycompress
  56. notifempty
  57. create 640
  58. sharedscripts
  59. }
  60. EOF
  61. config-add "\
  62. services:
  63. $MASTER_TARGET_SERVICE_NAME:
  64. volumes:
  65. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  66. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  67. $MASTER_BASE_SERVICE_NAME:
  68. volumes:
  69. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  70. "