Diaspora: Make config changes using augeas

This commit is contained in:
Joseph Nuthalpati 2017-07-18 17:39:57 +05:30 committed by James Valleroy
parent b109507e0a
commit d1b8d8e811
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -65,21 +65,20 @@ def set_domain_name(domain_name):
# {'url': domain_name})
# Manually changing the domain name in the conf files.
conf_file = '/etc/diaspora.conf'
with open(conf_file, 'r') as conf:
env_vars = conf.read().splitlines()
for index, line in enumerate(env_vars):
if "SERVER_NAME" in line:
env_vars[index] = "export SERVER_NAME={}".format(domain_name)
if "ENVIRONMENT_URL" in line:
env_vars[index] = "export ENVIRONMENT_URL=http://{}:3000".format(
domain_name)
with open(conf_file, 'w') as conf:
conf.write("\n".join(env_vars))
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
augeas.Augeas.NO_MODL_AUTOLOAD)
# shell-script config file lens
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
aug.set('/augeas/load/Shellvars/incl[last() + 1]', conf_file)
aug.load()
aug.set('/files/etc/diaspora.conf/SERVERNAME', '"{}"'.format(domain_name))
aug.set('/files/etc/diaspora.conf/ENVIRONMENT_URL',
'http://{}:3000'.format(domain_name))
aug.save()
# lens to edit apache2 config files
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
aug.set('/augeas/load/Httpd/incl[last() + 1]',
'/etc/apache2/conf-available/*')