[Erp5-report] r45631 luke - /erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Apr 22 11:31:58 CEST 2011


Author: luke
Date: Fri Apr 22 11:31:58 2011
New Revision: 45631

URL: http://svn.erp5.org?rev=45631&view=rev
Log:
 - install logrotate and setup its cron entry
 - put cron configuration in etc directory

Modified:
    erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/__init__.py

Modified: erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/__init__.py?rev=45631&r1=45630&r2=45631&view=diff
==============================================================================
--- erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/__init__.py [utf8] (original)
+++ erp5/trunk/utils/slapos.recipe.erp5/src/slapos/recipe/erp5/__init__.py [utf8] Fri Apr 22 11:31:58 2011
@@ -54,6 +54,7 @@ class Recipe(BaseSlapRecipe):
     self.requirements, self.ws = self.egg.working_set([__name__])
     # self.cron_d is a directory, where cron jobs can be registered
     self.cron_d = self.installCrond()
+    self.logrotate_d = self.installLogrotate()
     ca_conf = self.installCertificateAuthority()
     memcached_conf = self.installMemcached(ip=self.getLocalIPv4Address(),
         port=11000)
@@ -88,6 +89,19 @@ class Recipe(BaseSlapRecipe):
     ))
     return self.path_list
 
+  def installLogrotate(self):
+    """Installs logortate main configuration file and registers its to cron"""
+    logrotate_d = os.path.abspath(os.path.join(self.etc_directory,
+      'logrotate.d'))
+    self._createDirectory(logrotate_d)
+    logrotate_conf = self.createConfigurationFile("logrotate.conf",
+        "include %s" % logrotate_d)
+    logrotate_cron = os.path.join(self.cron_d, 'logrotate')
+    state_file = os.path.join(self.data_root_directory, 'logrotate.status')
+    open(logrotate_cron, 'w').write('0 0 * * * %s -s %s %s' % (self.options['logrotate_binary'], state_file, logrotate_conf))
+    self.path_list.extend([logrotate_d, logrotate_conf, logrotate_cron])
+    return logrotate_d
+
   def linkBinary(self):
     """Links binaries to instance's bin directory for easier exposal"""
     for linkline in self.options.get('link_binary_list', '').splitlines():
@@ -234,8 +248,8 @@ class Recipe(BaseSlapRecipe):
 
   def installCrond(self):
     timestamps = self.createDataDirectory('cronstamps')
-    cron_d = os.path.join(self.var_directory, 'cron.d')
-    crontabs = os.path.join(self.var_directory, 'crontabs')
+    cron_d = os.path.join(self.etc_directory, 'cron.d')
+    crontabs = os.path.join(self.etc_directory, 'crontabs')
     logfile = os.path.join(self.log_directory, 'cron.log')
     self._createDirectory(cron_d)
     self._createDirectory(crontabs)



More information about the Erp5-report mailing list