forked from moritz/alakazam
fix exchange_domains
This commit is contained in:
20
alakazam.py
20
alakazam.py
@ -334,17 +334,20 @@ def uncomment(keys, path, match_all=False):
|
||||
file.write(line)
|
||||
|
||||
|
||||
def exchange_domains(instance_config, apps, path):
|
||||
for app in apps:
|
||||
domain = instance_config[app]['app_domain']
|
||||
insert_domains(path, app, domain)
|
||||
def exchange_domains(instance, instance_config, path):
|
||||
for app in instance_config:
|
||||
old_app_domain = f'{app}.example.com'
|
||||
new_app_domain = instance_config[app]['app_domain']
|
||||
replace_domains(path, old_app_domain, new_app_domain)
|
||||
replace_domains(path, 'example.com', instance)
|
||||
|
||||
|
||||
def insert_domains(path, app, domain):
|
||||
logging.debug(f'replace all {app}.example.com with {domain} in {path}')
|
||||
|
||||
def replace_domains(path, old_domain, new_domain):
|
||||
logging.debug(f'replace all {old_domain} with {new_domain} in {path}')
|
||||
with open(path, "r") as file:
|
||||
content = file.read()
|
||||
content = content.replace(f"{app}.example.com", domain)
|
||||
content = content.replace(f"{old_domain}", new_domain)
|
||||
with open(path, "w") as file:
|
||||
file.write(content)
|
||||
|
||||
@ -412,7 +415,8 @@ def config(apps):
|
||||
new_app(app, domain, server)
|
||||
logging.info(f'set configs for {app} at {instance}')
|
||||
update_configs(path, app_config)
|
||||
exchange_domains(instance_config, instance_config.keys(), path)
|
||||
exchange_domains(instance, instance_config, path)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('-a', '--apps', multiple=True)
|
||||
|
||||
Reference in New Issue
Block a user