mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add setting to configure pop3 for dovecot
This commit is contained in:
parent
b5c38bf031
commit
83b4be5345
4 changed files with 36 additions and 7 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
do_pre_regen() {
|
do_pre_regen() {
|
||||||
pending_dir=$1
|
pending_dir=$1
|
||||||
|
|
||||||
|
@ -14,11 +16,10 @@ do_pre_regen() {
|
||||||
cp dovecot-ldap.conf "${dovecot_dir}/dovecot-ldap.conf"
|
cp dovecot-ldap.conf "${dovecot_dir}/dovecot-ldap.conf"
|
||||||
cp dovecot.sieve "${dovecot_dir}/global_script/dovecot.sieve"
|
cp dovecot.sieve "${dovecot_dir}/global_script/dovecot.sieve"
|
||||||
|
|
||||||
# prepare dovecot.conf conf file
|
export pop3_enabled="$(yunohost settings get 'pop3.enabled')"
|
||||||
main_domain=$(cat /etc/yunohost/current_host)
|
export main_domain=$(cat /etc/yunohost/current_host)
|
||||||
cat dovecot.conf \
|
|
||||||
| sed "s/{{ main_domain }}/${main_domain}/g" \
|
ynh_render_template "dovecot.conf" "${dovecot_dir}/dovecot.conf"
|
||||||
> "${dovecot_dir}/dovecot.conf"
|
|
||||||
|
|
||||||
# adapt it for IPv4-only hosts
|
# adapt it for IPv4-only hosts
|
||||||
if [ ! -f /proc/net/if_inet6 ]; then
|
if [ ! -f /proc/net/if_inet6 ]; then
|
||||||
|
|
|
@ -8,11 +8,10 @@ mail_home = /var/mail/%n
|
||||||
mail_location = maildir:/var/mail/%n
|
mail_location = maildir:/var/mail/%n
|
||||||
mail_uid = 500
|
mail_uid = 500
|
||||||
|
|
||||||
protocols = imap sieve
|
protocols = imap sieve {% if pop3_enabled == "True" %}pop3{% endif %}
|
||||||
|
|
||||||
mail_plugins = $mail_plugins quota
|
mail_plugins = $mail_plugins quota
|
||||||
|
|
||||||
|
|
||||||
ssl = yes
|
ssl = yes
|
||||||
ssl_cert = </etc/yunohost/certs/{{ main_domain }}/crt.pem
|
ssl_cert = </etc/yunohost/certs/{{ main_domain }}/crt.pem
|
||||||
ssl_key = </etc/yunohost/certs/{{ main_domain }}/key.pem
|
ssl_key = </etc/yunohost/certs/{{ main_domain }}/key.pem
|
||||||
|
|
|
@ -263,6 +263,7 @@
|
||||||
"global_settings_cant_write_settings": "Could not save settings file, reason: {reason:s}",
|
"global_settings_cant_write_settings": "Could not save settings file, reason: {reason:s}",
|
||||||
"global_settings_key_doesnt_exists": "The key '{settings_key:s}' does not exist in the global settings, you can see all the available keys by running 'yunohost settings list'",
|
"global_settings_key_doesnt_exists": "The key '{settings_key:s}' does not exist in the global settings, you can see all the available keys by running 'yunohost settings list'",
|
||||||
"global_settings_reset_success": "Previous settings now backed up to {path:s}",
|
"global_settings_reset_success": "Previous settings now backed up to {path:s}",
|
||||||
|
"global_settings_setting_pop3_enabled": "Enable the POP3 protocol for the mail server",
|
||||||
"global_settings_setting_example_bool": "Example boolean option",
|
"global_settings_setting_example_bool": "Example boolean option",
|
||||||
"global_settings_setting_example_enum": "Example enum option",
|
"global_settings_setting_example_enum": "Example enum option",
|
||||||
"global_settings_setting_example_int": "Example int option",
|
"global_settings_setting_example_int": "Example int option",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -46,6 +47,7 @@ DEFAULTS = OrderedDict([
|
||||||
"choices": ["intermediate", "modern"]}),
|
"choices": ["intermediate", "modern"]}),
|
||||||
("security.postfix.compatibility", {"type": "enum", "default": "intermediate",
|
("security.postfix.compatibility", {"type": "enum", "default": "intermediate",
|
||||||
"choices": ["intermediate", "modern"]}),
|
"choices": ["intermediate", "modern"]}),
|
||||||
|
("pop3.enabled", {"type": "bool", "default": False}),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,3 +301,29 @@ def reconfigure_ssh(setting_name, old_value, new_value):
|
||||||
def reconfigure_ssh(setting_name, old_value, new_value):
|
def reconfigure_ssh(setting_name, old_value, new_value):
|
||||||
if old_value != new_value:
|
if old_value != new_value:
|
||||||
service_regen_conf(names=['postfix'])
|
service_regen_conf(names=['postfix'])
|
||||||
|
|
||||||
|
@post_change_hook("pop3.enabled")
|
||||||
|
def reconfigure_dovecot(setting_name, old_value, new_value):
|
||||||
|
dovecot_package = 'dovecot-pop3d'
|
||||||
|
|
||||||
|
environment = os.environ.copy()
|
||||||
|
environment.update({'DEBIAN_FRONTEND': 'noninteractive'})
|
||||||
|
|
||||||
|
if new_value == "True":
|
||||||
|
command = [
|
||||||
|
'apt-get',
|
||||||
|
'-y',
|
||||||
|
'--no-remove',
|
||||||
|
'-o Dpkg::Options::=--force-confdef',
|
||||||
|
'-o Dpkg::Options::=--force-confold',
|
||||||
|
'install',
|
||||||
|
dovecot_package,
|
||||||
|
]
|
||||||
|
subprocess.call(command, env=environment)
|
||||||
|
if old_value != new_value:
|
||||||
|
service_regen_conf(names=['dovecot'])
|
||||||
|
else:
|
||||||
|
if old_value != new_value:
|
||||||
|
service_regen_conf(names=['dovecot'])
|
||||||
|
command = ['apt-get', '-y', 'remove', dovecot_package]
|
||||||
|
subprocess.call(command, env=environment)
|
||||||
|
|
Loading…
Add table
Reference in a new issue