diff --git a/rattail_fabric2/mysql.py b/rattail_fabric2/mysql.py index a96dbbb..f3b62aa 100644 --- a/rattail_fabric2/mysql.py +++ b/rattail_fabric2/mysql.py @@ -24,6 +24,8 @@ Fabric Library for MySQL """ +import re + from rattail_fabric2 import apt, make_deploy, sed @@ -38,6 +40,18 @@ def install(c): apt.install(c, 'default-mysql-server') +def get_version_string(c): + """ + Fetch the version of MySQL running on the target system + """ + result = c.sudo('mysql --version', warn=True) + if not result.failed: + # match = re.match(r'^mysql .*?(\d+\.\d+\.\d+)-MariaDB', result.stdout) + match = re.match(r'^mysql +Ver +(\d+\.\d+\.\d+)-.*', result.stdout) + if match: + return match.group(1) + + def set_bind_address(c, address): """ Configure the 'bind-address' setting with the given value.