mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-04-29 10:10:19 +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"""
|
"""Return parsed command line arguments as dictionary"""
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
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
|
subparsers.required = True
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def subcommand_setup(_):
|
def subcommand_setup(arguments):
|
||||||
"""Setup Apache configuration."""
|
"""Setup Apache configuration."""
|
||||||
# Regenerate the snakeoil self-signed SSL certificate. This is so that
|
# Regenerate the snakeoil self-signed SSL certificate. This is so that
|
||||||
# FreedomBox images don't all have the same certificate.
|
# FreedomBox images don't all have the same certificate. When FreedomBox
|
||||||
subprocess.run(['make-ssl-cert', 'generate-default-snakeoil',
|
# package is installed via apt, don't regenerate. When upgrading to newer
|
||||||
'--force-overwrite'], check=True)
|
# 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:
|
with action_utils.WebserverChange() as webserver:
|
||||||
# set the prefork worker model
|
# set the prefork worker model
|
||||||
|
|||||||
@ -478,3 +478,13 @@ Owners: {package}
|
|||||||
os.remove(override_file.name)
|
os.remove(override_file.name)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
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):
|
def setup(helper, old_version=None):
|
||||||
"""Configure the module."""
|
"""Configure the module."""
|
||||||
helper.install(managed_packages)
|
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