config: Remove Apache home page configuration from freedombox.conf

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2019-02-19 10:51:14 +05:30 committed by James Valleroy
parent bedc5ff96d
commit bd43ed515e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 5 additions and 34 deletions

View File

@ -23,11 +23,8 @@ Configuration helper for FreedomBox general configuration.
import argparse
import os
import augeas
from plinth import action_utils
from plinth.modules.config import (APACHE_HOMEPAGE_CONF_FILE_NAME,
FREEDOMBOX_APACHE_CONFIG)
from plinth.modules.config import APACHE_HOMEPAGE_CONF_FILE_NAME
def parse_arguments():
@ -39,31 +36,11 @@ def parse_arguments():
help='Set the home page for this FreedomBox instance.')
set_home_page.add_argument('homepage',
help='path to the webserver home page')
subparsers.add_parser(
'reset-home-page',
help='Reset the default app configuraton in freedombox.conf')
subparsers.required = True
return parser.parse_args()
def subcommand_reset_home_page(_):
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_home_page(arguments):
"""Set the default app for this FreedomBox."""
conf_file_path = os.path.join('/etc/apache2/conf-available',

View File

@ -4,13 +4,8 @@
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
##
## Redirect traffic on home to /plinth as part of turning the machine
## into FreedomBox server. Plinth then acts as a portal to reach all
## other services.
## Provide /freedombox as an alias to /plinth
##
## TODO Deprecation: The homepage for Apache server is being set in
## freedombox-apache-homepage.conf. This line will be removed.
RedirectMatch "^/$" "/plinth"
RedirectMatch "^/freedombox" "/plinth"
##

View File

@ -69,6 +69,8 @@ def get_home_page():
aug.defvar('conf', '/files' + conf_file)
app_path = 'plinth'
for match in aug.match('/files' + conf_file +
'/directive["RedirectMatch"]'):
if aug.get(match + "/arg[1]") == '''"^/$"''':
@ -114,14 +116,11 @@ def setup(helper, old_version=None):
def _migrate_home_page_config():
"""Move the default app configuration to an external file."""
"""Move the home page configuration to an external file."""
# Hold the current default app in a variable
home_page_path = get_home_page().replace('_', '/')
# Reset the default app to plinth in freedombox.conf
actions.superuser_run('config', ['reset-home-page'])
# Write the default app setting into the new conf file
# This step is run at the end because it reloads the Apache server
actions.superuser_run('config', ['set-home-page', home_page_path])