mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 16:53:36 +05:00
fix(Mainsail): implement missing mainsail cfg symlinking
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user