diff --git a/simp_le.py b/simp_le.py index b28e1de..efabac1 100755 --- a/simp_le.py +++ b/simp_le.py @@ -304,6 +304,22 @@ class IOPlugin(object): def __init__(self, path, **dummy_kwargs): self.path = path + self.arguments_dest = [] + if 'arguments' in dummy_kwargs: + self.arguments = dummy_kwargs['arguments'] + else: + self.arguments = None + + def add_arguments(self, manager): + if self.arguments: + for argument in self.arguments: + storeAction = manager.add_argument(*argument[0], **argument[1]) + self.arguments_dest.append(storeAction.dest) + + def set_arguments(self, args): + vargs = vars(args) + for dest in self.arguments_dest: + setattr(self, dest, vargs[dest]) @abc.abstractmethod def persisted(self): @@ -474,7 +490,16 @@ def dump_pem_jwk(data): ).strip() -@IOPlugin.register(path='external.sh', typ=OpenSSL.crypto.FILETYPE_PEM) +@IOPlugin.register(path='external.sh', typ=OpenSSL.crypto.FILETYPE_PEM, + arguments=[ + [ + ['--script'], + { + 'default': os.path.join('.', "external.sh"), + 'help': 'Script file for external.sh plugin', + } + ] + ]) class ExternalIOPlugin(OpenSSLIOPlugin): """External IO Plugin. @@ -497,11 +522,6 @@ class ExternalIOPlugin(OpenSSLIOPlugin): and ordered in the same way as in the `load` case. """ - @property - def script(self): - """Path to the script.""" - return os.path.join('.', self.path) - def get_output_or_fail(self, command): """Get output or throw an exception in case of errors.""" try: @@ -864,6 +884,9 @@ def create_parser(): 'is necessary to cover all components: key, certificate, chain. ' 'Allowed values: %s.' % ', '.join(sorted(IOPlugin.registered)), ) + for plugin_name in IOPlugin.registered: + IOPlugin.registered[plugin_name].add_arguments(io_group) + io_group.add_argument( '--cert_key_size', type=int, default=4096, metavar='BITS', help='Certificate key size. Fresh key is created for each renewal.', @@ -1121,6 +1144,10 @@ def check_plugins_persist_all(ioplugins): raise Error('Selected IO plugins do not cover the following ' 'components: %s.' % ', '.join(not_persisted)) +def set_plugins_arguments(ioplugins, args): + """Set arguments for plugin""" + for plugin_name in ioplugins: + IOPlugin.registered[plugin_name].set_arguments(args) def load_existing_data(ioplugins): """Load existing data from disk. @@ -1375,6 +1402,7 @@ def main_with_exceptions(cli_args): if args.vhosts is None: raise Error('You must set at least one -d/--vhost') + set_plugins_arguments(args.ioplugins, args) check_plugins_persist_all(args.ioplugins) existing_data = load_existing_data(args.ioplugins)