mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
apache: Only regenerate snake oil cert when needed
Closes #1230. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
b057a57dec
commit
7b326870da
@ -31,18 +31,26 @@ def parse_arguments():
|
||||
"""Return parsed command line arguments as dictionary"""
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
subparsers.add_parser('setup', help='Setup for Apache')
|
||||
subparser = subparsers.add_parser('setup', help='Setup for Apache')
|
||||
subparser.add_argument(
|
||||
'--old-version', type=int, required=True,
|
||||
help='Earlier version of the app that is already setup.')
|
||||
|
||||
subparsers.required = True
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def subcommand_setup(_):
|
||||
def subcommand_setup(arguments):
|
||||
"""Setup Apache configuration."""
|
||||
# Regenerate the snakeoil self-signed SSL certificate. This is so that
|
||||
# FreedomBox images don't all have the same certificate.
|
||||
subprocess.run(['make-ssl-cert', 'generate-default-snakeoil',
|
||||
'--force-overwrite'], check=True)
|
||||
# FreedomBox images don't all have the same certificate. When FreedomBox
|
||||
# package is installed via apt, don't regenerate. When upgrading to newer
|
||||
# version of Apache FreedomBox app and setting up for the first time don't
|
||||
# regenerate.
|
||||
if action_utils.is_disk_image() and arguments.old_version == 0:
|
||||
subprocess.run([
|
||||
'make-ssl-cert', 'generate-default-snakeoil', '--force-overwrite'
|
||||
], check=True)
|
||||
|
||||
with action_utils.WebserverChange() as webserver:
|
||||
# set the prefork worker model
|
||||
|
||||
@ -478,3 +478,13 @@ Owners: {package}
|
||||
os.remove(override_file.name)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def is_disk_image():
|
||||
"""Return whether the current machine is from a disk image.
|
||||
|
||||
Two primary ways to install FreedomBox are:
|
||||
- Using FreedomBox image for various hardware platforms.
|
||||
- Installing packages on a Debian machine using apt.
|
||||
"""
|
||||
return os.path.exists('/var/lib/freedombox/is-freedombox-disk-image')
|
||||
|
||||
@ -30,4 +30,5 @@ managed_packages = ['apache2', 'libapache2-mod-gnutls', 'libapache2-mod-php']
|
||||
def setup(helper, old_version=None):
|
||||
"""Configure the module."""
|
||||
helper.install(managed_packages)
|
||||
actions.superuser_run('apache', ['setup'])
|
||||
actions.superuser_run('apache',
|
||||
['setup', '--old-version', str(old_version)])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user