From 2ac315cbe23e2127d8c453c74fe19ffbbb18017c Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 27 Mar 2018 12:02:20 +0800 Subject: [PATCH] Add default logrotate configuration for gocons Add logrotate conf for the console log files and log of goconserver. --- xCAT-server/debian/dirs | 1 + xCAT-server/debian/install | 1 + xCAT-server/debian/rules | 1 + xCAT-server/lib/xcat/plugins/goconserver.pm | 4 ++++ xCAT-server/share/xcat/conf/goconslogrotate | 9 +++++++++ xCAT-server/xCAT-server.spec | 2 ++ 6 files changed, 18 insertions(+) create mode 100644 xCAT-server/share/xcat/conf/goconslogrotate diff --git a/xCAT-server/debian/dirs b/xCAT-server/debian/dirs index 04341946a..16b86efce 100644 --- a/xCAT-server/debian/dirs +++ b/xCAT-server/debian/dirs @@ -8,6 +8,7 @@ opt/xcat/share/xcat/netboot opt/xcat/share/xcat/templates opt/xcat/share/xcat/ca opt/xcat/share/xcat/scripts +opt/xcat/share/xcat/conf opt/xcat/share/xcat/tools opt/xcat/share/xcat/rollupdate opt/xcat/share/xcat/installp_bundles diff --git a/xCAT-server/debian/install b/xCAT-server/debian/install index ec21c731e..12d7fffa8 100644 --- a/xCAT-server/debian/install +++ b/xCAT-server/debian/install @@ -6,6 +6,7 @@ share/xcat/mypostscript/* opt/xcat/share/xcat/mypostscript/ share/xcat/ca/* opt/xcat/share/xcat/ca share/xcat/scripts/* opt/xcat/share/xcat/scripts +share/xcat/conf/* opt/xcat/share/xcat/conf share/xcat/tools/* opt/xcat/share/xcat/tools share/xcat/rollupdate/* opt/xcat/share/xcat/rollupdate share/xcat/installp_bundles/* opt/xcat/share/xcat/installp_bundles diff --git a/xCAT-server/debian/rules b/xCAT-server/debian/rules index 72d780fc1..e9d3948ba 100755 --- a/xCAT-server/debian/rules +++ b/xCAT-server/debian/rules @@ -47,6 +47,7 @@ binary-arch: chmod 755 $(rootdir)/bin/* chmod 755 $(rootdir)/sbin/* chmod 644 $(rootdir)/share/xcat/ca/* + chmod 644 $(rootdir)/share/xcat/conf/* chmod 755 $(rootdir)/share/xcat/cons/* chmod 755 $(rootdir)/share/xcat/ib/* chmod 755 $(rootdir)/share/xcat/ib/netboot/sles/* diff --git a/xCAT-server/lib/xcat/plugins/goconserver.pm b/xCAT-server/lib/xcat/plugins/goconserver.pm index 52325db86..226d819f9 100644 --- a/xCAT-server/lib/xcat/plugins/goconserver.pm +++ b/xCAT-server/lib/xcat/plugins/goconserver.pm @@ -6,6 +6,7 @@ BEGIN { } use lib "$::XCATROOT/lib/perl"; use strict; +use File::Copy; use xCAT::Table; use xCAT::Utils; use xCAT::TableUtils; @@ -165,6 +166,9 @@ sub start_goconserver { xCAT::MsgUtils->error_message("Failed to create configuration file for goconserver.", $::callback); return 1; } + if (!copy($::XCATROOT."/share/xcat/conf/goconslogrotate", "/etc/logrotate.d/goconserver")) { + xCAT::MsgUtils->warn_message("Failed to create logrotate configuration for goconserver.", $::callback); + } } $ret = xCAT::Goconserver::restart_service(); if ($ret) { diff --git a/xCAT-server/share/xcat/conf/goconslogrotate b/xCAT-server/share/xcat/conf/goconslogrotate new file mode 100644 index 000000000..afcbd7fe7 --- /dev/null +++ b/xCAT-server/share/xcat/conf/goconslogrotate @@ -0,0 +1,9 @@ +/var/log/consoles/*.log +/var/log/goconserver/server.log +{ + missingok + sharedscripts + postrotate + kill -HUP `systemctl show -p MainPID goconserver.service 2> /dev/null |awk -F= '{print $2}'` 2> /dev/null || true + endscript +} \ No newline at end of file diff --git a/xCAT-server/xCAT-server.spec b/xCAT-server/xCAT-server.spec index 4f9c35be3..fd2ebd942 100644 --- a/xCAT-server/xCAT-server.spec +++ b/xCAT-server/xCAT-server.spec @@ -100,6 +100,7 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/scripts mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/samples mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/cons +mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/conf mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/rollupdate mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/installp_bundles mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/image_data @@ -145,6 +146,7 @@ chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/xcat/ca/* cp share/xcat/mypostscript/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/mypostscript cp share/xcat/scripts/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/scripts +cp share/xcat/conf/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/conf cp share/xcat/samples/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/samples cp -r share/xcat/tools/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/tools cp -r share/xcat/hamn/* $RPM_BUILD_ROOT/%{prefix}/share/xcat/hamn