fix(Mainsail): implement missing mainsail cfg symlinking

Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
dw-0
2023-12-22 21:41:15 +01:00
parent 12bd8eb799
commit 22e8e314db
2 changed files with 48 additions and 10 deletions

View File

@@ -14,7 +14,12 @@ import subprocess
from pathlib import Path
from zipfile import ZipFile
from kiauh.utils import NGINX_SITES_AVAILABLE, NGINX_SITES_ENABLED, MODULE_PATH, NGINX_CONFD
from kiauh.utils import (
NGINX_SITES_AVAILABLE,
NGINX_SITES_ENABLED,
MODULE_PATH,
NGINX_CONFD,
)
from kiauh.utils.logger import Logger
@@ -48,6 +53,17 @@ def create_directory(_dir: Path) -> None:
raise
def create_symlink(source: Path, target: Path, sudo=False) -> None:
try:
cmd = ["ln", "-sf", source, target]
if sudo:
cmd.insert(0, "sudo")
subprocess.run(cmd, stderr=subprocess.PIPE, check=True)
except subprocess.CalledProcessError as e:
Logger.print_error(f"Failed to create symlink: {e}")
raise
def remove_file(file_path: Path, sudo=False) -> None:
try:
command = f"{'sudo ' if sudo else ''}rm -f {file_path}"
@@ -57,6 +73,7 @@ def remove_file(file_path: Path, sudo=False) -> None:
Logger.print_error(log)
raise
def unzip(file: str, target_dir: str) -> None:
"""
Helper function to unzip a zip-archive into a target directory |