mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
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:
parent
bedc5ff96d
commit
bd43ed515e
@ -23,11 +23,8 @@ Configuration helper for FreedomBox general configuration.
|
|||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import augeas
|
|
||||||
|
|
||||||
from plinth import action_utils
|
from plinth import action_utils
|
||||||
from plinth.modules.config import (APACHE_HOMEPAGE_CONF_FILE_NAME,
|
from plinth.modules.config import APACHE_HOMEPAGE_CONF_FILE_NAME
|
||||||
FREEDOMBOX_APACHE_CONFIG)
|
|
||||||
|
|
||||||
|
|
||||||
def parse_arguments():
|
def parse_arguments():
|
||||||
@ -39,31 +36,11 @@ def parse_arguments():
|
|||||||
help='Set the home page for this FreedomBox instance.')
|
help='Set the home page for this FreedomBox instance.')
|
||||||
set_home_page.add_argument('homepage',
|
set_home_page.add_argument('homepage',
|
||||||
help='path to the webserver home page')
|
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
|
subparsers.required = True
|
||||||
return parser.parse_args()
|
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):
|
def subcommand_set_home_page(arguments):
|
||||||
"""Set the default app for this FreedomBox."""
|
"""Set the default app for this FreedomBox."""
|
||||||
conf_file_path = os.path.join('/etc/apache2/conf-available',
|
conf_file_path = os.path.join('/etc/apache2/conf-available',
|
||||||
|
|||||||
@ -4,13 +4,8 @@
|
|||||||
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
|
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" env=HTTPS
|
||||||
|
|
||||||
##
|
##
|
||||||
## Redirect traffic on home to /plinth as part of turning the machine
|
## Provide /freedombox as an alias to /plinth
|
||||||
## into FreedomBox server. Plinth then acts as a portal to reach all
|
|
||||||
## other services.
|
|
||||||
##
|
##
|
||||||
## 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"
|
RedirectMatch "^/freedombox" "/plinth"
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
@ -69,6 +69,8 @@ def get_home_page():
|
|||||||
|
|
||||||
aug.defvar('conf', '/files' + conf_file)
|
aug.defvar('conf', '/files' + conf_file)
|
||||||
|
|
||||||
|
app_path = 'plinth'
|
||||||
|
|
||||||
for match in aug.match('/files' + conf_file +
|
for match in aug.match('/files' + conf_file +
|
||||||
'/directive["RedirectMatch"]'):
|
'/directive["RedirectMatch"]'):
|
||||||
if aug.get(match + "/arg[1]") == '''"^/$"''':
|
if aug.get(match + "/arg[1]") == '''"^/$"''':
|
||||||
@ -114,14 +116,11 @@ def setup(helper, old_version=None):
|
|||||||
|
|
||||||
|
|
||||||
def _migrate_home_page_config():
|
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
|
# Hold the current default app in a variable
|
||||||
home_page_path = get_home_page().replace('_', '/')
|
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
|
# Write the default app setting into the new conf file
|
||||||
# This step is run at the end because it reloads the Apache server
|
# This step is run at the end because it reloads the Apache server
|
||||||
actions.superuser_run('config', ['set-home-page', home_page_path])
|
actions.superuser_run('config', ['set-home-page', home_page_path])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user