Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for Gentoo + python 3.x #15

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions certbot_haproxy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Ubuntu Vivid (15.04)
- Ubuntu Wily (15.10)
- Ubuntu Xenial (16.04)
- CentOS (7)

You can define new lists below following the instructions hereafter, please
consider making a pull-request when you do so, so others may benefit of your
Expand Down Expand Up @@ -57,8 +58,8 @@
from certbot_haproxy.util import MemoiseNoArgs

RE_HAPROXY_DOMAIN_ACL = re.compile(
r'\s*acl (?P<name>[0-9a-z_\-.]+) '
r'hdr\(host\) -i '
r'\s*acl\s+(?P<name>[0-9a-z_\-.]+)\s+'
r'(?:hdr\(host\)|req\.ssl_sni)\s+-i\s+'
r'(?P<domain>' # Start group "domain"
r'(?:[0-9-a-z](?:[a-z0-9-]{0,61}[a-z0-9]\.)+)' # (sub-)domain parts
r'(?:[0-9-a-z](?:[a-z0-9-]{0,61}[a-z0-9]))' # TLD part
Expand Down Expand Up @@ -87,6 +88,29 @@
crt_directory='/opt/certbot/haproxy_fullchains',
)

CLI_DEFAULTS_RHEL_BASED_SYSTEMD_OS = dict(
service_manager='systemctl',
version_cmd=['/usr/sbin/haproxy', '-v'],
restart_cmd=['sudo', 'systemctl', 'restart', 'haproxy'],
# Needs the config file as an argument:
conftest_cmd=['/usr/sbin/haproxy', '-c', '-f'],
haproxy_config='/etc/haproxy/haproxy.cfg',
# Needs to be writeable by the user that will run certbot
crt_directory='/opt/certbot/haproxy_fullchains',
)

CLI_DEFAULTS_GENTOO_BASED_SYSTEMD_OS = dict(
service_manager='/sbin/service',
version_cmd=['/usr/bin/haproxy', '-v'],
restart_cmd=['sudo', '/etc/init.d/haproxy', 'restart'],
# Needs the config file as an argument:
conftest_cmd=['/usr/bin/haproxy', '-c', '-f'],
haproxy_config='/etc/haproxy/haproxy.cfg',
# Needs to be writeable by the user that will run certbot
crt_directory='/opt/certbot/haproxy_fullchains',
)


CLI_DEFAULTS = {
"debian": {
'_min_version': '7',
Expand All @@ -102,7 +126,16 @@
'15.04': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS,
'15.10': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS,
'16.04': CLI_DEFAULTS_DEBIAN_BASED_SYSTEMD_OS
}
},
"centos": {
'_min_version': '7',
'7': CLI_DEFAULTS_RHEL_BASED_SYSTEMD_OS
},
"gentoo": {
'_min_version': '0',
'_max_version': '999999',
'': CLI_DEFAULTS_GENTOO_BASED_SYSTEMD_OS
},
}

logger = logging.getLogger(__name__) # pylint:disable=invalid-name
Expand Down
5 changes: 3 additions & 2 deletions certbot_haproxy/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def prepare():

# Check that a supported version of HAProxy is installed.
version_cmd = constants.os_constant("version_cmd")
output = subprocess.check_output(version_cmd)
output = subprocess.check_output(version_cmd).decode('utf-8')
matches = re.match(
r'HA-Proxy version'
r' (?P<version>[0-9]{1,4}\.[0-9]{1,4}\.[0-9a-z]{1,10}).*',
Expand Down Expand Up @@ -472,7 +472,8 @@ def save(self, title=None, temporary=False):
path = os.path.dirname(os.path.abspath(filepath))
if not os.path.exists(path):
os.makedirs(path)

if isinstance(contents, bytes):
contents = contents.decode('utf-8')
with open(filepath, 'w') as cert:
cert.write(contents)
self.new_crt_files = {}
Expand Down