Commit fb02ace6 authored by Patrick J Cherry's avatar Patrick J Cherry
Browse files

webmail: Fixed up config to behave more like phpmyadmin.

parent 165f32f5
symbiosis-webmail (2014:1111) stable; urgency=medium
* Fix up symbiosis-webmail-roundcube postinst to act more like our
phpmyadmin config.
-- Patrick J Cherry <patrick@bytemark.co.uk> Fri, 07 Aug 2015 23:14:33 +0100
symbiosis-webmail (2014:1110) stable; urgency=low
* Updated roundcube config to use UTF8 for mailbox names in sieve.
......
......@@ -21,4 +21,5 @@ rm -f /etc/apache2/conf.d/squirrelmail.local.conf
invoke-rc.d apache2 reload || true
#DEBHELPER#
exit 0
......@@ -15,86 +15,19 @@ fi
#
update-alternatives --install /var/www/webmail symbiosis-webmail /var/lib/roundcube/ 100
######################################
#
# Divert config files. This is cribbed from config-package-dev.
# Make sure Symbiosis config is included.
#
######################################
if ( ! grep -q "require('/etc/roundcube/main.symbiosis.inc.php')" /etc/roundcube/main.inc.php ); then
cat >>/etc/roundcube/main.inc.php <<EOF
mangle_config() {
file="$1"
package="$2"
ourfile="$file.dpkg-symbiosis"
theirfile="$file.dpkg-symbiosis-orig"
if [ -L "$file" -a -L "$theirfile" -a "$(readlink "$file")" -eq "$(readlink "$theirfile")"]; then
echo "$file and $theirfile are both symlinks to $(readlink "$file"), and the rcmail_config['des_key'] field isn't configured - something has gone wrong, so we'll rebuild the config file for roundcube."
# Try to recreate the roundcube config file in its absence. This is lifted from /var/lib/dpkg/roundcube-core.postinst
# Get current 3DES key from /etc/roundcube/main.inc.php
# Source the debian magic that gives us db_get and company
source /usr/share/debconf/confmodule
db_get roundcube/language || true
language="$RET"
db_get roundcube/hosts || true
hosts="$RET"
[ -f /etc/roundcube/main.inc.php ] && {
deskey=$(sed -n "s+^\$rcmail_config\['des_key'\] = '\(.*\)';\$+\1+p" \
/etc/roundcube/main.inc.php)
}
# If this is the default key, forget it !
[ "$deskey" = "rcmail-!24ByteDESkey*Str" ] && unset deskey
# Generate a new one
while [ -z "$deskey" ]; do
deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | \
tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
done
# Put hosts, language and key in main.inc.php - roundcube must already be installed, but it's a dependency of symbiosis-webmail-roundcube anyway.
cat /usr/share/roundcube/main.inc.php.dist | while read line; do
case "$line" in
"\$rcmail_config['default_host'] = "*)
printf "\$rcmail_config['default_host'] = %s;\n" "${hosts}"
;;
"\$rcmail_config['des_key'] = "*)
printf "\$rcmail_config['des_key'] = '%s';\n" "${deskey}"
;;
"\$rcmail_config['language'] = "*)
printf "\$rcmail_config['language'] = '%s';\n" "${language}"
;;
*)
printf "%s\n" "$line"
;;
esac
done >> $file.ucftmp
ucf --debconf-ok $file.ucftmp $theirfile
fi
# ucf --purge "$file"
#
# Now add the link in, unless it is already in place.
#
if [ ! -L "$file" ] && [ ! -e "$file" ]; then
ln -s "$(basename "$ourfile")" "$file"
elif [ ! -L "$file" ] || \
[ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
"$(readlink "$file")" != "$(basename "$theirfile")" ]; then
echo "E: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
fi
/**
* Read symbiosis config.
*/
if (is_readable('/etc/roundcube/main.symbiosis.inc.php')) {
require('/etc/roundcube/main.symbiosis.inc.php');
}
if [ "$1" = configure ] ; then
mangle_config /etc/roundcube/main.inc.php symbiosis-webmail-roundcube
EOF
fi
#DEBHELPER#
......@@ -105,6 +38,3 @@ fi
invoke-rc.d apache2 force-reload
exit 0
#DEBHELPER#
exit 0
......@@ -7,33 +7,6 @@ set -e
#
update-alternatives --remove symbiosis-webmail /var/lib/roundcube/
#
# Remove mangled configurations.
#
unmangle_config() {
file="$1"
package="$2"
ourfile="$file.dpkg-symbiosis"
theirfile="$file.dpkg-symbiosis-orig"
if [ ! -L "$file" ] || \
[ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
"$(readlink "$file")" != "$(basename "$theirfile")" ]; then
echo "E: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
else
rm -f "$file"
fi
if [ ! -L "$file" ] && [ ! -e "$file" ]; then
ucf "$theirfile" "$file"
fi
}
if [ "$1" = "remove" ]; then
unmangle_config /etc/roundcube/main.inc.php symbiosis-webmail-roundcube
fi
#DEBHELPER#
#
......@@ -41,7 +14,5 @@ fi
#
invoke-rc.d apache2 force-reload
#DEBHELPER#
exit 0
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment