39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
import os
|
|
|
|
if __name__ == '__main__':
|
|
|
|
service_name = input("Enter the service name (e.g. cloud): ").strip().lower()
|
|
url = input("Enter the URL (e.g. cloud.stuve.uni-ulm.de): ").strip().lower()
|
|
forward_url = input("Enter the forward URL with port (e.g. http://faline.stuve.uni-ulm.de:80): ").strip().lower()
|
|
|
|
config = f'''
|
|
http:
|
|
routers:
|
|
{service_name}_router_https:
|
|
rule: "Host(`{url}`)"
|
|
service: {service_name}
|
|
entryPoints:
|
|
- "websecure"
|
|
tls:
|
|
certResolver: "http_resolver"
|
|
|
|
services:
|
|
{service_name}:
|
|
loadBalancer:
|
|
servers:
|
|
- url: "{forward_url}"
|
|
'''
|
|
|
|
# check if the file already exists
|
|
if os.path.exists(f'{service_name}.yml'):
|
|
print(f'Configuration for {service_name} already exists.')
|
|
overwrite = input(f'Overwrite {service_name}.yml? (y/n): ').strip().lower() == 'y'
|
|
|
|
if not overwrite:
|
|
exit(0)
|
|
|
|
# write the configuration to a file
|
|
with open(f'{service_name}.yml', 'w') as f:
|
|
f.write(config)
|
|
print(f'Configuration for {service_name} written to {service_name}.yml') |