]> git.parisson.com Git - mezzo.git/commitdiff
Install : log dir creation for cron
authorEmilie <zawadzki@ircam.fr>
Fri, 14 Oct 2016 17:08:39 +0000 (19:08 +0200)
committerEmilie <zawadzki@ircam.fr>
Fri, 14 Oct 2016 17:08:39 +0000 (19:08 +0200)
install.py

index 78d7b91dfdae11119afc342d4979bc0c0fef4bb9..5955a4bd0e811e73a521386dfe89f513e6fa17c8 100755 (executable)
@@ -13,6 +13,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 import os
 import argparse
 import platform
+from pwd import getpwnam
+from grp import getgrnam
 
 sysvinit_script = """#!/bin/sh
 ### BEGIN INIT INFO
@@ -156,8 +158,12 @@ class DockerCompositionInstaller(object):
     def install_cron(self):
         # version with migration
         # without migration
+        log_path = "/var/log/"+ self.name
+        if not os.path.exists(log_path) :
+            os.makedirs(log_path, 0o755)
+            os.chown(log_path, getpwnam(self.user).pw_uid, getgrnam(self.user).gr_gid)
         path = "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin\n"
-        command = "cd /srv/ircam-www && ./scripts/push.sh >> /var/log/cri/ircam-www-push.log 2>&1 \n"
+        command = "cd /srv/ircam-www && ./scripts/push.sh >> /var/log/"+ self.name +"/ircam-www-push.log 2>&1 \n"
         rule = self.cron_rule % (self.user, command)
         f = open('/etc/cron.d/' + self.name, 'w')
         f.write(path + rule)