From 12570cc57b91fa67f5fd4a87f48354b6ab387979 Mon Sep 17 00:00:00 2001 From: Emilie Date: Fri, 14 Oct 2016 19:08:39 +0200 Subject: [PATCH] Install : log dir creation for cron --- install.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install.py b/install.py index 78d7b91d..5955a4bd 100755 --- a/install.py +++ b/install.py @@ -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) -- 2.39.5