2010-01-15 00:15:41 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-12-30 16:25:42 +00:00
|
|
|
#
|
|
|
|
# This file is part of Radicale Server - Calendar Server
|
2013-04-26 01:28:03 +02:00
|
|
|
# Copyright © 2008-2013 Guillaume Ayoub
|
2009-07-27 15:04:54 +00:00
|
|
|
# Copyright © 2008 Nicolas Kandel
|
|
|
|
# Copyright © 2008 Pascal Halter
|
2008-12-30 16:25:42 +00:00
|
|
|
#
|
|
|
|
# This library 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, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library 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 General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2009-07-27 15:04:54 +00:00
|
|
|
"""
|
|
|
|
Radicale configuration module.
|
|
|
|
|
|
|
|
Give a configparser-like interface to read and write configuration.
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2009-07-27 15:04:54 +00:00
|
|
|
"""
|
|
|
|
|
2010-01-18 10:48:06 +01:00
|
|
|
import os
|
2010-02-10 18:57:21 +01:00
|
|
|
import sys
|
2010-02-10 23:52:50 +01:00
|
|
|
# Manage Python2/3 different modules
|
2010-06-05 01:18:59 +02:00
|
|
|
# pylint: disable=F0401
|
2010-01-15 16:04:03 +01:00
|
|
|
try:
|
|
|
|
from configparser import RawConfigParser as ConfigParser
|
|
|
|
except ImportError:
|
|
|
|
from ConfigParser import RawConfigParser as ConfigParser
|
2010-06-05 01:18:59 +02:00
|
|
|
# pylint: enable=F0401
|
2008-12-30 16:25:42 +00:00
|
|
|
|
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Default configuration
|
|
|
|
INITIAL_CONFIG = {
|
2008-12-30 16:25:42 +00:00
|
|
|
"server": {
|
2011-04-02 21:49:48 +02:00
|
|
|
"hosts": "0.0.0.0:5232",
|
2010-01-18 10:48:06 +01:00
|
|
|
"daemon": "False",
|
2011-05-13 22:50:55 +02:00
|
|
|
"pid": "",
|
2010-01-19 17:49:32 +01:00
|
|
|
"ssl": "False",
|
|
|
|
"certificate": "/etc/apache2/ssl/server.crt",
|
2012-03-13 09:35:01 +01:00
|
|
|
"key": "/etc/apache2/ssl/server.key",
|
2013-12-13 14:31:09 +01:00
|
|
|
"protocol": "PROTOCOL_SSLv23",
|
2013-12-13 15:17:30 +01:00
|
|
|
"ciphers": "",
|
2012-10-22 12:44:42 +02:00
|
|
|
"dns_lookup": "True",
|
2013-06-28 16:39:09 +02:00
|
|
|
"base_prefix": "/",
|
|
|
|
"realm": "Radicale - Password Required"},
|
2008-12-30 16:25:42 +00:00
|
|
|
"encoding": {
|
|
|
|
"request": "utf-8",
|
2010-02-10 23:52:50 +01:00
|
|
|
"stock": "utf-8"},
|
2012-08-08 18:29:09 +02:00
|
|
|
"auth": {
|
2011-04-10 18:17:06 +02:00
|
|
|
"type": "None",
|
2013-12-28 13:31:32 +04:00
|
|
|
"custom_handler": "",
|
2012-08-08 16:37:18 +02:00
|
|
|
"htpasswd_filename": "/etc/radicale/users",
|
|
|
|
"htpasswd_encryption": "crypt",
|
2013-04-26 00:56:56 +02:00
|
|
|
"imap_hostname": "localhost",
|
|
|
|
"imap_port": "143",
|
|
|
|
"imap_ssl": "False",
|
2011-04-25 16:47:42 +02:00
|
|
|
"ldap_url": "ldap://localhost:389/",
|
|
|
|
"ldap_base": "ou=users,dc=example,dc=com",
|
2011-05-10 14:45:54 +02:00
|
|
|
"ldap_attribute": "uid",
|
2012-03-13 10:47:01 +01:00
|
|
|
"ldap_filter": "",
|
2011-05-10 14:45:54 +02:00
|
|
|
"ldap_binddn": "",
|
2011-10-24 18:02:40 +02:00
|
|
|
"ldap_password": "",
|
2011-11-29 12:54:38 +01:00
|
|
|
"ldap_scope": "OneLevel",
|
2011-10-24 18:02:40 +02:00
|
|
|
"pam_group_membership": "",
|
2013-04-26 01:14:33 +02:00
|
|
|
"courier_socket": "",
|
|
|
|
"http_url": "",
|
|
|
|
"http_user_parameter": "",
|
|
|
|
"http_password_parameter": ""},
|
2013-09-13 17:21:50 +02:00
|
|
|
"git": {
|
2013-09-25 13:04:14 +02:00
|
|
|
"committer": "Radicale <radicale@example.com>"},
|
2012-08-08 18:45:55 +02:00
|
|
|
"rights": {
|
2012-08-11 00:56:45 +02:00
|
|
|
"type": "None",
|
2013-12-29 15:13:35 +04:00
|
|
|
"custom_handler": "",
|
2013-08-14 10:50:59 +02:00
|
|
|
"file": "~/.config/radicale/rights"},
|
2010-02-10 23:52:50 +01:00
|
|
|
"storage": {
|
2012-01-12 02:18:06 +01:00
|
|
|
"type": "filesystem",
|
2013-12-28 14:15:35 +04:00
|
|
|
"custom_handler": "",
|
2012-08-08 16:37:18 +02:00
|
|
|
"filesystem_folder": os.path.expanduser(
|
|
|
|
"~/.config/radicale/collections"),
|
2013-04-20 12:51:32 +02:00
|
|
|
"database_url": ""},
|
2011-02-16 13:53:27 +01:00
|
|
|
"logging": {
|
2011-04-10 19:17:35 +02:00
|
|
|
"config": "/etc/radicale/logging",
|
2011-05-13 10:15:21 +02:00
|
|
|
"debug": "False",
|
|
|
|
"full_environment": "False"}}
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Create a ConfigParser and configure it
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER = ConfigParser()
|
2010-02-10 18:57:21 +01:00
|
|
|
|
|
|
|
for section, values in INITIAL_CONFIG.items():
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.add_section(section)
|
2010-01-15 16:04:03 +01:00
|
|
|
for key, value in values.items():
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.set(section, key, value)
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2010-02-10 23:52:50 +01:00
|
|
|
_CONFIG_PARSER.read("/etc/radicale/config")
|
2011-04-10 19:17:35 +02:00
|
|
|
_CONFIG_PARSER.read(os.path.expanduser("~/.config/radicale/config"))
|
2012-03-01 10:40:15 +01:00
|
|
|
if "RADICALE_CONFIG" in os.environ:
|
|
|
|
_CONFIG_PARSER.read(os.environ["RADICALE_CONFIG"])
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
# Wrap config module into ConfigParser instance
|
2010-02-10 23:52:50 +01:00
|
|
|
sys.modules[__name__] = _CONFIG_PARSER
|