add_wp_app_config.py for central configuration

This commit is contained in:
2025-04-30 09:49:57 +02:00
parent 2e94a324a6
commit 08bef8fe6e
9 changed files with 92 additions and 91 deletions

View File

@ -5,13 +5,12 @@ import os
import shutil
from pathlib import Path
from subprocess import check_call
from wp_app_config import AppConfig
uname: Path = Path("/tmp/.log_user")
log_name = Path(uname).read_text(encoding="utf-8")
# Folder Name "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
folder_path: Path = Path("/tmp/tlecdcwg/")
keyfile: Path = Path(f"/home/{log_name}/.config/wire_py/pbwgk.pem")
PKEYFILE: Path = "/usr/local/etc/ssl/pwgk.pem"
@ -20,16 +19,16 @@ if not keyfile.is_file():
check_call(["openssl", "rsa", "-in", PKEYFILE, "-out", keyfile, "-outform", "PEM", "-pubout"])
shutil.chown(keyfile, 1000, 1000)
folder_path2 = f"/home/{log_name}/.config/wire_py/"
detl: list[str] = os.listdir(folder_path2)
os.chdir(folder_path2)
AppConfig.TEMP_DIR2 = f"/home/{log_name}/.config/wire_py/"
detl: list[str] = os.listdir(AppConfig.TEMP_DIR2)
os.chdir(AppConfig.TEMP_DIR2)
detl.remove("keys")
detl.remove("settings")
if os.path.exists(f"{folder_path2}pbwgk.pem"):
if os.path.exists(f"{AppConfig.TEMP_DIR2}pbwgk.pem"):
detl.remove("pbwgk.pem")
for detunnels in detl:
tlname2 = f"{detunnels[:-4]}.conf"
extpath = f"{folder_path}/{tlname2}"
extpath = f"{AppConfig.TEMP_DIR}/{tlname2}"
check_call(["openssl", "pkeyutl", "-decrypt", "-inkey", PKEYFILE, "-in", detunnels,
"-out", extpath])
shutil.chown(extpath, 1000, 1000)