mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
Diaspora: Make config changes using augeas
This commit is contained in:
parent
b109507e0a
commit
d1b8d8e811
@ -65,21 +65,20 @@ def set_domain_name(domain_name):
|
|||||||
# {'url': domain_name})
|
# {'url': domain_name})
|
||||||
# Manually changing the domain name in the conf files.
|
# Manually changing the domain name in the conf files.
|
||||||
conf_file = '/etc/diaspora.conf'
|
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 +
|
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/lens', 'Httpd.lns')
|
||||||
aug.set('/augeas/load/Httpd/incl[last() + 1]',
|
aug.set('/augeas/load/Httpd/incl[last() + 1]',
|
||||||
'/etc/apache2/conf-available/*')
|
'/etc/apache2/conf-available/*')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user