install_update_dovecot-2.4.sh: another imtermediate update
This commit is contained in:
@ -274,6 +274,98 @@ replace_or_append_code_block() {
|
||||
return 0
|
||||
}
|
||||
|
||||
replace_or_append_code_block_if_keyval() {
|
||||
local block_name="$1"
|
||||
local new_block="$2"
|
||||
local file="$3"
|
||||
local required_key="$4"
|
||||
local required_value="$5"
|
||||
|
||||
if [[ -z "$block_name" || -z "$new_block" || -z "$file" || -z "$required_key" || -z "$required_value" ]]; then
|
||||
echo "Fehler: Parameter fehlen."
|
||||
echo "Verwendung: replace_or_append_code_block_if_keyval \"blockname\" \"neuer_block\" \"/pfad/zur/datei\" \"key\" \"value\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Fehler: Datei '$file' existiert nicht."
|
||||
return 2
|
||||
fi
|
||||
|
||||
local tmp_file
|
||||
tmp_file=$(mktemp)
|
||||
|
||||
local block_found=0
|
||||
|
||||
awk -v block_name="$block_name" -v new_block="$new_block" \
|
||||
-v req_key="$required_key" -v req_val="$required_value" '
|
||||
function count_char(str, c) {
|
||||
n = 0
|
||||
for (i = 1; i <= length(str); i++) {
|
||||
if (substr(str, i, 1) == c) n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
{
|
||||
if (!in_block && $0 ~ "^\\s*" block_name "\\s*\\{") {
|
||||
in_block = 1
|
||||
brace_depth = count_char($0, "{") - count_char($0, "}")
|
||||
block_buffer = $0 "\n"
|
||||
found_keyval = 0
|
||||
next
|
||||
}
|
||||
|
||||
if (in_block) {
|
||||
brace_depth += count_char($0, "{") - count_char($0, "}")
|
||||
block_buffer = block_buffer $0 "\n"
|
||||
|
||||
# Prüfe nur im obersten Block-Level auf key = value
|
||||
if (brace_depth == 1 && $0 ~ "^\\s*" req_key "\\s*=\\s*" req_val "\\s*$") {
|
||||
found_keyval = 1
|
||||
}
|
||||
|
||||
if (brace_depth <= 0) {
|
||||
in_block = 0
|
||||
if (found_keyval) {
|
||||
print new_block
|
||||
block_found = 1
|
||||
} else {
|
||||
printf "%s", block_buffer
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
print
|
||||
}
|
||||
|
||||
END {
|
||||
if (!block_found) {
|
||||
print new_block > "/dev/stderr"
|
||||
exit 3
|
||||
}
|
||||
}
|
||||
' "$file" 1>"$tmp_file" 2>_new_block_to_append.tmp
|
||||
|
||||
result=$?
|
||||
|
||||
if [[ $result -eq 3 ]]; then
|
||||
echo "" >> "$file"
|
||||
cat _new_block_to_append.tmp >> "$file"
|
||||
rm -f "$tmp_file" _new_block_to_append.tmp
|
||||
echo "Block '$block_name' wurde nicht gefunden oder Bedingung nicht erfüllt – daher am Ende angehängt."
|
||||
return 0
|
||||
fi
|
||||
|
||||
mv "$tmp_file" "$file"
|
||||
rm -f _new_block_to_append.tmp
|
||||
echo "Block '$block_name' wurde ersetzt (Bedingung erfüllt)."
|
||||
return 0
|
||||
}
|
||||
|
||||
delete_code_block() {
|
||||
local block_name="$1"
|
||||
local file="$2"
|
||||
@ -1197,6 +1289,98 @@ replace_or_append_code_block() {
|
||||
return 0
|
||||
}
|
||||
|
||||
replace_or_append_code_block_if_keyval() {
|
||||
local block_name="$1"
|
||||
local new_block="$2"
|
||||
local file="$3"
|
||||
local required_key="$4"
|
||||
local required_value="$5"
|
||||
|
||||
if [[ -z "$block_name" || -z "$new_block" || -z "$file" || -z "$required_key" || -z "$required_value" ]]; then
|
||||
echo "Fehler: Parameter fehlen."
|
||||
echo "Verwendung: replace_or_append_code_block_if_keyval \"blockname\" \"neuer_block\" \"/pfad/zur/datei\" \"key\" \"value\""
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$file" ]]; then
|
||||
echo "Fehler: Datei '$file' existiert nicht."
|
||||
return 2
|
||||
fi
|
||||
|
||||
local tmp_file
|
||||
tmp_file=$(mktemp)
|
||||
|
||||
local block_found=0
|
||||
|
||||
awk -v block_name="$block_name" -v new_block="$new_block" \
|
||||
-v req_key="$required_key" -v req_val="$required_value" '
|
||||
function count_char(str, c) {
|
||||
n = 0
|
||||
for (i = 1; i <= length(str); i++) {
|
||||
if (substr(str, i, 1) == c) n++
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
{
|
||||
if (!in_block && $0 ~ "^\\s*" block_name "\\s*\\{") {
|
||||
in_block = 1
|
||||
brace_depth = count_char($0, "{") - count_char($0, "}")
|
||||
block_buffer = $0 "\n"
|
||||
found_keyval = 0
|
||||
next
|
||||
}
|
||||
|
||||
if (in_block) {
|
||||
brace_depth += count_char($0, "{") - count_char($0, "}")
|
||||
block_buffer = block_buffer $0 "\n"
|
||||
|
||||
# Prüfe nur im obersten Block-Level auf key = value
|
||||
if (brace_depth == 1 && $0 ~ "^\\s*" req_key "\\s*=\\s*" req_val "\\s*$") {
|
||||
found_keyval = 1
|
||||
}
|
||||
|
||||
if (brace_depth <= 0) {
|
||||
in_block = 0
|
||||
if (found_keyval) {
|
||||
print new_block
|
||||
block_found = 1
|
||||
} else {
|
||||
printf "%s", block_buffer
|
||||
}
|
||||
next
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
|
||||
print
|
||||
}
|
||||
|
||||
END {
|
||||
if (!block_found) {
|
||||
print new_block > "/dev/stderr"
|
||||
exit 3
|
||||
}
|
||||
}
|
||||
' "$file" 1>"$tmp_file" 2>_new_block_to_append.tmp
|
||||
|
||||
result=$?
|
||||
|
||||
if [[ $result -eq 3 ]]; then
|
||||
echo "" >> "$file"
|
||||
cat _new_block_to_append.tmp >> "$file"
|
||||
rm -f "$tmp_file" _new_block_to_append.tmp
|
||||
echo "Block '$block_name' wurde nicht gefunden oder Bedingung nicht erfüllt – daher am Ende angehängt."
|
||||
return 0
|
||||
fi
|
||||
|
||||
mv "$tmp_file" "$file"
|
||||
rm -f _new_block_to_append.tmp
|
||||
echo "Block '$block_name' wurde ersetzt (Bedingung erfüllt)."
|
||||
return 0
|
||||
}
|
||||
|
||||
delete_code_block() {
|
||||
local block_name="$1"
|
||||
local file="$2"
|
||||
@ -2436,7 +2620,7 @@ if [[ $dovecot_major_version -gt 2 ]] \
|
||||
_key_file="/etc/dovecot/ssl/mailserver.key"
|
||||
_ssl_server_block="ssl_server {\n ssl = yes\n cert_file = ${_cert_file}\n key_file = ${_key_file}\n}"
|
||||
|
||||
echononl " Adjust file dovecot.conf.."
|
||||
echononl " Adjust file $(basename "${_conf_file}").."
|
||||
|
||||
# # Delete all lines that begin with !include and also delete the following line
|
||||
# # if it is empty or contains only whitespace.
|
||||
@ -4364,15 +4548,268 @@ blank_line
|
||||
# modify /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
#
|
||||
#
|
||||
_failed=false
|
||||
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf"
|
||||
if [[ $dovecot_major_version -gt 2 ]] \
|
||||
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
|
||||
|
||||
echononl " Modify file '10-mail.conf'.."
|
||||
echo -e "$rc_not_yet_implemented"
|
||||
echononl " Modify file '$(basename "${_conf_file}")'.."
|
||||
|
||||
# modify /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
#
|
||||
# namespace inbox {
|
||||
# type = private
|
||||
# separator = /
|
||||
# hidden = no
|
||||
# list = yes
|
||||
# subscriptions = yes
|
||||
# }
|
||||
|
||||
if grep -qE "^\s*namespace\s+inbox\s*{" "${_conf_file}"; then
|
||||
|
||||
read -r -d '' NEW_BLOCK <<EOF
|
||||
namespace inbox {
|
||||
# The namespace type. One of:
|
||||
#
|
||||
# public Contains public shared mailboxes.
|
||||
# private Typically contains only user's own private mailboxes.
|
||||
# shared Contains other users' user shared mailboxes.
|
||||
#
|
||||
# Default: private
|
||||
type = private
|
||||
|
||||
# Specifies the hierarchy separator for the namespace.
|
||||
#
|
||||
# Default: "." for Maildir; "/" for other mbox formats
|
||||
#
|
||||
# The separator is a single character, which can't then otherwise be used in folder names.
|
||||
# The commonly used separators are . and /, but other separators can be used as well. For
|
||||
# example ^ is less likely to be found in normal folder names.
|
||||
#
|
||||
# Recommended value is to leave it empty and accept the default value.
|
||||
separator = /
|
||||
|
||||
# Specifies prefix for namespace.
|
||||
#
|
||||
# Must end with namespace_separator.
|
||||
#
|
||||
# Default: [none]
|
||||
#prefix =
|
||||
|
||||
# If yes, this namespace will be considered the one holding the INBOX folder.
|
||||
#
|
||||
# There can be only one namespace defined like this.
|
||||
inbox = yes
|
||||
|
||||
# If yes, namespace will be hidden from IMAP NAMESPACE (RFC 2342) command.
|
||||
hidden = no
|
||||
|
||||
# Include this namespace in LIST output when listing its parent's folders.
|
||||
#
|
||||
# One of:
|
||||
# children Namespace prefix list listed only if it has child mailboxes.
|
||||
#
|
||||
# no Namespace and mailboxes not listed unless listing requests explicitly
|
||||
# mailboxes under the namespace prefix.
|
||||
#
|
||||
# yes Namespace and mailboxes are always listed.
|
||||
#
|
||||
# It is still possible to list the namespace's folders by explicitly asking for them.
|
||||
# For example, if this setting is no, using LIST "" * with namespace prefix "lazy-expunge/"
|
||||
# won't list it, but using LIST "" lazy-expunge/* lists all folders under it.
|
||||
#
|
||||
# Default: yes
|
||||
list = yes
|
||||
|
||||
# Whether subscriptions are stored in this namespace.
|
||||
#
|
||||
# This is usually no for shared namespaces so that the shared folders' subscriptions are
|
||||
# stored in the user's primary subscriptions file. If no, the subscriptions are stored in
|
||||
# the first parent namespace (based on the prefix) that has this setting enabled.
|
||||
#
|
||||
# Example: If this setting is no for a namespace with prefix=foo/bar/, Dovecot first sees
|
||||
# if there's a prefix=foo/ namespace with subscriptions=yes and then a namespace with an
|
||||
# empty prefix. If neither is found, an error is given.
|
||||
#
|
||||
# Default: yes
|
||||
subscriptions = yes
|
||||
}
|
||||
EOF
|
||||
replace_or_append_code_block "namespace inbox" "${NEW_BLOCK}" "${_conf_file}" >> "${log_file}" 2>&1
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
cat <<EOF >> "${_conf_file}" 2> "${log_file}"
|
||||
|
||||
# Namespaces
|
||||
#
|
||||
# Dovecot supports fully configurable, hierarchical namespaces, which can use different storage drivers.
|
||||
#
|
||||
# Their original and primary purpose is to provide Namespace IMAP extension (RFC 2342) support, which
|
||||
# allows giving IMAP clients hints about where to locate mailboxes and whether they're private, shared
|
||||
# or public.
|
||||
#
|
||||
# Dovecot namespaces can be used for several other purposes too:
|
||||
#
|
||||
# Changing the Hierarchy Separators
|
||||
# Providing backwards compatibility when switching from another IMAP server
|
||||
# Provides support for public shared mailboxes and user shared mailboxes mailboxes
|
||||
# Allows having mails in multiple different locations with possibly different formats
|
||||
#
|
||||
# These different locations and drivers are presented to the client as a single tree.
|
||||
#
|
||||
# Each namespace has:
|
||||
#
|
||||
# prefix (usually empty or "INBOX.")
|
||||
# namespace separator (usually '/' or '.')
|
||||
# 0 or more folders
|
||||
#
|
||||
# There must be one namespace where the case-insensitive folder named INBOX exists.
|
||||
#
|
||||
# All visible namespaces must have the same separator.
|
||||
#
|
||||
# Inside each namespace there is a list of folders, which form a sub-hierarchy.
|
||||
namespace inbox {
|
||||
# The namespace type. One of:
|
||||
#
|
||||
# public Contains public shared mailboxes.
|
||||
# private Typically contains only user's own private mailboxes.
|
||||
# shared Contains other users' user shared mailboxes.
|
||||
#
|
||||
# Default: private
|
||||
type = private
|
||||
|
||||
# Specifies the hierarchy separator for the namespace.
|
||||
#
|
||||
# Default: "." for Maildir; "/" for other mbox formats
|
||||
#
|
||||
# The separator is a single character, which can't then otherwise be used in folder names.
|
||||
# The commonly used separators are . and /, but other separators can be used as well. For
|
||||
# example ^ is less likely to be found in normal folder names.
|
||||
#
|
||||
# Recommended value is to leave it empty and accept the default value.
|
||||
separator = /
|
||||
|
||||
# Specifies prefix for namespace.
|
||||
#
|
||||
# Must end with namespace_separator.
|
||||
#prefix =
|
||||
|
||||
# If yes, this namespace will be considered the one holding the INBOX folder.
|
||||
#
|
||||
# There can be only one namespace defined like this.
|
||||
inbox = yes
|
||||
|
||||
# If yes, namespace will be hidden from IMAP NAMESPACE (RFC 2342) command.
|
||||
hidden = no
|
||||
|
||||
# Include this namespace in LIST output when listing its parent's folders.
|
||||
#
|
||||
# One of:
|
||||
# children Namespace prefix list listed only if it has child mailboxes.
|
||||
#
|
||||
# no Namespace and mailboxes not listed unless listing requests explicitly
|
||||
# mailboxes under the namespace prefix.
|
||||
#
|
||||
# yes Namespace and mailboxes are always listed.
|
||||
#
|
||||
# It is still possible to list the namespace's folders by explicitly asking for them.
|
||||
# For example, if this setting is no, using LIST "" * with namespace prefix "lazy-expunge/"
|
||||
# won't list it, but using LIST "" lazy-expunge/* lists all folders under it.
|
||||
#
|
||||
# Default: yes
|
||||
list = yes
|
||||
|
||||
# Whether subscriptions are stored in this namespace.
|
||||
#
|
||||
# This is usually no for shared namespaces so that the shared folders' subscriptions are
|
||||
# stored in the user's primary subscriptions file. If no, the subscriptions are stored in
|
||||
# the first parent namespace (based on the prefix) that has this setting enabled.
|
||||
#
|
||||
# Example: If this setting is no for a namespace with prefix=foo/bar/, Dovecot first sees
|
||||
# if there's a prefix=foo/ namespace with subscriptions=yes and then a namespace with an
|
||||
# empty prefix. If neither is found, an error is given.
|
||||
#
|
||||
# Default: yes
|
||||
subscriptions = yes
|
||||
}
|
||||
EOF
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
fi # if grep -qE "^\s*namespace\s+inbox\s*{" "${_conf_file}"; then
|
||||
|
||||
read -r -d '' NEW_BLOCK <<EOF
|
||||
|
||||
namespace shared {
|
||||
type = shared
|
||||
separator = /
|
||||
|
||||
# Mailboxes are visible under "shared/user@domain/"
|
||||
# %%n, %%d and %%u are expanded to the destination user.
|
||||
prefix = shared/%%u/
|
||||
|
||||
# Mail location setting
|
||||
mail_home = /var/vmail/%{user | domain}/%{user | username}
|
||||
mail_driver = Maildir
|
||||
mail_path = mail_path = ~/Maildir
|
||||
mail_index_private_path = ~/Maildir/shared/%{owner_user}
|
||||
|
||||
# Use the default namespace for saving subscriptions.
|
||||
subscriptions = no
|
||||
|
||||
# Include this namespace in LIST output when listing its parent's folders.
|
||||
#
|
||||
# One of:
|
||||
# children Namespace prefix list listed only if it has child mailboxes.
|
||||
#
|
||||
# no Namespace and mailboxes not listed unless listing requests explicitly
|
||||
# mailboxes under the namespace prefix.
|
||||
#
|
||||
# yes Namespace and mailboxes are always listed.
|
||||
#
|
||||
# It is still possible to list the namespace's folders by explicitly asking for them.
|
||||
# For example, if this setting is no, using LIST "" * with namespace prefix "lazy-expunge/"
|
||||
# won't list it, but using LIST "" lazy-expunge/* lists all folders under it.
|
||||
#
|
||||
# Default: yes
|
||||
list = children
|
||||
}
|
||||
EOF
|
||||
|
||||
# Replace or expand only if namespace block contains "type = value"
|
||||
#
|
||||
replace_or_append_code_block "namespace" "${NEW_BLOCK}" "${_conf_file}" "type" "shared" >> "${log_file}" 2>&1
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
if ! $_failed ; then
|
||||
echo -e "$rc_done"
|
||||
else
|
||||
echo -e "$rc_failed"
|
||||
error "Adjusting Adjusting file ${_conf_file} failed"
|
||||
error "$(cat "${log_file}")"
|
||||
|
||||
echo ""
|
||||
echononl "continue anyway [yes/no]: "
|
||||
read OK
|
||||
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||
echononl "Wrong entry! - repeat [yes/no]: "
|
||||
read OK
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal "Interupted by user"
|
||||
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
echononl " Modify file '10-mail.conf'.."
|
||||
echononl " Modify file '$(basename "${_conf_file}")'.."
|
||||
|
||||
## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
## -
|
||||
@ -4384,126 +4821,278 @@ else
|
||||
## - ..
|
||||
## - }
|
||||
## -
|
||||
_failed=false
|
||||
_found=false
|
||||
_tmp_file="$(mktemp)"
|
||||
> $_tmp_file
|
||||
while IFS='' read -r _line || [[ -n $_line ]] ; do
|
||||
|
||||
if echo "$_line" | grep -i -E "^\s*namespace\s+inbox\s+" > /dev/null 2>&1 ; then
|
||||
echo "## $_line" >> $_tmp_file
|
||||
_found=true
|
||||
continue
|
||||
fi
|
||||
|
||||
if $_found && echo "$_line" | grep -i -E "^\s*}" > /dev/null 2>&1 ; then
|
||||
echo "## $_line" >> $_tmp_file
|
||||
_found=false
|
||||
continue
|
||||
fi
|
||||
|
||||
if $_found ; then
|
||||
echo "## $_line" >> $_tmp_file
|
||||
else
|
||||
echo "$_line" >> $_tmp_file
|
||||
fi
|
||||
done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf"
|
||||
if [[ "$?" != "0" ]] ; then
|
||||
_failed=true
|
||||
fi
|
||||
mv /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf \
|
||||
/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf.TMP
|
||||
if [[ "$?" != "0" ]] ; then
|
||||
_failed=true
|
||||
fi
|
||||
mv $_tmp_file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
if [[ "$?" != "0" ]] ; then
|
||||
_failed=true
|
||||
fi
|
||||
chmod 644 /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
if [[ "$?" != "0" ]] ; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
|
||||
#perl -i -n -p -e "s#^([ ]*)(namespace\ +inbox\ +{\ *)#\1\#\#\ \2#g" \
|
||||
# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
#perl -i -n -p -e "s#^([ ]*)(inbox\ +=\ +yes\ *)#\1\#\#\ \2#g" \
|
||||
# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
#perl -i -n -p -e "s#^([ ]*)(}\ *)#\1\#\#\ \2#g" \
|
||||
# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
|
||||
if ! $_failed ; then
|
||||
echo -e "$rc_done"
|
||||
else
|
||||
echo -e "$rc_failed"
|
||||
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed"
|
||||
fi
|
||||
# _tmp_file="$(mktemp)"
|
||||
# > $_tmp_file
|
||||
# while IFS='' read -r _line || [[ -n $_line ]] ; do
|
||||
#
|
||||
# if echo "$_line" | grep -i -E "^\s*namespace\s+inbox\s+" > /dev/null 2>&1 ; then
|
||||
# echo "## $_line" >> $_tmp_file
|
||||
# _found=true
|
||||
# continue
|
||||
# fi
|
||||
#
|
||||
# if $_found && echo "$_line" | grep -i -E "^\s*}" > /dev/null 2>&1 ; then
|
||||
# echo "## $_line" >> $_tmp_file
|
||||
# _found=false
|
||||
# continue
|
||||
# fi
|
||||
#
|
||||
# if $_found ; then
|
||||
# echo "## $_line" >> $_tmp_file
|
||||
# else
|
||||
# echo "$_line" >> $_tmp_file
|
||||
# fi
|
||||
# done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf"
|
||||
# if [[ "$?" != "0" ]] ; then
|
||||
# _failed=true
|
||||
# fi
|
||||
# mv /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf \
|
||||
# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf.TMP
|
||||
# if [[ "$?" != "0" ]] ; then
|
||||
# _failed=true
|
||||
# fi
|
||||
# mv $_tmp_file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
# if [[ "$?" != "0" ]] ; then
|
||||
# _failed=true
|
||||
# fi
|
||||
# chmod 644 /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
# if [[ "$?" != "0" ]] ; then
|
||||
# _failed=true
|
||||
# fi
|
||||
#
|
||||
#
|
||||
# #perl -i -n -p -e "s#^([ ]*)(namespace\ +inbox\ +{\ *)#\1\#\#\ \2#g" \
|
||||
# # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
# #perl -i -n -p -e "s#^([ ]*)(inbox\ +=\ +yes\ *)#\1\#\#\ \2#g" \
|
||||
# # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
# #perl -i -n -p -e "s#^([ ]*)(}\ *)#\1\#\#\ \2#g" \
|
||||
# # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true
|
||||
#
|
||||
# if ! $_failed ; then
|
||||
# echo -e "$rc_done"
|
||||
# else
|
||||
# echo -e "$rc_failed"
|
||||
# fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed"
|
||||
# fi
|
||||
|
||||
|
||||
## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
## -
|
||||
## - Add namespaces type private
|
||||
## - Add or Replace 'namespace inbox' type private
|
||||
## -
|
||||
## - Add:
|
||||
## - namespace inbox {
|
||||
## - type = private
|
||||
## - separator = /
|
||||
## - prefix =
|
||||
## - inbox = yes
|
||||
## - }
|
||||
## - namespace inbox {
|
||||
## - # Namespace type: private, shared or public
|
||||
## - type = private
|
||||
## -
|
||||
echononl " Add namespaces type private to file 10-mail.conf"
|
||||
cat <<EOF >> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
## - # Hierarchy separator to use. You should use the same separator for all
|
||||
## - # namespaces or some clients get confused. '/' is usually a good one.
|
||||
## - # The default however depends on the underlying mail storage format.
|
||||
## - #separator =
|
||||
## - separator = /
|
||||
## -
|
||||
## - # Prefix required to access this namespace. This needs to be different for
|
||||
## - # all namespaces. For example "Public/".
|
||||
## - #prefix =
|
||||
## - prefix =
|
||||
## -
|
||||
## - # Physical location of the mailbox. This is in same format as
|
||||
## - # mail_location, which is also the default for it.
|
||||
## - #location =
|
||||
## -
|
||||
## - # There can be only one INBOX, and this setting defines which namespace
|
||||
## - # has it.
|
||||
## - #inbox = no
|
||||
## - inbox = yes
|
||||
## -
|
||||
## - # If namespace is hidden, it's not advertised to clients via NAMESPACE
|
||||
## - # extension. You'll most likely also want to set list=no. This is mostly
|
||||
## - # useful when converting from another server with different namespaces which
|
||||
## - # you want to deprecate but still keep working. For example you can create
|
||||
## - # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
|
||||
## - #hidden = no
|
||||
## -
|
||||
## - # Show the mailboxes under this namespace with LIST command. This makes the
|
||||
## - # namespace visible for clients that don't support NAMESPACE extension.
|
||||
## - # "children" value lists child mailboxes, but hides the namespace prefix.
|
||||
## - #list = yes
|
||||
## -
|
||||
## - # Namespace handles its own subscriptions. If set to "no", the parent
|
||||
## - # namespace handles them (empty prefix should always have this as "yes")
|
||||
## - #subscriptions = yes
|
||||
## - }
|
||||
echononl " Modify file '$(basename "${_conf_file}")'.."
|
||||
|
||||
## - Namespaces
|
||||
## -
|
||||
if grep -qE "^\s*namespace\s+inbox\s*{" "${_conf_file}"; then
|
||||
|
||||
read -r -d '' NEW_BLOCK <<EOF
|
||||
namespace inbox {
|
||||
# Namespace type: private, shared or public
|
||||
type = private
|
||||
# Namespace type: private, shared or public
|
||||
type = private
|
||||
|
||||
# Hierarchy separator to use. You should use the same separator for all
|
||||
# namespaces or some clients get confused. '/' is usually a good one.
|
||||
# The default however depends on the underlying mail storage format.
|
||||
#separator =
|
||||
separator = /
|
||||
# Hierarchy separator to use. You should use the same separator for all
|
||||
# namespaces or some clients get confused. '/' is usually a good one.
|
||||
# The default however depends on the underlying mail storage format.
|
||||
#separator =
|
||||
separator = /
|
||||
|
||||
# Prefix required to access this namespace. This needs to be different for
|
||||
# all namespaces. For example "Public/".
|
||||
#prefix =
|
||||
prefix =
|
||||
# Prefix required to access this namespace. This needs to be different for
|
||||
# all namespaces. For example "Public/".
|
||||
#prefix =
|
||||
prefix =
|
||||
|
||||
# Physical location of the mailbox. This is in same format as
|
||||
# mail_location, which is also the default for it.
|
||||
#location =
|
||||
# Physical location of the mailbox. This is in same format as
|
||||
# mail_location, which is also the default for it.
|
||||
#location =
|
||||
|
||||
# There can be only one INBOX, and this setting defines which namespace
|
||||
# has it.
|
||||
#inbox = no
|
||||
inbox = yes
|
||||
# There can be only one INBOX, and this setting defines which namespace
|
||||
# has it.
|
||||
#inbox = no
|
||||
inbox = yes
|
||||
|
||||
# If namespace is hidden, it's not advertised to clients via NAMESPACE
|
||||
# extension. You'll most likely also want to set list=no. This is mostly
|
||||
# useful when converting from another server with different namespaces which
|
||||
# you want to deprecate but still keep working. For example you can create
|
||||
# hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
|
||||
#hidden = no
|
||||
# If namespace is hidden, it's not advertised to clients via NAMESPACE
|
||||
# extension. You'll most likely also want to set list=no. This is mostly
|
||||
# useful when converting from another server with different namespaces which
|
||||
# you want to deprecate but still keep working. For example you can create
|
||||
# hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
|
||||
#hidden = no
|
||||
|
||||
# Show the mailboxes under this namespace with LIST command. This makes the
|
||||
# namespace visible for clients that don't support NAMESPACE extension.
|
||||
# "children" value lists child mailboxes, but hides the namespace prefix.
|
||||
#list = yes
|
||||
# Show the mailboxes under this namespace with LIST command. This makes the
|
||||
# namespace visible for clients that don't support NAMESPACE extension.
|
||||
# "children" value lists child mailboxes, but hides the namespace prefix.
|
||||
#list = yes
|
||||
|
||||
# Namespace handles its own subscriptions. If set to "no", the parent
|
||||
# namespace handles them (empty prefix should always have this as "yes")
|
||||
#subscriptions = yes
|
||||
# Namespace handles its own subscriptions. If set to "no", the parent
|
||||
# namespace handles them (empty prefix should always have this as "yes")
|
||||
#subscriptions = yes
|
||||
}
|
||||
EOF
|
||||
replace_or_append_code_block "namespace inbox" "${NEW_BLOCK}" "${_conf_file}" >> "${log_file}" 2>&1
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
cat <<EOF >> "${_conf_file}" 2> "${log_file}"
|
||||
|
||||
# If you need to set multiple mailbox locations or want to change default
|
||||
# namespace settings, you can do it by defining namespace sections.
|
||||
#
|
||||
# You can have private, shared and public namespaces. Private namespaces
|
||||
# are for user's personal mails. Shared namespaces are for accessing other
|
||||
# users' mailboxes that have been shared. Public namespaces are for shared
|
||||
# mailboxes that are managed by sysadmin. If you create any shared or public
|
||||
# namespaces you'll typically want to enable ACL plugin also, otherwise all
|
||||
# users can access all the shared mailboxes, assuming they have permissions
|
||||
# on filesystem level to do so.
|
||||
namespace inbox {
|
||||
# Namespace type: private, shared or public
|
||||
type = private
|
||||
|
||||
# Hierarchy separator to use. You should use the same separator for all
|
||||
# namespaces or some clients get confused. '/' is usually a good one.
|
||||
# The default however depends on the underlying mail storage format.
|
||||
#separator =
|
||||
separator = /
|
||||
|
||||
# Prefix required to access this namespace. This needs to be different for
|
||||
# all namespaces. For example "Public/".
|
||||
#prefix =
|
||||
prefix =
|
||||
|
||||
# Physical location of the mailbox. This is in same format as
|
||||
# mail_location, which is also the default for it.
|
||||
#location =
|
||||
|
||||
# There can be only one INBOX, and this setting defines which namespace
|
||||
# has it.
|
||||
#inbox = no
|
||||
inbox = yes
|
||||
|
||||
# If namespace is hidden, it's not advertised to clients via NAMESPACE
|
||||
# extension. You'll most likely also want to set list=no. This is mostly
|
||||
# useful when converting from another server with different namespaces which
|
||||
# you want to deprecate but still keep working. For example you can create
|
||||
# hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
|
||||
#hidden = no
|
||||
|
||||
# Show the mailboxes under this namespace with LIST command. This makes the
|
||||
# namespace visible for clients that don't support NAMESPACE extension.
|
||||
# "children" value lists child mailboxes, but hides the namespace prefix.
|
||||
#list = yes
|
||||
|
||||
# Namespace handles its own subscriptions. If set to "no", the parent
|
||||
# namespace handles them (empty prefix should always have this as "yes")
|
||||
#subscriptions = yes
|
||||
}
|
||||
EOF
|
||||
if [[ $? -gt 0 ]]; then
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
cat <<EOF >> "${_conf_file}" 2> "${log_file}"
|
||||
|
||||
namespace {
|
||||
type = shared
|
||||
separator = /
|
||||
|
||||
# Mailboxes are visible under "shared/user@domain/"
|
||||
# %%n, %%d and %%u are expanded to the destination user.
|
||||
prefix = shared/%%u/
|
||||
|
||||
# Mail location for other users' mailboxes. Note that %variables and ~/
|
||||
# expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
|
||||
# destination user's data.
|
||||
#location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
|
||||
# Use the default namespace for saving subscriptions.
|
||||
subscriptions = no
|
||||
|
||||
# Include this namespace in LIST output when listing its parent's folders.
|
||||
#
|
||||
# One of:
|
||||
# children Namespace prefix list listed only if it has child mailboxes.
|
||||
#
|
||||
# no Namespace and mailboxes not listed unless listing requests explicitly
|
||||
# mailboxes under the namespace prefix.
|
||||
#
|
||||
# yes Namespace and mailboxes are always listed.
|
||||
#
|
||||
# It is still possible to list the namespace's folders by explicitly asking for them.
|
||||
# For example, if this setting is no, using LIST "" * with namespace prefix "lazy-expunge/"
|
||||
# won't list it, but using LIST "" lazy-expunge/* lists all folders under it.
|
||||
#
|
||||
# Default: yes
|
||||
list = children
|
||||
}
|
||||
EOF
|
||||
if [ "$?" = 0 ]; then
|
||||
echo -e "$rc_done"
|
||||
else
|
||||
echo -e "$rc_failed"
|
||||
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed"
|
||||
fatal "Adding namespaces to '${_conf_file}' failed"
|
||||
fi
|
||||
|
||||
if ! $_failed ; then
|
||||
echo -e "$rc_done"
|
||||
else
|
||||
echo -e "$rc_failed"
|
||||
error "Adjusting Adjusting file ${_conf_file} failed"
|
||||
error "$(cat "${log_file}")"
|
||||
|
||||
echo ""
|
||||
echononl "continue anyway [yes/no]: "
|
||||
read OK
|
||||
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||
echononl "Wrong entry! - repeat [yes/no]: "
|
||||
read OK
|
||||
done
|
||||
[[ $OK = "yes" ]] || fatal "Interupted by user"
|
||||
|
||||
fi
|
||||
|
||||
fi # modify /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
@ -6557,68 +7146,68 @@ fi
|
||||
## -
|
||||
|
||||
|
||||
# edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
## edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
##
|
||||
## Add namespaces type shared to 10-mail.conf
|
||||
##
|
||||
#if [[ $dovecot_major_version -gt 2 ]] \
|
||||
# || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
|
||||
#
|
||||
# Add namespaces type shared to 10-mail.conf
|
||||
# echononl " Add namespaces type shared to '10-mail.conf'...."
|
||||
# echo -e "$rc_not_yet_implemented"
|
||||
#
|
||||
if [[ $dovecot_major_version -gt 2 ]] \
|
||||
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
|
||||
|
||||
echononl " Add namespaces type shared to '10-mail.conf'...."
|
||||
echo -e "$rc_not_yet_implemented"
|
||||
|
||||
else
|
||||
|
||||
## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
## -
|
||||
## - Add namespaces type shared to 10-mail.conf
|
||||
## - Take care to enable ACL plugin also, otherwise all users can access all the shared
|
||||
## - mailboxes, assuming they have permissions on filesystem level to do so.
|
||||
## - we will do that later..
|
||||
## - namespace {
|
||||
## - type = shared
|
||||
## - separator = /
|
||||
## - prefix = shared/%%u/
|
||||
## - location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
## - subscriptions = no
|
||||
## - list = children
|
||||
## - }
|
||||
## -
|
||||
echononl " Add namespaces type shared to 10-mail.conf"
|
||||
cat <<EOF >> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
|
||||
namespace {
|
||||
#type = shared
|
||||
#separator = /
|
||||
type = shared
|
||||
separator = /
|
||||
|
||||
# Mailboxes are visible under "shared/user@domain/"
|
||||
# %%n, %%d and %%u are expanded to the destination user.
|
||||
#prefix = shared/%%u/
|
||||
prefix = shared/%%u/
|
||||
|
||||
# Mail location for other users' mailboxes. Note that %variables and ~/
|
||||
# expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
|
||||
# destination user's data.
|
||||
#location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
|
||||
# Use the default namespace for saving subscriptions.
|
||||
subscriptions = no
|
||||
|
||||
# List the shared/ namespace only if there are visible shared mailboxes.
|
||||
list = children
|
||||
}
|
||||
EOF
|
||||
if [ "$?" = 0 ]; then
|
||||
echo -e "$rc_done"
|
||||
else
|
||||
echo -e "$rc_failed"
|
||||
fatal "Adding namespaces to /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed"
|
||||
fi
|
||||
|
||||
fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
#else
|
||||
#
|
||||
# ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
# ## -
|
||||
# ## - Add namespaces type shared to 10-mail.conf
|
||||
# ## - Take care to enable ACL plugin also, otherwise all users can access all the shared
|
||||
# ## - mailboxes, assuming they have permissions on filesystem level to do so.
|
||||
# ## - we will do that later..
|
||||
# ## - namespace {
|
||||
# ## - type = shared
|
||||
# ## - separator = /
|
||||
# ## - prefix = shared/%%u/
|
||||
# ## - location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
# ## - subscriptions = no
|
||||
# ## - list = children
|
||||
# ## - }
|
||||
# ## -
|
||||
# echononl " Add namespaces type shared to 10-mail.conf"
|
||||
# cat <<EOF >> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf
|
||||
#
|
||||
#namespace {
|
||||
# #type = shared
|
||||
# #separator = /
|
||||
# type = shared
|
||||
# separator = /
|
||||
#
|
||||
# # Mailboxes are visible under "shared/user@domain/"
|
||||
# # %%n, %%d and %%u are expanded to the destination user.
|
||||
# #prefix = shared/%%u/
|
||||
# prefix = shared/%%u/
|
||||
#
|
||||
# # Mail location for other users' mailboxes. Note that %variables and ~/
|
||||
# # expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
|
||||
# # destination user's data.
|
||||
# #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
# location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u
|
||||
#
|
||||
# # Use the default namespace for saving subscriptions.
|
||||
# subscriptions = no
|
||||
#
|
||||
# # List the shared/ namespace only if there are visible shared mailboxes.
|
||||
# list = children
|
||||
#}
|
||||
#EOF
|
||||
# if [ "$?" = 0 ]; then
|
||||
# echo -e "$rc_done"
|
||||
# else
|
||||
# echo -e "$rc_failed"
|
||||
# fatal "Adding namespaces to /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed"
|
||||
# fi
|
||||
#
|
||||
#fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf
|
||||
|
||||
|
||||
# edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf
|
||||
|
Reference in New Issue
Block a user