works
This commit is contained in:
1 parent
722e499089
commit
a915a87ed9
4 files changed
+3
-30
No files matched your search
@@ -36,36 +36,9 @@ 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")
|
||||
|
||||
|
||||
Reference in new issue
Block a user