/opt/osstech/var/lib/tomcat/openam/openam/stats/*
/opt/osstech/var/lib/tomcat/openam/openam/debug/*
{
  rotate 100
  daily
  su tomcat tomcat
  notifempty
  missingok
  copytruncate
  olddir old
  ## Old logrotate's createolddir is broken and insecure.
  ## (e.g., logrotate 3.8.6-12 on RHEL 7)
  ## https://github.com/logrotate/logrotate/pull/59
  ## https://github.com/logrotate/logrotate/commit/3c76f48efa0d9d448528af3e40f757654458978c
  ## https://github.com/logrotate/logrotate/pull/114
  #createolddir 0750 tomcat tomcat
  dateext
  compress
  nodelaycompress
  sharedscripts
  postrotate
    /sbin/runuser --shell /bin/sh --login -- tomcat -c '
      old_days=100
      ## Audit logs: CSV logs can NOT be rotated by an external program,
      ## thus this script only compresses and expires the old logs.
      old_audit_files="/opt/osstech/var/lib/tomcat/openam/openam/log/*.csv-*"
      ## OpenDJ logs: Internal log rotation is enabled by default,
      ## thus this script only compresses and expires the old logs.
      old_opendj_files="/opt/osstech/var/lib/tomcat/openam/opends/logs/*.*Z"
      for old_files in "$old_audit_files" "$old_opendj_files"; do
	old_dir="${old_files%/*}/old"
	mkdir -p -m 0750 "${old_dir}"
	for old_file in $old_files; do
	  [ -f "${old_file}" ] || continue
	  mv "${old_file}" "${old_dir}/" || continue
	  gzip "${old_dir}/${old_file##*/}" || continue
	done
	find "${old_dir}" -name "*.gz" -mtime +"${old_days}" -exec rm {} +
      done
    '
  endscript
}
## vim: filetype=conf:
