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.

55 lines
1.3 KiB

  1. #!/bin/bash
  2. ## Should be executable N time in a row with same result.
  3. . lib/common
  4. set -e
  5. uid_gid=$(docker_get_uid_gid "$MASTER_BASE_SERVICE_NAME" "odoo" "odoo")
  6. uid=${uid_gid%%$'\n'*}
  7. gid=${uid_gid#*$'\n'}
  8. LOGS=/var/log/odoo
  9. mkdir -p "$SERVICE_DATASTORE/$LOGS"
  10. chown -R "$odoo_uid" "$SERVICE_DATASTORE/$LOGS"
  11. rotated_count=$(relation-get rotated-count 2>/dev/null) || true
  12. rotated_count=${rotated_count:-52}
  13. ## No postrotate script as odoo uses a WatchedFileHandler log that
  14. ## close and reopen log file if it changes.
  15. ## XXXvlab: a lot of this intelligence should be moved away into ``logrotate`` charm
  16. DST="$CONFIGSTORE/$TARGET_SERVICE_NAME/etc/logrotate.d/$SERVICE_NAME"
  17. file_put "$DST" <<EOF
  18. /var/log/docker/$SERVICE_NAME/odoo.log
  19. {
  20. weekly
  21. missingok
  22. dateext
  23. dateyesterday
  24. dateformat _%Y-%m-%d
  25. extension .log
  26. rotate $rotated_count
  27. compress
  28. delaycompress
  29. notifempty
  30. create 0640 :$uid :$gid
  31. sharedscripts
  32. }
  33. EOF
  34. config-add "\
  35. services:
  36. $MASTER_TARGET_SERVICE_NAME:
  37. volumes:
  38. - $DST:/etc/logrotate.d/docker-${SERVICE_NAME}:ro
  39. - $SERVICE_DATASTORE$LOGS:/var/log/docker/$SERVICE_NAME:rw
  40. $MASTER_BASE_SERVICE_NAME:
  41. volumes:
  42. - $SERVICE_DATASTORE$LOGS:$LOGS:rw
  43. command:
  44. - \"--logfile=$LOGS/odoo.log\"
  45. "