From 8052f4aeded5d96471f2d18e78066f5e218549d0 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 23 Jun 2017 09:43:41 +0200 Subject: [PATCH] Added new option to generate config file. fix #130 --- README.rst | 11 ++++++++++- installer.cfg.default => installer.cfg.template | 0 modoboa_installer/utils.py | 2 +- run.py | 5 +++++ 4 files changed, 16 insertions(+), 2 deletions(-) rename installer.cfg.default => installer.cfg.template (100%) diff --git a/README.rst b/README.rst index f556685..0c4ac7a 100644 --- a/README.rst +++ b/README.rst @@ -27,7 +27,9 @@ Usage:: $ cd modoboa-installer $ sudo ./run.py -To customize the installation, look at the ``installer.cfg`` file. +A configuration file will be automatically generated the first time +you run the installer, please don't copy the +``installer.cfg.template`` file manually. By default, the following components are installed: @@ -37,6 +39,13 @@ By default, the following components are installed: * Dovecot * Amavis (with SpamAssassin and ClamAV) +If you want to customize configuration before running the installer, +run the following command:: + + $ ./run.py --stop-after-configfile-check + +Make your modifications and run the installer as usual. + If you want more information about the installation process, add the ``--debug`` option to your command line. diff --git a/installer.cfg.default b/installer.cfg.template similarity index 100% rename from installer.cfg.default rename to installer.cfg.template diff --git a/modoboa_installer/utils.py b/modoboa_installer/utils.py index 82eb2fa..68e43f4 100644 --- a/modoboa_installer/utils.py +++ b/modoboa_installer/utils.py @@ -146,7 +146,7 @@ def check_config_file(dest): printcolor( "Configuration file {} not found, creating new one." .format(dest), YELLOW) - with open("installer.cfg.default") as fp: + with open("installer.cfg.template") as fp: buf = fp.read() context = { "mysql_password": make_password(), diff --git a/run.py b/run.py index 92e58cd..e0f600b 100755 --- a/run.py +++ b/run.py @@ -23,6 +23,9 @@ def main(): help="Force installation") parser.add_argument("--configfile", default="installer.cfg", help="Configuration file to use") + parser.add_argument( + "--stop-after-configfile-check", action="store_true", default=False, + help="Check configuration, generate it if needed and exit") parser.add_argument("domain", type=str, help="The main domain of your future mail server") args = parser.parse_args() @@ -31,6 +34,8 @@ def main(): utils.ENV["debug"] = True utils.printcolor("Welcome to Modoboa installer!", utils.GREEN) utils.check_config_file(args.configfile) + if args.stop_after_configfile_check: + return config = configparser.SafeConfigParser() with open(args.configfile) as fp: config.readfp(fp)