Page MenuHomeDevCentral

D743.id1865.diff
No OneTemporary

D743.id1865.diff

Index: __init__.py
===================================================================
--- /dev/null
+++ __init__.py
@@ -0,0 +1 @@
+""" Deploying certificates to jails plugin """
Index: certCopyPlugin.py
===================================================================
--- /dev/null
+++ certCopyPlugin.py
@@ -0,0 +1,84 @@
+"""
+Deploy a Let's encrypt certificate to an additional path
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Project: Nasqueron
+Created: 2016-12-03
+License: Trivial work, not eligible to copyright
+Depedencies: Certbot
+--------------------------------------------------------------
+"""
+
+from certbot import interfaces
+from certbot.plugins import common
+
+""" Common imports """
+import os
+import shutil
+import subprocess
+
+
+logger = logging.getLogger(__name__)
+
+
+@zope.interface.implementer(self, interfaces.IInstaller)
+@zope.interface.provider(self, interfaces.IPluginFactory)
+class Installer(common.Plugin):
+
+ description = "Copy the certificate to a given path, without keeping permissions"
+
+ def __init__(self, path):
+ pass
+
+ def get_certdir_path(self):
+ """Full absolute path to SSL configuration file."""
+ return self.config.config_dir
+
+ @classmethod
+ def add_parser_arguments(cls, add):
+ add("server_root", default=constants.CLI_DEFAULTS["server_root"], help="Path to the service")
+
+ def prepare(self):
+ if not self.conf("server_root"):
+ raise MisconfigurationError
+ pass
+
+ def more_info(self):
+ return "Copy the to the target destination, useful for lxc containers or FreeBSD jails"
+
+ def get_all_names(self):
+ pass
+
+ def deploy_cert(self, domain, cert_path, key_path, chain_path, fullchain_path):
+ try:
+ copyfile(fullchain_path,self.conf("server_root"))
+ copyfile(key_path,self.conf("server_root"))
+ except (shutil.Error, IOError) as e:
+ logger.info("Cannot deploy certificate: %s", str(e))
+ raise PluginError
+ pass
+
+ logger.info("%s certificate successfully deployed to %s", domain, self.conf("server_root"))
+
+ def enhance(self, domain, enhancement, options=None):
+ pass
+
+ def supported_enhancements(self):
+ pass
+
+ def save(self, title=None, temporary=False):
+ pass
+
+ def rollback_checkpoints(self, rollback=1):
+ pass
+
+ def recovery_routine(self):
+ pass
+
+ def view_config_changes(self):
+ pass
+
+ def config_test(self):
+ pass
+
+ def restart(self):
+ pass
Index: services/mumbleCertCopyPlugin.py
===================================================================
--- /dev/null
+++ services/mumbleCertCopyPlugin.py
@@ -0,0 +1,42 @@
+"""
+Deploy a Let's encrypt certificate to Mumble's jail
+- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+Project: Nasqueron
+Created: 2016-12-03
+License: Trivial work, not eligible to copyright
+--------------------------------------------------------------
+"""
+
+from certbot import interfaces
+from certbot.plugins import common
+
+from ... import certCopyPlugin
+
+""" Common imports """
+import subprocess
+
+
+logger = logging.getLogger(__name__)
+
+
+@zope.interface.implementer(self, interfaces.IInstaller)
+@zope.interface.provider(self, interfaces.IPluginFactory)
+class Installer(cert-copy-plugin.Installer):
+
+ description = "Copy the certificate to the Mumble jail"
+
+ def __init__(self, path):
+ pass
+
+ def more_info(self):
+ return description
+
+ def restart(self):
+ try:
+ subprocess.call(['service', 'mumble-server', 'restart' ])
+ except OSError as e:
+ logger.info("Restart failed: %s ", str(e))
+ raise PluginError instead
+
+
+ logger.info("Service deployed")

File Metadata

Mime Type
text/plain
Expires
Thu, Nov 28, 21:54 (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2270038
Default Alt Text
D743.id1865.diff (3 KB)

Event Timeline