From e17972e7983e070d8dd780581cbb82e310bb45d4 Mon Sep 17 00:00:00 2001
From: Steven Murray <Steven.Murray@cern.ch>
Date: Mon, 22 May 2017 16:15:53 +0200
Subject: [PATCH] cta/CTA#112 Package 3 cta-taped files into the RPM

Packaged cta-frontend.logrotate and cta-taped.logrotate
---
 cta.spec.in                          | 14 +++++++++-----
 tapeserver/CMakeLists.txt            |  3 ++-
 xroot_plugins/CMakeLists.txt         |  1 +
 xroot_plugins/cta-frontend.logrotate | 10 ++++++++++
 4 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 xroot_plugins/cta-frontend.logrotate

diff --git a/cta.spec.in b/cta.spec.in
index 72fda50434..600d7ad6e2 100644
--- a/cta.spec.in
+++ b/cta.spec.in
@@ -119,8 +119,9 @@ The xroot plugin
 %package -n cta-taped
 Summary: CERN Tape Archive: tape daemon
 Group: Application/CTA
-requires: cta-lib
-requires(pre): /usr/bin/getent, /usr/sbin/groupadd, /usr/sbin/useradd
+Requires: logrotate
+Requires: cta-lib
+Requires(pre): /usr/bin/getent, /usr/sbin/groupadd, /usr/sbin/useradd
 %description -n cta-taped
 CERN Tape Archive:
 The tape server daemon
@@ -129,6 +130,7 @@ The tape server daemon
 /usr/bin/getent passwd cta || /usr/sbin/useradd -s /bin/nologin -c "CTA system account" -g cta cta
 %files -n cta-taped
 %defattr(-,root,root)
+%attr(0644,root,root) %config(noreplace) /etc/logrotate.d/cta-taped
 %attr(0755,root,root) %{_bindir}/cta-taped
 %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta.conf.example
 %attr(0644,root,bin) %doc /usr/share/man/man1/cta-taped.1cta.gz
@@ -136,9 +138,10 @@ The tape server daemon
 %package -n cta-frontend
 Summary: CERN Tape Archive: Xrootd plugin
 Group: Application/CTA
-requires: cta-lib
-requires: xrootd-server
-requires(pre): /usr/bin/getent, /usr/sbin/groupadd, /usr/sbin/useradd
+Requires: logrotate
+Requires: cta-lib
+Requires: xrootd-server
+Requires(pre): /usr/bin/getent, /usr/sbin/groupadd, /usr/sbin/useradd
 %description -n cta-frontend
 CERN Tape Archive:
 The xroot plugin
@@ -147,6 +150,7 @@ The xroot plugin
 /usr/bin/getent passwd cta || /usr/sbin/useradd -s /bin/nologin -c "CTA system account" -g cta cta
 %files -n cta-frontend
 %defattr(-,root,root)
+%attr(0644,root,root) %config(noreplace) /etc/logrotate.d/cta-frontend
 %attr(0755,root,root) %{_libdir}/libXrdCtaOfs.so
 %attr(0644,root,root) %config(noreplace) /etc/xrootd/xrootd-cta.cfg
 %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cta/cta-frontend.conf
diff --git a/tapeserver/CMakeLists.txt b/tapeserver/CMakeLists.txt
index bb76dba89c..970453e151 100644
--- a/tapeserver/CMakeLists.txt
+++ b/tapeserver/CMakeLists.txt
@@ -13,7 +13,8 @@ add_executable (cta-taped cta-taped.cpp)
 target_link_libraries(cta-taped
   ctatapedaemon ctacommon protobuf)
 install (TARGETS cta-taped DESTINATION usr/bin)
-install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-taped.1cta DESTINATION /usr/share/man/man1)
+install (FILES cta-taped.1cta DESTINATION /usr/share/man/man1)
+install (FILES cta-taped.logrotate DESTINATION /etc/logrotate.d RENAME cta-taped)
 
 # CTA's cta-taped system tests.
 add_library(cta-tapedSystemTests SHARED
diff --git a/xroot_plugins/CMakeLists.txt b/xroot_plugins/CMakeLists.txt
index 2532fcb735..386b5a3d35 100644
--- a/xroot_plugins/CMakeLists.txt
+++ b/xroot_plugins/CMakeLists.txt
@@ -28,6 +28,7 @@ target_link_libraries (XrdCtaOfs ctacatalogue ctaeosmessages ctascheduler ctacom
 INSTALL (TARGETS XrdCtaOfs DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
 INSTALL (FILES xrootd-cta.cfg DESTINATION /etc/xrootd/)
 INSTALL (FILES cta-frontend.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/cta)
+install (FILES cta-frontend.logrotate DESTINATION /etc/logrotate.d RENAME cta-frontend)
 
 set (OPAQUE_QUERY_CMD_SRC_FILES
   CmdLineTool.cpp
diff --git a/xroot_plugins/cta-frontend.logrotate b/xroot_plugins/cta-frontend.logrotate
new file mode 100644
index 0000000000..471d0ec355
--- /dev/null
+++ b/xroot_plugins/cta-frontend.logrotate
@@ -0,0 +1,10 @@
+/var/log/cta/cta-frontend*.log {
+    compress
+    daily
+    missingok
+    rotate 500
+    delaycompress
+    postrotate
+        /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
+    endscript
+}
-- 
GitLab