From 8e89770b5e525f8d6de7fc92bf9c421fcb72e31d Mon Sep 17 00:00:00 2001 From: VermiIIi0n <104612478+VermiIIi0n@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:50:45 +0800 Subject: [PATCH] fix logs permissions --- nginx_install/installers/core.py | 12 ++++++++++++ pyproject.toml | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nginx_install/installers/core.py b/nginx_install/installers/core.py index 5dc878a..d78b7c2 100644 --- a/nginx_install/installers/core.py +++ b/nginx_install/installers/core.py @@ -382,6 +382,18 @@ async def install(self, ctx: Context): rs = await ctx.run_cmd("systemctl enable nginx") rs.raise_for_returncode() + paths = (self.error_log_path, self.http_log_path) + for p in paths: + await aio.os.makedirs(p.parent, exist_ok=True) + if not p.exists(): + ctx.logger.debug("%s: Creating log file %s", self, p) + async with aio.open(p, "w") as f: + await f.write('') + ctx.logger.debug("%s: Chown %s to %s:%s", + self, p, self.user, self.group) + rs = await ctx.run_cmd(f"chown {self.user}:{self.group} {p}") + rs.raise_for_returncode() + ctx.logger.info("Nginx installation completed") ctx.progress.update(task, advance=1) diff --git a/pyproject.toml b/pyproject.toml index 0354585..919d5d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nginx_install" -version = "0.1.10" +version = "0.1.11" description = "Auto Nginx Installation" authors = ["VermiIIi0n "] readme = "README.md"