diff --git a/actions/config b/actions/config index eeee8adc9..55cbc2efe 100755 --- a/actions/config +++ b/actions/config @@ -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', diff --git a/data/etc/apache2/conf-available/freedombox.conf b/data/etc/apache2/conf-available/freedombox.conf index 57ef13dd4..f5710dcbd 100644 --- a/data/etc/apache2/conf-available/freedombox.conf +++ b/data/etc/apache2/conf-available/freedombox.conf @@ -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" ## diff --git a/plinth/modules/config/__init__.py b/plinth/modules/config/__init__.py index 5a41d905e..1b1264bcf 100644 --- a/plinth/modules/config/__init__.py +++ b/plinth/modules/config/__init__.py @@ -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])