From 5050648451850d5387dd5381addcfaa3fe93d70c Mon Sep 17 00:00:00 2001 From: clore Date: Sat, 7 Dec 2024 04:09:13 +0000 Subject: [PATCH] redirect dmidecode stderr -> stdout, openvpn config check --- lib/clore_partner.py | 4 ++-- lib/openvpn.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/clore_partner.py b/lib/clore_partner.py index 314cc5b..1e971ed 100644 --- a/lib/clore_partner.py +++ b/lib/clore_partner.py @@ -51,7 +51,7 @@ async def initialize(): return False code, stdout, stderr = await utils.async_run_command( - "dmidecode -t 2", + "dmidecode -t 2 2>&1", 20 ) if code == 0 and not stderr: @@ -60,7 +60,7 @@ async def initialize(): else: return False code, stdout, stderr = await utils.async_run_command( - "dmidecode", + "dmidecode 2>&1", 20 ) if code == 0 and not stderr: diff --git a/lib/openvpn.py b/lib/openvpn.py index 38ae6b1..f417483 100644 --- a/lib/openvpn.py +++ b/lib/openvpn.py @@ -114,8 +114,12 @@ async def clore_partner_configure(clore_partner_config): vpn_secret_key=clore_partner_config["secret"] ) - async with aiofiles.open(os.path.join(CLIENT_CONFIGS_LOCATION, PARTNER_CONFIG_NAME), mode='r') as file: - saved_config = await file.read() + saved_config='' + + config_exists = await aiofiles.os.path.exists(os.path.join(CLIENT_CONFIGS_LOCATION, PARTNER_CONFIG_NAME)) + if config_exists: + async with aiofiles.open(os.path.join(CLIENT_CONFIGS_LOCATION, PARTNER_CONFIG_NAME), mode='r') as file: + saved_config = await file.read() if saved_config != needed_openvpn_config: async with aiofiles.open(os.path.join(CLIENT_CONFIGS_LOCATION, PARTNER_CONFIG_NAME), mode='w') as file: