2 # postinst script for roundcube
4 # see: dh_installdeb(1)
8 . /usr/share/debconf/confmodule
9 . /usr/share/dbconfig-common/dpkg/postinst
10 dbc_generate_include=php:/etc/roundcube/debian-db.php
11 dbc_generate_include_owner="www-data:www-data"
12 dbc_generate_include_perms="640"
13 dbc_dbfile_owner="www-data:www-data"
14 dbc_dbfile_perms="0660"
21 if [ ! -f /etc/lighttpd/conf-available/50-roundcube.conf ] ; then
22 if [ ! -x /usr/sbin/lighty-enable-mod ] ; then
23 echo "Lighttpd not installed, skipping"
25 ln -s /etc/roundcube/lighttpd.conf /etc/lighttpd/conf-available/50-roundcube.conf
26 lighty-enable-mod roundcube
33 if [ -d /etc/$webserver/conf.d ] && [ ! -e /etc/$webserver/conf.d/roundcube ]; then
34 ln -s /etc/roundcube/apache.conf /etc/$webserver/conf.d/roundcube
42 # We try to fix an incomplete upgrade (see #610725 and #613586)
43 if [ -n "$2" ] && dpkg --compare-versions "$2" le 0.5.1+dfsg-2; then
44 db_get roundcube/dbconfig-upgrade || true
45 if [ x"$RET" = x"true" ]; then
46 if [ x"$dbc_dbtype" = x"mysql" ]; then
47 # Ok, we may need to do some upgrade steps.
48 echo "Fixing MySQL installation..."
49 if dpkg --compare-versions "$2" ge 0.5; then
50 # Hack (ugly) to replace "mysql" by "mysql -f"
51 real_mysql="$(which mysql)"
52 workdir="$(mktemp -d)"
54 cat <<EOF > "$workdir/mysql"
56 "$real_mysql" "\$@" -f
58 chmod +x "$workdir/mysql"
61 /usr/share/dbconfig-common/data/roundcube/upgrade/mysql/0.5-1 || true
65 cat <<EOF | while read command; do dbc_mysql_exec_command "$command" || true ; done
66 ALTER TABLE \`messages\` ADD INDEX \`index_index\` (\`user_id\`, \`cache_key\`, \`idx\`);
67 ALTER TABLE \`contacts\`ADD INDEX \`user_contacts_index\` (\`user_id\`,\`email\`);
68 ALTER TABLE \`identities\` ADD INDEX \`user_identities_index\` (\`user_id\`, \`del\`);
74 CONFFILE=/etc/roundcube/main.inc.php
75 touch $CONFFILE.ucftmp
76 chmod 640 $CONFFILE.ucftmp
78 db_get roundcube/hosts || true
80 if [ "$hosts" != "" ]; then
81 hosts="array(\"$(echo $hosts | sed 's/ /\",\"/g')\")"
86 db_get roundcube/language || true
89 # Get current 3DES key from /etc/roundcube/main.inc.php
90 [ -f /etc/roundcube/main.inc.php ] && {
91 deskey=$(sed -n "s+^\$rcmail_config\['des_key'\] = '\(.*\)';\$+\1+p" \
92 /etc/roundcube/main.inc.php)
94 # If this is the default key, forget it !
95 [ "$deskey" = "rcmail-!24ByteDESkey*Str" ] && unset deskey
97 while [ -z "$deskey" ]; do
98 deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | \
99 tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
102 # Put hosts, language and key in main.inc.php
103 cat /usr/share/roundcube/main.inc.php.dist | while read line; do
105 "\$rcmail_config['default_host'] = "*)
106 printf "\$rcmail_config['default_host'] = %s;\n" "${hosts}"
108 "\$rcmail_config['des_key'] = "*)
109 printf "\$rcmail_config['des_key'] = '%s';\n" "${deskey}"
111 "\$rcmail_config['language'] = "*)
112 printf "\$rcmail_config['language'] = '%s';\n" "${language}"
115 printf "%s\n" "$line"
118 done >> $CONFFILE.ucftmp
120 ucf --debconf-ok $CONFFILE.ucftmp $CONFFILE
121 chown root:www-data $CONFFILE
122 rm -f $CONFFILE.ucftmp
124 # Handle webserver reconfiguration/restart ; stolen from zabbix package
125 db_get roundcube/reconfigure-webserver || true
129 for webserver in $webservers; do
130 webserver=${webserver%,}
131 if [ "$webserver" = "lighttpd" ] ; then
134 apache_install $webserver
136 test -x /usr/sbin/$webserver || continue
137 restart="$restart $webserver"
140 db_get roundcube/restart-webserver || true
143 if [ "$res" = "true" ]; then
144 for webserver in $restart; do
145 webserver=${webserver%,}
146 # Redirection of 3 is needed because Debconf uses it and it might
147 # be inherited by webserver. See bug #446324.
148 if [ -x /usr/sbin/invoke-rc.d ]; then
149 invoke-rc.d $webserver reload 3>/dev/null || true
151 /etc/init.d/$webserver reload 3>/dev/null || true
156 chown -R www-data:adm /var/log/roundcube
157 chmod -R 750 /var/log/roundcube
158 chown -R www-data:www-data /var/lib/roundcube/temp
159 chmod -R 750 /var/lib/roundcube/temp
163 abort-upgrade|abort-remove|abort-deconfigure)
167 echo "postinst called with unknown argument \`$1'" >&2