Python 3.8 fixes.
This commit is contained in:
11
README.rst
11
README.rst
@@ -30,6 +30,17 @@ Usage::
|
|||||||
$ cd modoboa-installer
|
$ cd modoboa-installer
|
||||||
$ sudo ./run.py <your domain>
|
$ sudo ./run.py <your domain>
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
On some systems (Ubuntu 20.04 for example), you might encounter the
|
||||||
|
following issue::
|
||||||
|
|
||||||
|
/usr/bin/env: 'python': No such file or directory
|
||||||
|
|
||||||
|
If so, try to run the command like this::
|
||||||
|
|
||||||
|
$ sudo python3 run.py <your domain>
|
||||||
|
|
||||||
A configuration file will be automatically generated the first time
|
A configuration file will be automatically generated the first time
|
||||||
you run the installer, please don't copy the
|
you run the installer, please don't copy the
|
||||||
``installer.cfg.template`` file manually.
|
``installer.cfg.template`` file manually.
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"""Database related tools."""
|
"""Database related tools."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import pwd
|
import pwd
|
||||||
import stat
|
import stat
|
||||||
|
|
||||||
@@ -143,7 +142,7 @@ class MySQL(Database):
|
|||||||
|
|
||||||
def install_package(self):
|
def install_package(self):
|
||||||
"""Preseed package installation."""
|
"""Preseed package installation."""
|
||||||
name, version, _id = platform.linux_distribution()
|
name, version, _id = utils.dist_info()
|
||||||
name = name.lower()
|
name = name.lower()
|
||||||
if name == "debian":
|
if name == "debian":
|
||||||
mysql_name = "mysql" if version.startswith("8") else "mariadb"
|
mysql_name = "mysql" if version.startswith("8") else "mariadb"
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ class Postfix(base.Installer):
|
|||||||
def install_packages(self):
|
def install_packages(self):
|
||||||
"""Preconfigure postfix package installation."""
|
"""Preconfigure postfix package installation."""
|
||||||
if "centos" in utils.dist_name():
|
if "centos" in utils.dist_name():
|
||||||
config = configparser.SafeConfigParser()
|
config = configparser.ConfigParser()
|
||||||
with open("/etc/yum.repos.d/CentOS-Base.repo") as fp:
|
with open("/etc/yum.repos.d/CentOS-Base.repo") as fp:
|
||||||
config.readfp(fp)
|
config.read_file(fp)
|
||||||
config.set("centosplus", "enabled", "1")
|
config.set("centosplus", "enabled", "1")
|
||||||
config.set("centosplus", "includepkgs", "postfix-*")
|
config.set("centosplus", "includepkgs", "postfix-*")
|
||||||
config.set("base", "exclude", "postfix-*")
|
config.set("base", "exclude", "postfix-*")
|
||||||
|
|||||||
@@ -73,17 +73,26 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, login=True, **kwargs):
|
|||||||
return process.returncode, output
|
return process.returncode, output
|
||||||
|
|
||||||
|
|
||||||
def dist_name():
|
def dist_info():
|
||||||
"""Try to guess the distribution name."""
|
"""Try to return information about the system we're running on."""
|
||||||
try:
|
try:
|
||||||
# Python 3.8 and up way
|
# Python 3.8 and up way
|
||||||
import distro
|
import distro
|
||||||
name, version, _id = distro.linux_distribution()
|
return distro.linux_distribution()
|
||||||
except ImportError as e:
|
except ImportError:
|
||||||
# Python 3.7 and down way
|
# Python 3.7 and down way
|
||||||
import platform
|
import platform
|
||||||
name, version, _id = platform.linux_distribution()
|
return platform.linux_distribution()
|
||||||
return "unknown" if not name else name.lower()
|
printcolor(
|
||||||
|
"Failed to retrieve information about your system, aborting.",
|
||||||
|
RED)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def dist_name():
|
||||||
|
"""Try to guess the distribution name."""
|
||||||
|
name, version, _id = dist_info()
|
||||||
|
return name.lower()
|
||||||
|
|
||||||
|
|
||||||
def mkdir(path, mode, uid, gid):
|
def mkdir(path, mode, uid, gid):
|
||||||
|
|||||||
4
run.py
4
run.py
@@ -79,9 +79,9 @@ def main(input_args):
|
|||||||
utils.check_config_file(args.configfile, args.interactive, args.upgrade)
|
utils.check_config_file(args.configfile, args.interactive, args.upgrade)
|
||||||
if args.stop_after_configfile_check:
|
if args.stop_after_configfile_check:
|
||||||
return
|
return
|
||||||
config = configparser.SafeConfigParser()
|
config = configparser.ConfigParser()
|
||||||
with open(args.configfile) as fp:
|
with open(args.configfile) as fp:
|
||||||
config.readfp(fp)
|
config.read_file(fp)
|
||||||
if not config.has_section("general"):
|
if not config.has_section("general"):
|
||||||
config.add_section("general")
|
config.add_section("general")
|
||||||
config.set("general", "domain", args.domain)
|
config.set("general", "domain", args.domain)
|
||||||
|
|||||||
Reference in New Issue
Block a user