summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-04 11:04:57 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-08-04 11:08:30 +0100
commite1f0780b02149278390517e7731f8b39ad7d7556 (patch)
treecca2694b62ccfdffaf02211370e641480f97276d /pykolab
parentd3fae3685b2e9bd905887def6d8378cf728a3246 (diff)
downloadpykolab-e1f0780b02149278390517e7731f8b39ad7d7556.tar.gz
Add setup_php for the PHP timezone
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/Makefile.am1
-rw-r--r--pykolab/setup/setup_php.py72
2 files changed, 73 insertions, 0 deletions
diff --git a/pykolab/Makefile.am b/pykolab/Makefile.am
index 73cf939..6353f86 100644
--- a/pykolab/Makefile.am
+++ b/pykolab/Makefile.am
@@ -57,6 +57,7 @@ pykolab_setup_PYTHON = \
setup/setup_ldap.py \
setup/setup_mta.py \
setup/setup_mysql.py \
+ setup/setup_php.py \
setup/setup_roundcube.py \
setup/setup_zpush.py \
setup/__init__.py
diff --git a/pykolab/setup/setup_php.py b/pykolab/setup/setup_php.py
new file mode 100644
index 0000000..c9db0f5
--- /dev/null
+++ b/pykolab/setup/setup_php.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2012 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 3 or, at your option, any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+from augeas import Augeas
+import os
+import shutil
+import subprocess
+import tempfile
+
+import components
+
+import pykolab
+
+from pykolab import utils
+from pykolab.auth import Auth
+from pykolab.constants import *
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.setup')
+conf = pykolab.getConf()
+
+def __init__():
+ components.register('php', execute, description=description())
+
+def cli_options():
+ php_group = conf.add_cli_parser_option_group(_("PHP Options"))
+
+ php_group.add_option(
+ "--timezone",
+ dest = "timezone",
+ action = "store",
+ default = "UTC",
+ help = _("Specify the timezone for PHP.")
+ )
+
+def description():
+ return _("Setup PHP.")
+
+def execute(*args, **kw):
+ myaugeas = Augeas()
+
+ setting_base = '/files/etc/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_path = insert_paths[(len(insert_paths)-1)]
+ myaugeas.insert(insert_path, setting_key, False)
+
+ log.debug(_("Setting key %r to %r") % ('Date/date.timezone', conf.timezone), level=8)
+ myaugeas.set(setting, conf.timezone)
+
+ myaugeas.save()
+