2008-12-30 16:25:42 +00:00
|
|
|
# This file is part of Radicale Server - Calendar Server
|
2016-03-31 19:57:40 +02:00
|
|
|
# Copyright © 2008-2016 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
|
2016-03-31 19:57:40 +02:00
|
|
|
from configparser import RawConfigParser as ConfigParser
|
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": "",
|
2016-06-10 14:36:44 +02:00
|
|
|
"max_connections": "20",
|
2016-06-10 14:34:52 +02:00
|
|
|
"max_content_length": "10000000",
|
2016-06-10 14:33:25 +02:00
|
|
|
"timeout": "10",
|
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": "/",
|
2014-08-06 11:51:11 +02:00
|
|
|
"can_skip_base_prefix": "False",
|
2013-06-28 16:39:09 +02:00
|
|
|
"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",
|
2012-08-08 16:37:18 +02:00
|
|
|
"htpasswd_filename": "/etc/radicale/users",
|
2016-04-07 19:02:52 +02:00
|
|
|
"htpasswd_encryption": "crypt"},
|
2012-08-08 18:45:55 +02:00
|
|
|
"rights": {
|
2012-08-11 00:56:45 +02:00
|
|
|
"type": "None",
|
2013-08-14 10:50:59 +02:00
|
|
|
"file": "~/.config/radicale/rights"},
|
2010-02-10 23:52:50 +01:00
|
|
|
"storage": {
|
2016-04-07 19:02:52 +02:00
|
|
|
"type": "multifilesystem",
|
2012-08-08 16:37:18 +02:00
|
|
|
"filesystem_folder": os.path.expanduser(
|
2016-06-11 10:34:18 +02:00
|
|
|
"~/.config/radicale/collections"),
|
2016-08-08 05:17:41 +02:00
|
|
|
"fsync": "True",
|
2016-08-11 03:34:08 +02:00
|
|
|
"hook": "",
|
|
|
|
"close_lock_file": "False"},
|
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",
|
2016-06-11 12:53:58 +02:00
|
|
|
"full_environment": "False",
|
|
|
|
"mask_passwords": "True"}}
|
2008-12-30 16:25:42 +00:00
|
|
|
|
2010-02-10 18:57:21 +01:00
|
|
|
|
2016-07-05 17:50:40 +02:00
|
|
|
def load(paths=(), extra_config=None):
|
2016-04-22 11:37:02 +09:00
|
|
|
config = ConfigParser()
|
|
|
|
for section, values in INITIAL_CONFIG.items():
|
|
|
|
config.add_section(section)
|
|
|
|
for key, value in values.items():
|
|
|
|
config.set(section, key, value)
|
2016-07-05 17:50:40 +02:00
|
|
|
if extra_config:
|
|
|
|
for section, values in extra_config.items():
|
|
|
|
for key, value in values.items():
|
|
|
|
config.set(section, key, value)
|
2016-04-22 11:37:02 +09:00
|
|
|
for path in paths:
|
|
|
|
if path:
|
|
|
|
config.read(path)
|
|
|
|
return config
|