mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 02:54:34 +02:00
More generality for renewer config. (Still no CLI flags.)
This commit is contained in:
+11
-3
@@ -6,6 +6,7 @@ configuration."""
|
|||||||
|
|
||||||
# TODO: call new installer API to restart servers after deployment
|
# TODO: call new installer API to restart servers after deployment
|
||||||
|
|
||||||
|
import copy
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import configobj
|
import configobj
|
||||||
@@ -87,7 +88,7 @@ def renew(cert, old_version):
|
|||||||
# (where fewer than all names were renewed)
|
# (where fewer than all names were renewed)
|
||||||
|
|
||||||
|
|
||||||
def main(config=constants.RENEWER_DEFAULTS):
|
def main(config=None):
|
||||||
"""main function for autorenewer script."""
|
"""main function for autorenewer script."""
|
||||||
# TODO: Distinguish automated invocation from manual invocation,
|
# TODO: Distinguish automated invocation from manual invocation,
|
||||||
# perhaps by looking at sys.argv[0] and inhibiting automated
|
# perhaps by looking at sys.argv[0] and inhibiting automated
|
||||||
@@ -95,10 +96,17 @@ def main(config=constants.RENEWER_DEFAULTS):
|
|||||||
# turned it off. (The boolean parameter should probably be
|
# turned it off. (The boolean parameter should probably be
|
||||||
# called renewer_enabled.)
|
# called renewer_enabled.)
|
||||||
|
|
||||||
# This attempts to read the renewer config file and augment or replace
|
# Merge supplied config, if provided, on top of builtin defaults
|
||||||
|
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
||||||
|
defaults_copy.merge(config if config is not None else configobj.ConfigObj())
|
||||||
|
config = defaults_copy
|
||||||
|
# Now attempt to read the renewer config file and augment or replace
|
||||||
# the renewer defaults with any options contained in that file. If
|
# the renewer defaults with any options contained in that file. If
|
||||||
# renewer_config_file is undefined or if the file is nonexistent or
|
# renewer_config_file is undefined or if the file is nonexistent or
|
||||||
# empty, this .merge() will have no effect.
|
# empty, this .merge() will have no effect. TODO: when we have a more
|
||||||
|
# elaborate renewer command line, we will presumably also be able to
|
||||||
|
# specify a config file on the command line, which, if provided, should
|
||||||
|
# take precedence over this one.
|
||||||
config.merge(configobj.ConfigObj(config.get("renewer_config_file", "")))
|
config.merge(configobj.ConfigObj(config.get("renewer_config_file", "")))
|
||||||
|
|
||||||
for i in os.listdir(config["renewal_configs_dir"]):
|
for i in os.listdir(config["renewal_configs_dir"]):
|
||||||
|
|||||||
+11
-4
@@ -78,13 +78,13 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
and/or systemwide defaults.
|
and/or systemwide defaults.
|
||||||
:type configuration: :class:`configobj.ConfigObj`"""
|
:type configuration: :class:`configobj.ConfigObj`"""
|
||||||
|
|
||||||
def __init__(self, configfile, defaults=constants.RENEWER_DEFAULTS):
|
def __init__(self, configfile, config_opts=None):
|
||||||
"""Instantiate a RenewableCert object from an existing lineage.
|
"""Instantiate a RenewableCert object from an existing lineage.
|
||||||
|
|
||||||
:param :class:`configobj.ConfigObj` configfile: an already-parsed
|
:param :class:`configobj.ConfigObj` configfile: an already-parsed
|
||||||
ConfigObj object made from reading the renewal config file that
|
ConfigObj object made from reading the renewal config file that
|
||||||
defines this lineage.
|
defines this lineage.
|
||||||
:param :class:`configobj.ConfigObj` defaults: systemwide defaults
|
:param :class:`configobj.ConfigObj` config_opts: systemwide defaults
|
||||||
for renewal properties not otherwise specified in the individual
|
for renewal properties not otherwise specified in the individual
|
||||||
renewal config file.
|
renewal config file.
|
||||||
|
|
||||||
@@ -109,7 +109,10 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
# TODO: Do we actually use anything from defaults and do we want to
|
# TODO: Do we actually use anything from defaults and do we want to
|
||||||
# read further defaults from the systemwide renewal configuration
|
# read further defaults from the systemwide renewal configuration
|
||||||
# file at this stage?
|
# file at this stage?
|
||||||
self.configuration = copy.deepcopy(defaults)
|
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
||||||
|
defaults_copy.merge(config_opts if config_opts is not None
|
||||||
|
else configobj.ConfigObj())
|
||||||
|
self.configuration = defaults_copy
|
||||||
self.configuration.merge(self.configfile)
|
self.configuration.merge(self.configfile)
|
||||||
|
|
||||||
if not all(x in self.configuration for x in ALL_FOUR):
|
if not all(x in self.configuration for x in ALL_FOUR):
|
||||||
@@ -479,7 +482,7 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def new_lineage(cls, lineagename, cert, privkey, chain,
|
def new_lineage(cls, lineagename, cert, privkey, chain,
|
||||||
renewalparams=None, config=constants.RENEWER_DEFAULTS):
|
renewalparams=None, config=None):
|
||||||
# pylint: disable=too-many-locals,too-many-arguments
|
# pylint: disable=too-many-locals,too-many-arguments
|
||||||
"""Create a new certificate lineage.
|
"""Create a new certificate lineage.
|
||||||
|
|
||||||
@@ -511,6 +514,10 @@ class RenewableCert(object): # pylint: disable=too-many-instance-attributes
|
|||||||
:returns: the newly-created RenewalCert object
|
:returns: the newly-created RenewalCert object
|
||||||
:rtype: :class:`storage.renewableCert`"""
|
:rtype: :class:`storage.renewableCert`"""
|
||||||
|
|
||||||
|
defaults_copy = copy.deepcopy(constants.RENEWER_DEFAULTS)
|
||||||
|
defaults_copy.merge(config if config is not None
|
||||||
|
else configobj.ConfigObj())
|
||||||
|
config = defaults_copy
|
||||||
# This attempts to read the renewer config file and augment or replace
|
# This attempts to read the renewer config file and augment or replace
|
||||||
# the renewer defaults with any options contained in that file. If
|
# the renewer defaults with any options contained in that file. If
|
||||||
# renewer_config_file is undefined or if the file is nonexistent or
|
# renewer_config_file is undefined or if the file is nonexistent or
|
||||||
|
|||||||
Reference in New Issue
Block a user