container detection implemented
This commit is contained in:
@@ -12,12 +12,16 @@ def configure_server(db: Session = Depends(get_db)):
|
||||
# Generate to a temporary location or standard location
|
||||
# As per plan, we behave like srvconf
|
||||
output_path = "/etc/openvpn/server.conf"
|
||||
# Since running locally for dev, maybe output to staging
|
||||
import os
|
||||
if not os.path.exists("/etc/openvpn"):
|
||||
# For local dev safety, don't try to write to /etc/openvpn if not root or not existing
|
||||
output_path = "staging/server.conf"
|
||||
os.makedirs("staging", exist_ok=True)
|
||||
|
||||
# Ensure we can write to /etc/openvpn
|
||||
if not os.path.exists(os.path.dirname(output_path)) or not os.access(os.path.dirname(output_path), os.W_OK):
|
||||
# For local dev or non-root host, use staging
|
||||
output_path = "staging/server.conf"
|
||||
os.makedirs("staging", exist_ok=True)
|
||||
logger.info(f"[SERVER] /etc/openvpn not writable, using staging path: {output_path}")
|
||||
else:
|
||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
||||
|
||||
|
||||
content = generator.generate_server_config(db, output_path=output_path)
|
||||
return {"message": "Server configuration generated", "path": output_path}
|
||||
|
||||
Reference in New Issue
Block a user