optimized remove with open
This commit is contained in:
parent
213f772f40
commit
19d413ea97
@ -8,8 +8,7 @@ from subprocess import check_call
|
|||||||
|
|
||||||
uname: Path = Path("/tmp/.log_user")
|
uname: Path = Path("/tmp/.log_user")
|
||||||
|
|
||||||
with open(uname, "r", encoding="utf-8") as f:
|
log_name = Path(uname).read_text(encoding="utf-8")
|
||||||
log_name = f.readline()
|
|
||||||
|
|
||||||
# Folder Name "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
|
# Folder Name "tlecdewg" = Tunnel Encrypt Decrypt Wireguard
|
||||||
folder_path: Path = Path("/tmp/tlecdcwg/")
|
folder_path: Path = Path("/tmp/tlecdcwg/")
|
||||||
@ -31,5 +30,6 @@ if os.path.exists(f"{folder_path2}pbwgk.pem"):
|
|||||||
for detunnels in detl:
|
for detunnels in detl:
|
||||||
tlname2 = f"{detunnels[:-4]}.conf"
|
tlname2 = f"{detunnels[:-4]}.conf"
|
||||||
extpath = f"{folder_path}/{tlname2}"
|
extpath = f"{folder_path}/{tlname2}"
|
||||||
check_call(["openssl", "pkeyutl", "-decrypt", "-inkey", PKEYFILE, "-in", detunnels, "-out", extpath])
|
check_call(["openssl", "pkeyutl", "-decrypt", "-inkey", PKEYFILE, "-in", detunnels,
|
||||||
|
"-out", extpath])
|
||||||
shutil.chown(extpath, 1000, 1000)
|
shutil.chown(extpath, 1000, 1000)
|
||||||
|
@ -8,8 +8,7 @@ from subprocess import check_call
|
|||||||
|
|
||||||
uname: Path = Path("/tmp/.log_user")
|
uname: Path = Path("/tmp/.log_user")
|
||||||
|
|
||||||
with open(uname, "r", encoding="utf-8") as f:
|
log_name = Path(uname).read_text(encoding="utf-8")
|
||||||
log_name: str = f.readline()
|
|
||||||
|
|
||||||
keyfile: Path = Path(f"/home/{log_name}/.config/wire_py/pbwgk.pem")
|
keyfile: Path = Path(f"/home/{log_name}/.config/wire_py/pbwgk.pem")
|
||||||
folder_path: Path = Path("/tmp/tlecdcwg/")
|
folder_path: Path = Path("/tmp/tlecdcwg/")
|
||||||
|
15
start_wg.py
15
start_wg.py
@ -7,12 +7,9 @@ from subprocess import check_call
|
|||||||
|
|
||||||
path_to_file = Path(Path.home() / ".config/wire_py/settings")
|
path_to_file = Path(Path.home() / ".config/wire_py/settings")
|
||||||
|
|
||||||
with open(path_to_file, "r", encoding="utf-8") as a_con:
|
a_con = Path(path_to_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
|
a_con = a_con[7].strip()
|
||||||
# This function is for the independent autostarted of the previously selected tunnel
|
if a_con != "off":
|
||||||
lines = a_con.readlines()
|
check_call(["nmcli", "connection", "up", a_con])
|
||||||
a_con = lines[7].strip()
|
else:
|
||||||
if a_con != "off":
|
pass
|
||||||
check_call(["nmcli", "connection", "up", a_con])
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user