From 57029bb1a1ec3194b07113bbe8649949155d41d4 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Mon, 3 Jun 2019 16:56:51 +0300 Subject: [PATCH] MXS-2445 Add logrotate config file --- CMakeLists.txt | 1 + cmake/init_scripts.cmake | 2 ++ etc/logrotate.d/maxscale_logrotate | 11 +++++++++++ etc/postinst.in | 6 ++++++ etc/postrm.in | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 etc/logrotate.d/maxscale_logrotate diff --git a/CMakeLists.txt b/CMakeLists.txt index 3017ba4df..a4288ece3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,6 +233,7 @@ install_file(${CMAKE_SOURCE_DIR}/LICENSE-THIRDPARTY.TXT core) install_file(etc/lsyncd_example.conf core) install_manual(Documentation/maxscale.1 1 core) install_file(${CMAKE_SOURCE_DIR}/server/maxscale_binlogserver_template.cnf core) +install_file(${CMAKE_SOURCE_DIR}/etc/logrotate.d/maxscale_logrotate core) # For devel package, these files are put to the base folder install_header(${CMAKE_SOURCE_DIR}/COPYRIGHT devel) diff --git a/cmake/init_scripts.cmake b/cmake/init_scripts.cmake index 1ab095eba..01f526e1a 100644 --- a/cmake/init_scripts.cmake +++ b/cmake/init_scripts.cmake @@ -50,8 +50,10 @@ else() install(FILES ${CMAKE_BINARY_DIR}/maxscale.conf DESTINATION /etc/ld.so.conf.d COMPONENT core) install(FILES ${CMAKE_BINARY_DIR}/maxscale.service DESTINATION /usr/lib/systemd/system COMPONENT core) install(FILES ${CMAKE_BINARY_DIR}/upstart/maxscale.conf DESTINATION /etc/init/) + install(FILES ${CMAKE_SOURCE_DIR}/etc/logrotate.d/maxscale_logrotate DESTINATION /etc/logrotate.d/) message(STATUS "Installing maxscale.conf to: /etc/ld.so.conf.d") message(STATUS "Installing startup scripts to: /etc/init.d") message(STATUS "Installing systemd service files to: /usr/lib/systemd/system") message(STATUS "Installing upstart files to: /etc/init/") + message(STATUS "Installing logrotate config to: /etc/logrotate.d/maxscale_logrotate") endif() diff --git a/etc/logrotate.d/maxscale_logrotate b/etc/logrotate.d/maxscale_logrotate new file mode 100644 index 000000000..360b9006d --- /dev/null +++ b/etc/logrotate.d/maxscale_logrotate @@ -0,0 +1,11 @@ +/var/log/maxscale/maxscale.log { +monthly +rotate 5 +missingok +nocompress +sharedscripts +postrotate +kill -USR1 `cat /var/run/maxscale/maxscale.pid` +endscript +} + diff --git a/etc/postinst.in b/etc/postinst.in index 592fcf0ce..17ab823d3 100755 --- a/etc/postinst.in +++ b/etc/postinst.in @@ -73,6 +73,12 @@ then cp @MAXSCALE_CONFDIR@/maxscale.cnf.template @MAXSCALE_CONFDIR@/maxscale.cnf fi +# If no logrotate config file is found, create one +if [ ! -f "etc/logrotate.d/maxscale_logrotate" ] +then + cp @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/maxscale_logrotate /etc/logrotate.d/maxscale_logrotate +fi + # This will allow us to install the Perl scripts as executable files # without adding the Perl dependencies find @CMAKE_INSTALL_PREFIX@/@MAXSCALE_SHAREDIR@/plugins/nagios -name '*.pl' -exec chmod ug+x {} \; diff --git a/etc/postrm.in b/etc/postrm.in index 4a10dcaf3..1e31d788f 100755 --- a/etc/postrm.in +++ b/etc/postrm.in @@ -22,4 +22,9 @@ then then rm /lib/systemd/system/maxscale.service fi + + if [ -f /etc/logrotate.d/maxscale_logrotate ] + then + rm /etc/logrotate.d/maxscale_logrotate + fi fi