summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-10-05 16:02:47 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-10-05 16:03:23 +0100
commit3a546e0b7a59c881d8366aabe1cf5cf2050a572d (patch)
tree6b7a4e2e71556ba5c68d88749e6281ae2ba3ba64 /pykolab
parentd211a6e58afe537d9d4b8fbcd3d8c82ce54a39f0 (diff)
downloadpykolab-3a546e0b7a59c881d8366aabe1cf5cf2050a572d.tar.gz
Allow the specification of a php.ini location, and attempt the two known locations (#1084)
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/setup/setup_php.py28
1 files changed, 26 insertions, 2 deletions
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)