feat: Update DNS handling and add port parameter for subdomain management
This commit is contained in:
@@ -63,6 +63,8 @@ Wichtige Ports:
|
|||||||
- Gitea SSH: 2222
|
- Gitea SSH: 2222
|
||||||
- Website Upstream: 4999
|
- Website Upstream: 4999
|
||||||
|
|
||||||
|
Hinweis: Die Website nutzt in Docker Compose intern den Service-Namen `mongodb` als MongoDB-Host. Wenn du die Website lokal mit `python` oder außerhalb des Containers startest, muss `MONGO_URI` auf einen hostzugänglichen MongoDB-Endpunkt zeigen oder `mongodb` über `27017:27017` erreichbar sein.
|
||||||
|
|
||||||
### Nginx
|
### Nginx
|
||||||
|
|
||||||
Datei: [nginx.sh](nginx.sh)
|
Datei: [nginx.sh](nginx.sh)
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ services:
|
|||||||
mem_reservation: 192m
|
mem_reservation: 192m
|
||||||
environment:
|
environment:
|
||||||
MONGO_INITDB_DATABASE: Invario_Website
|
MONGO_INITDB_DATABASE: Invario_Website
|
||||||
|
ports:
|
||||||
|
- "27017:27017"
|
||||||
volumes:
|
volumes:
|
||||||
- mongo_data:/data/db
|
- mongo_data:/data/db
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
|||||||
@@ -5,16 +5,18 @@ import requests
|
|||||||
_var = "/opt/legendary-octo-garbanzo"
|
_var = "/opt/legendary-octo-garbanzo"
|
||||||
_cmd = "run-tenant-cmd.sh"
|
_cmd = "run-tenant-cmd.sh"
|
||||||
|
|
||||||
def add_dns(name: str) -> bool:
|
def add_dns(name: str, port: int) -> bool:
|
||||||
"""
|
"""
|
||||||
Adds the subdomain to the DNS Routes
|
Adds the subdomain to the DNS Routes
|
||||||
|
|
||||||
Input:
|
Input:
|
||||||
- name (Name of the subdomain) -> String
|
- name (Name of the subdomain) -> String
|
||||||
|
- port (Port number for the subdomain) -> int
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
- bool (True if adding of the Subdomain is active)
|
- bool (True if adding of the Subdomain is active)
|
||||||
"""
|
"""
|
||||||
|
# This is a placeholder function, as the actual implementation would depend on the DNS provider and how the DNS records are managed.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clear_special(var_:str) -> str:
|
def clear_special(var_:str) -> str:
|
||||||
@@ -45,7 +47,7 @@ def clear_special(var_:str) -> str:
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def execute_script(wd_: str, file_: str, com_: str, com2_: str="None"):
|
def execute_script(wd_: str, file_: str, com_: str, com2_: str="None", com3_: str="None"):
|
||||||
"""
|
"""
|
||||||
executes a script with the option of to extra inputs
|
executes a script with the option of to extra inputs
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ def execute_script(wd_: str, file_: str, com_: str, com2_: str="None"):
|
|||||||
- file_ = working file that youre targeting -> String
|
- file_ = working file that youre targeting -> String
|
||||||
- com_ = first option -> String
|
- com_ = first option -> String
|
||||||
- com2_ = second option (Optional if needet)-> String
|
- com2_ = second option (Optional if needet)-> String
|
||||||
|
- com3_ = third option (Optional if needet)-> String
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
- ether False if failed -> bool
|
- ether False if failed -> bool
|
||||||
@@ -64,9 +67,11 @@ def execute_script(wd_: str, file_: str, com_: str, com2_: str="None"):
|
|||||||
if not update_path:
|
if not update_path:
|
||||||
return False
|
return False
|
||||||
if com2_ != "None":
|
if com2_ != "None":
|
||||||
cmd = f'bash "{update_path}" {com_}'
|
|
||||||
else:
|
|
||||||
cmd = f'bash "{update_path}" {com_} {com2_}'
|
cmd = f'bash "{update_path}" {com_} {com2_}'
|
||||||
|
elif com3_ != "None":
|
||||||
|
cmd = f'bash "{update_path}" {com_} {com2_} {com3_}'
|
||||||
|
else:
|
||||||
|
cmd = f'bash "{update_path}" {com_}'
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["bash", "-lc", cmd],
|
["bash", "-lc", cmd],
|
||||||
@@ -99,7 +104,7 @@ class instace:
|
|||||||
def __init__():
|
def __init__():
|
||||||
return list()
|
return list()
|
||||||
|
|
||||||
def new(name: str) -> bool:
|
def new(name: str):
|
||||||
"""
|
"""
|
||||||
Generates a new instance with the subdomain [name].invario.eu
|
Generates a new instance with the subdomain [name].invario.eu
|
||||||
|
|
||||||
@@ -107,10 +112,16 @@ class instace:
|
|||||||
- name -> String
|
- name -> String
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
- bool if the initiation works (True: generation worked; False: didnt work)
|
- int (Port number for the subdomain) or False if the creation of the instance didnt work
|
||||||
"""
|
"""
|
||||||
if execute_script(_var, _cmd, "add", clear_special(name)):
|
port_starter = 10002
|
||||||
return True
|
port = port_starter
|
||||||
|
for i in instace.list():
|
||||||
|
port =+ 1
|
||||||
|
|
||||||
|
if execute_script(_var, _cmd, "add", clear_special(name), port):
|
||||||
|
add_dns(name, port)
|
||||||
|
return int(port)
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user