s
This commit is contained in:
1 parent
d25a9a94a3
commit
722e499089
2 files changed
+28
-1
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ fi
|
|||||||
|
|
||||||
host_vars_dir="/app/host_vars"
|
host_vars_dir="/app/host_vars"
|
||||||
|
|
||||||
keys=(NEBULA_CA API_KEY HOSTNAME NEBULA_CRT NEBULA_KEY SSH_PRIVATE SSH_PUBLIC)
|
keys=(NEBULA_CA API_KEY HOSTNAME NEBULA_CRT NEBULA_KEY SSH_PRIVATE SSH_PUBLIC PROVIDER CONTRACT_END COST)
|
||||||
|
|
||||||
NEBULA_CA=$(<"$host_vars_dir/ca.crt")
|
NEBULA_CA=$(<"$host_vars_dir/ca.crt")
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,36 @@ def read_file(path):
|
|||||||
return None
|
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():
|
def main():
|
||||||
audit = {}
|
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
|
# Container identity
|
||||||
audit["container_id"] = os.environ.get("HOSTNAME")
|
audit["container_id"] = os.environ.get("HOSTNAME")
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user