summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Boddie <paul@boddie.org.uk>2014-09-14 17:37:30 (GMT)
committerPaul Boddie <paul@boddie.org.uk>2014-09-14 17:37:30 (GMT)
commitda6dcb7886488b2f797c89f2fa33001bef162425 (patch)
tree49c67854fc945b74d8b9760fdf00c30e09f6fdb3
parent69b068bafb25086299674b3c6c28e9141880cec6 (diff)
downloadpykolab-dev/boddie-new/combined.tar.gz
Handle apparent old-style and new-style Cyrus paths.dev/boddie-new/combined
-rw-r--r--pykolab/setup/services.py23
-rw-r--r--pykolab/setup/setup_imap.py6
-rw-r--r--share/templates/cyrus.conf.tpl8
-rw-r--r--share/templates/imapd.conf.tpl6
4 files changed, 31 insertions, 12 deletions
diff --git a/pykolab/setup/services.py b/pykolab/setup/services.py
index a836a5a..ae4eecd 100644
--- a/pykolab/setup/services.py
+++ b/pykolab/setup/services.py
@@ -142,6 +142,12 @@ def find_file(name, paths):
return full_path
return None
+def find_path(paths):
+ for path in paths:
+ if exists(path):
+ return path
+ return None
+
def readfile(filename):
f = open(filename)
try:
@@ -450,10 +456,7 @@ def have_mysql_process():
return have_process_with_file(pidfile)
def get_mysql_defaults():
- for path in '/etc/mysql/debian.cnf', '/etc/mysql/my.cnf', '/etc/my.cnf':
- if exists(path):
- return path
- return None
+ return find_path(['/etc/mysql/debian.cnf', '/etc/mysql/my.cnf', '/etc/my.cnf'])
def make_mysql_defaults_file(defaults_file):
utils.multiline_message(
@@ -489,6 +492,18 @@ def have_cyrus_imapd():
def have_dovecot_imapd():
return exists('/etc/dovecot')
+def get_cyrus_config_base():
+ return find_path(['/var/lib/imap', '/var/lib/cyrus'])
+
+def get_cyrus_spool_base():
+ return find_path(['/var/spool/imap', '/var/spool/cyrus'])
+
+def get_cyrus_sieve_base():
+ return find_path(['/var/lib/imap/sieve', '/var/spool/sieve'])
+
+def get_cyrus_socket_base():
+ return find_path(['/var/lib/imap/socket', '/var/run/cyrus/socket'])
+
# LDAP-related functions.
def have_slapd():
diff --git a/pykolab/setup/setup_imap.py b/pykolab/setup/setup_imap.py
index e3b5563..5cf60a9 100644
--- a/pykolab/setup/setup_imap.py
+++ b/pykolab/setup/setup_imap.py
@@ -167,6 +167,10 @@ def _execute(*args, **kw):
def get_imap_settings():
return {
+ "imap_config_dir": get_cyrus_config_base(),
+ "imap_spool_dir": get_cyrus_spool_base(),
+ "imap_sieve_dir": get_cyrus_sieve_base(),
+ "imap_socket_dir": get_cyrus_socket_base(),
"ldap_servers": conf.get('ldap', 'ldap_uri'),
"ldap_host": get_host_from_url(conf.get('ldap', 'ldap_uri')),
"ldap_base": conf.get('ldap', 'base_dn'),
@@ -198,7 +202,7 @@ def configure_cyrus_imapd(imapd_settings):
for template_basename, output_file, settings in [
('imapd.conf.tpl', '/etc/imapd.conf', [imapd_settings]),
- ('cyrus.conf.tpl', '/etc/cyrus.conf', [{}])
+ ('cyrus.conf.tpl', '/etc/cyrus.conf', [imapd_settings])
]:
template_file = get_template_path(template_basename)
diff --git a/share/templates/cyrus.conf.tpl b/share/templates/cyrus.conf.tpl
index 9a4a17a..acb1483 100644
--- a/share/templates/cyrus.conf.tpl
+++ b/share/templates/cyrus.conf.tpl
@@ -8,7 +8,7 @@ START {
idled cmd="idled"
}
-# UNIX sockets start with a slash and are put into /var/lib/imap/sockets
+# UNIX sockets start with a slash and are put into $imap_socket_dir
SERVICES {
# add or remove based on preferences
imap cmd="imapd" listen="imap" prefork=5
@@ -17,7 +17,7 @@ SERVICES {
pop3s cmd="pop3d -s" listen="pop3s" prefork=1
sieve cmd="timsieved" listen="sieve" prefork=0
- ptloader cmd="ptloader" listen="/var/lib/imap/ptclient/ptsock" prefork=0
+ ptloader cmd="ptloader" listen="$imap_socket_dir/ptsock" prefork=0
# these are only necessary if receiving/exporting usenet via NNTP
#nntp cmd="nntpd" listen="nntp" prefork=3
@@ -25,10 +25,10 @@ SERVICES {
# at least one LMTP is required for delivery
#lmtp cmd="lmtpd" listen="lmtp" prefork=0
- lmtpunix cmd="lmtpd" listen="/var/lib/imap/socket/lmtp" prefork=1
+ lmtpunix cmd="lmtpd" listen="$imap_socket_dir/lmtp" prefork=1
# this is only necessary if using notifications
- notify cmd="notifyd" listen="/var/lib/imap/socket/notify" proto="udp" prefork=1
+ notify cmd="notifyd" listen="$imap_socket_dir/notify" proto="udp" prefork=1
}
EVENTS {
diff --git a/share/templates/imapd.conf.tpl b/share/templates/imapd.conf.tpl
index 874e55a..d029457 100644
--- a/share/templates/imapd.conf.tpl
+++ b/share/templates/imapd.conf.tpl
@@ -1,7 +1,7 @@
-configdirectory: /var/lib/imap
-partition-default: /var/spool/imap
+configdirectory: $imap_config_dir
+partition-default: $imap_spool_dir
admins: $admins
-sievedir: /var/lib/imap/sieve
+sievedir: $imap_sieve_dir
sendmail: /usr/sbin/sendmail
sasl_pwcheck_method: auxprop saslauthd
sasl_mech_list: PLAIN LOGIN