This commit is contained in:
oliver committed 2026-10-14 10:00:09 -03:00
1 parent d25a9a94a3
commit 722e499089
2 files changed
+28 -1

No files matched your search

+27
View File
@@ -36,9 +36,36 @@ def read_file(path):
return None
def read_env_file(path):
"""Parse a KEY=value env file (optionally quoted) into a dict."""
env = {}
try:
with open(path) as f:
for line in f:
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
if line.startswith("export "):
line = line[len("export ") :].strip()
key, value = line.split("=", 1)
value = value.strip()
if len(value) >= 2 and value[0] == value[-1] and value[0] in "\"'":
value = value[1:-1]
env[key.strip()] = value
except (FileNotFoundError, PermissionError):
pass
return env
def main():
audit = {}
# Provider / contract info (API_KEY is intentionally not exposed)
server_env = read_env_file("/etc/4server")
audit["PROVIDER"] = server_env.get("PROVIDER")
audit["CONTRACT_END"] = server_env.get("CONTRACT_END")
audit["COST"] = server_env.get("COST")
# Container identity
audit["container_id"] = os.environ.get("HOSTNAME")