config: Migrate default app configuration to new conf file

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati authored and James Valleroy committed 2019-02-23 10:30:55 -05:00
1 parent 209d8e7b3a
commit a87b0ff596
2 files changed
+46 -2

No files matched your search

+24 -1
View File
@@ -23,8 +23,11 @@ Configuration helper for FreedomBox general configuration.
import argparse
import os
import augeas
from plinth import action_utils
from plinth.modules.config import DEFAULT_APP_CONF_FILE_NAME
from plinth.modules.config import (DEFAULT_APP_CONF_FILE_NAME,
FREEDOMBOX_APACHE_CONFIG)
def parse_arguments():
@@ -35,11 +38,31 @@ def parse_arguments():
'set-default-app',
help='Set the default app for this FreedomBox instance.')
set_default_app.add_argument('app', help='name of the default app')
subparsers.add_parser(
'reset-default-app',
help='Reset the default app configuraton in freedombox.conf')
subparsers.required = True
return parser.parse_args()
def subcommand_reset_default_app(_):
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
aug.set('/augeas/load/Httpd/incl[last() + 1]', FREEDOMBOX_APACHE_CONFIG)
aug.load()
aug.defvar('conf', '/files' + FREEDOMBOX_APACHE_CONFIG)
for match in aug.match('/files' + FREEDOMBOX_APACHE_CONFIG +
'/directive["RedirectMatch"]'):
if aug.get(match + "/arg[1]") == '''"^/$"''':
aug.set(match + "/arg[2]", '"/{}"'.format('plinth'))
aug.save()
def subcommand_set_default_app(arguments):
"""Set the default app for this FreedomBox."""
conf_file_path = os.path.join('/etc/apache2/conf-available',