Branch 'pykolab-0.5' - 2 commits - pykolab/setup

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Oct 5 17:04:37 CEST 2012


 pykolab/setup/setup_mta.py |   47 ++++++++++++++++++++++++++-------------------
 pykolab/setup/setup_php.py |   28 ++++++++++++++++++++++++--
 2 files changed, 54 insertions(+), 21 deletions(-)

New commits:
commit 3a546e0b7a59c881d8366aabe1cf5cf2050a572d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Oct 5 16:02:47 2012 +0100

    Allow the specification of a php.ini location, and attempt the two known locations (#1084)

diff --git a/pykolab/setup/setup_php.py b/pykolab/setup/setup_php.py
index 4d2679b..9fa0098 100644
--- a/pykolab/setup/setup_php.py
+++ b/pykolab/setup/setup_php.py
@@ -49,6 +49,14 @@ def cli_options():
             help    = _("Specify the timezone for PHP.")
         )
 
+    php_group.add_option(
+            "--with-php-ini",
+            dest    = "php_ini_path",
+            action  = "store",
+            default = None,
+            help    = _("Specify the path to the php.ini file used with the webserver.")
+        )
+
 def description():
     return _("Setup PHP.")
 
@@ -65,15 +73,31 @@ def execute(*args, **kw):
                 default="UTC"
             )
 
+    if not conf.php_ini_path == None:
+        if not os.path.isfile(conf.php_ini_path):
+            log.error(_("Cannot configure PHP through %r (No such file or directory)") % (conf.php_ini_path))
+            return
+        php_ini = conf.php_ini_path
+
+    else:
+        # Search and destroy
+        php_ini = "/etc/php.ini"
+        if not os.path.isfile(php_ini):
+            php_ini = "/etc/php5/apache2/php.ini"
+
+        if not os.path.isfile(php_ini):
+            log.error(_("Could not find PHP configuration file php.ini"))
+            return
+
     myaugeas = Augeas()
 
-    setting_base = '/files/etc/php.ini/'
+    setting_base = '/files%s/' % (php_ini)
 
     setting = os.path.join(setting_base, 'Date', 'date.timezone')
     current_value = myaugeas.get(setting)
 
     if current_value == None:
-        insert_paths = myaugeas.match('/files/etc/php.ini/Date/*')
+        insert_paths = myaugeas.match('/files%s/Date/*' % (php_ini))
         insert_path = insert_paths[(len(insert_paths)-1)]
         myaugeas.insert(insert_path, 'date.timezone', False)
 


commit d211a6e58afe537d9d4b8fbcd3d8c82ce54a39f0
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Oct 5 15:51:46 2012 +0100

    Skip Amavis configuration if no file /etc/amavisd/amavisd.conf exists

diff --git a/pykolab/setup/setup_mta.py b/pykolab/setup/setup_mta.py
index f9202d3..e6a019c 100644
--- a/pykolab/setup/setup_mta.py
+++ b/pykolab/setup/setup_mta.py
@@ -266,26 +266,35 @@ result_attribute = mail
 
     template_file = None
 
-    if os.path.isfile('/etc/kolab/templates/amavisd.conf.tpl'):
-        template_file = '/etc/kolab/templates/amavisd.conf.tpl'
-    elif os.path.isfile('/usr/share/kolab/templates/amavisd.conf.tpl'):
-        template_file = '/usr/share/kolab/templates/amavisd.conf.tpl'
-    elif os.path.isfile(os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'amavisd.conf.tpl'))):
-        template_file = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'amavisd.conf.tpl'))
-
-    if not template_file == None:
-        fp = open(template_file, 'r')
-        template_definition = fp.read()
-        fp.close()
-
-        t = Template(template_definition, searchList=[amavisd_settings])
-        fp = open('/etc/amavisd/amavisd.conf', 'w')
-        fp.write(t.__str__())
-        fp.close()
-
+    # On RPM installations, Amavis configuration is contained within a single file.
+    if os.path.isfile("/etc/amavsid/amavisd.conf"):
+        if os.path.isfile('/etc/kolab/templates/amavisd.conf.tpl'):
+            template_file = '/etc/kolab/templates/amavisd.conf.tpl'
+        elif os.path.isfile('/usr/share/kolab/templates/amavisd.conf.tpl'):
+            template_file = '/usr/share/kolab/templates/amavisd.conf.tpl'
+        elif os.path.isfile(os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'amavisd.conf.tpl'))):
+            template_file = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'share', 'templates', 'amavisd.conf.tpl'))
+
+        if not template_file == None:
+            fp = open(template_file, 'r')
+            template_definition = fp.read()
+            fp.close()
+
+            t = Template(template_definition, searchList=[amavisd_settings])
+            fp = open('/etc/amavisd/amavisd.conf', 'w')
+            fp.write(t.__str__())
+            fp.close()
+
+        else:
+            log.error(_("Could not write out Amavis configuration file /etc/amavisd/amavisd.conf"))
+            return
+
+    # On APT installations, /etc/amavis/conf.d/ is a directory with many more files.
+    # 
+    # Somebody could work on enhancement request #1080 to configure LDAP lookups,
+    # while really it isn't required.
     else:
-        log.error(_("Could not write out Amavis configuration file /etc/amavisd/amavisd.conf"))
-        return
+        log.info(_("Not writing out any configuration for Amavis."))
 
     if os.path.isfile('/bin/systemctl'):
         subprocess.call(['systemctl', 'restart', 'postfix.service'])





More information about the commits mailing list