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="660"
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 /usr/sbin/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 # From 0.1-beta2.2 to 0.1-rc1, a column was added to table
43 # `identities'. For MySQL and PostgreSQL, this is handled by
44 # dbconfig-common but for sqlite, there is no way to add a
45 # column to a table. Therefore, we dump here the table and add
47 [ "$dbc_upgrade" = "true" ] && {
50 db="${dbc_basepath}/${dbc_dbname}"
51 # OK, we need to check if the table contains html_signature
52 if ! sqlite "$db" '.schema identities' | grep -q html_signature; then
54 echo -n "Need to upgrade 'identities' table in $db... "
55 upgrade_tmp=$(mktemp -t roundcube.sqlite.XXXXXXXXXX)
59 DROP TABLE identities;
60 CREATE TABLE identities (
61 identity_id integer NOT NULL PRIMARY KEY,
62 user_id integer NOT NULL default '0',
63 del tinyint NOT NULL default '0',
64 standard tinyint NOT NULL default '0',
65 name varchar(128) NOT NULL default '',
66 organization varchar(128) default '',
67 email varchar(128) NOT NULL default '',
68 "reply-to" varchar(128) NOT NULL default '',
69 bcc varchar(128) NOT NULL default '',
70 signature text NOT NULL default '',
71 html_signature tinyint NOT NULL default '0'
74 CREATE INDEX ix_identities_user_id ON identities(user_id);
77 # We dump and keep only inserts
78 sqlite "$db" '.dump identities' | \
79 awk '/^INSERT INTO/ {start = 1} {if (start == 1) print}' | \
81 sed 's/^\(INSERT INTO identities \)/\1(identity_id, user_id, del, standard, name, organization, email, "reply-to", bcc, signature) /'
82 echo 'COMMIT;' ) > $upgrade_tmp
83 sqlite "$db" < $upgrade_tmp
94 CONFFILE=/etc/roundcube/main.inc.php
95 touch $CONFFILE.ucftmp
96 chmod 640 $CONFFILE.ucftmp
98 db_get roundcube/hosts || true
100 if [ "$hosts" != "" ]; then
101 hosts="array(\"$(echo $hosts | sed 's/ /\",\"/g')\")"
106 db_get roundcube/language || true
109 # Get current 3DES key from /etc/roundcube/main.inc.php
110 [ -f /etc/roundcube/main.inc.php ] && {
111 deskey=$(sed -n "s+^\$rcmail_config\['des_key'\] = '\(.*\)';\$+\1+p" \
112 /etc/roundcube/main.inc.php)
114 # If this is the default key, forget it !
115 [ "$deskey" = "rcmail-!24ByteDESkey*Str" ] && unset deskey
117 while [ -z "$deskey" ]; do
118 deskey=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | \
119 tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
122 # Put hosts, language and key in main.inc.php
123 cat /usr/share/roundcube/main.inc.php.dist | \
124 sed -e "s+^\(\$rcmail_config\['default_host'\] = \)''\(;\)\$+\1${hosts}\2+" \
125 -e "s+^\(\$rcmail_config\['des_key'\] = '\).*\(';\)\$+\1$deskey\2+" \
126 -e "s+^\(\$rcmail_config\['locale_string'\] = '\).*\(';\)\$+\1${language}\2+" >> $CONFFILE.ucftmp
128 ucf --debconf-ok $CONFFILE.ucftmp $CONFFILE
129 chown root:www-data $CONFFILE
130 rm -f $CONFFILE.ucftmp
132 # Handle webserver reconfiguration/restart ; stolen from zabbix package
133 db_get roundcube/reconfigure-webserver || true
137 for webserver in $webservers; do
138 webserver=${webserver%,}
139 if [ "$webserver" = "lighttpd" ] ; then
142 apache_install $webserver
144 test -x /usr/sbin/$webserver || continue
145 restart="$restart $webserver"
148 db_get roundcube/restart-webserver || true
151 if [ "$res" = "true" ]; then
152 for webserver in $restart; do
153 webserver=${webserver%,}
154 if [ -x /usr/sbin/invoke-rc.d ]; then
155 invoke-rc.d $webserver restart
157 /etc/init.d/$webserver restart
162 chown -R www-data:adm /var/log/roundcube
163 chmod -R 750 /var/log/roundcube
164 chown -R www-data:www-data /var/lib/roundcube/temp
165 chmod -R 750 /var/lib/roundcube/temp
166 chown www-data:adm /var/lib/roundcube/skins
170 abort-upgrade|abort-remove|abort-deconfigure)
174 echo "postinst called with unknown argument \`$1'" >&2