5 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -x
7 # Source debconf library.
8 . /usr/share/debconf/confmodule
15 abort-upgrade|abort-remove|abort-deconfigure)
20 echo "postinst called with unknown argument \`$1'" >&2
27 domainname=`dnsdomainname`
28 FQDN=`hostname --fqdn`
30 # Include CARNet functions
31 . /usr/share/carnet-tools/functions.sh
35 # Clean up /etc, nove old jun^H^H^Hbackups where they belong
36 glob="$1.old.*-*-*.*:*:*"
38 # ${glob%/*} (dirname $glob) does not work for files in root
39 if [ -n "$(find ${glob%/*} -name ${glob##*/})" ]; then
40 for i in $(find ${glob%/*} -name ${glob##*/})
42 cp_backup_conffile "$i" "$2"
50 # Recursively walks /etc/apache2/apache2.conf for Include directives.
51 # Returns all configfiles so defined.
56 incs=`awk 'tolower($1) == "include" { sub("/$","/*",$2); print $2; }' $1`
57 if [ -n "$incs" ]; then
59 if [ -e "$i" ]; then echo "$i"; listconffiles "$i"; fi
66 # Update/generate localisation files from templates if locales-all
70 if [ -f /usr/lib/locales-all/supported.tar.lzma ] ; then
71 cp_echo "CN: locales-all installed, skipping locales generation."
79 DATE=`date +%Y-%m-%d.%H:%M:%S`
80 CONFDIR=/etc/squirrelmail
81 CONF=$CONFDIR/apache.conf
83 backup_name=squirrelmail_apache.conf
84 mv_old_backups $CONF $backup_name
86 # Check Apache2 web server configuration.
88 if [ -f "$CONF" ]; then
91 if cp_check_and_backup "$CONF" "$backup_name"; then
92 cp_echo "CN: Old $CONF saved as \"/var/backups/$backup_name.bak\"."
95 # Check if we already modified apache.conf
96 if ! egrep -q "^[ ]+RewriteRule \. https" "$CONF"; then
97 echo -n "CN: Updating Apache2 configuration for Squirrelmail"
98 perl -n -e 'print if ! m|^Alias\s*/webmail|' "$CONF" > $CONF.tmp
100 cp-update -t squirrelmail-cn $CONF.tmp <<-EOF
101 # Force SSL for /webmail -> you can still use /squirrelmail
102 Alias /webmail /usr/share/squirrelmail
104 <IfModule mod_rewrite.c>
108 RewriteCond %{HTTPS} !=on
109 RewriteRule . https://%{HTTP_HOST}%{REQUEST_URI} [L]
115 # WARNING: This file is automatically included in each VirtualHost
116 # entry you might have. Do not enable the VirtualHost example provided
117 # in this file, it WILL break your Apache configuration. Copy the
118 # VirtualHost section to the standard webserver configuration file
122 cp_mv $CONF.tmp $CONF
124 # This will break if cp_backup_conffile ever changes destination path
125 if ! cmp -s "$CONF" "/var/backups/$backup_name.bak"; then
127 cp_echo "CN: Updated Apache2 configuration for Squirrelmail."
130 echo "... no changes."
136 hconf=/etc/apache2/apache2.conf
137 sconf=/etc/apache2/sites-available/ssl
139 # Include Squirrelmail apache.conf in Apache2 web server configuration
140 # (directory /etc/apache2/conf.d/), but only if we are not present in
141 # Apache2 configuration at all.
143 # We're not using listconffiles from apache-common Debian package.
144 # apache-common is no longer available in Debian Lenny. We're using
145 # listconffiles() function instead.
147 apache2listconf=`listconffiles "$hconf" | grep "$CONF"` || true
148 apache2squirrel=`ls -l /etc/apache2/conf.d/ | grep "$CONF"` || true
150 if [ -z "$apache2listconf" -a -z "$apache2squirrel" ]; then
151 ln -s "$CONF" /etc/apache2/conf.d/squirrelmail-cn.conf
156 # Initial CARNet config tweaks.
158 CONF="$CONFDIR/config.php"
159 TMPL="$CONFDIR/config_default.php"
160 mv_old_backups "$CONF" "`basename $CONF`"
161 if cp_check_and_backup "$CONF"; then
162 cp_echo "CN: Old $CONF saved as \"/var/backups/${CONF##*/}.bak\"."
165 # We use sed to replace old defaults with ours.
166 # Must escape \$ because of shell expansion.
168 seddef="/^[ ]*\\\$org_logo[ ]*=/s/sm_logo\.jpg/sm_carnet_logo.png/;
169 /^[ ]*\\\$org_logo[ ]*=/s/sm_logo\.png/sm_carnet_logo.png/;
170 /^[ ]*\\\$org_logo[ ]*=/s/sm_carnet_logo\.jpg/sm_carnet_logo.png/;
171 /^[ ]*\\\$domain[ ]*=/s/mydomain\.com/$domainname/;
172 /^[ ]*\\\$default_charset[ ]*=/s/iso-8859-1/iso-8859-2/;
173 /^[ ]*\\\$org_logo_width[ ]*=/s/308/0/;
174 /^[ ]*\\\$org_logo_height[ ]*=/s/111/0/;
175 /^[ ]*\\\$squirrelmail_default_language[ ]*=/s/en_US/hr_HR/;
176 /^[ ]*\\\$data_dir[ ]*=/s/\.\.\/data\//\/var\/lib\/squirrelmail\/data\//;
179 # Left frame size to 220px.
180 # $default_left_size = '220';
182 db_get squirrelmail-cn/leftwidth || true
183 if [ "$RET" = "true" ]; then
184 seddef="$seddef/^[ ]*\\\$default_left_size[ ]*=/s/'[0-9]*'/'220'/;
188 # Change CSS file for Squirrelmail.
189 # $theme_css = SM_PATH . 'themes/css/squirrelmail-cn.css';
191 db_get squirrelmail-cn/themecss || true
192 if [ "$RET" = "true" ]; then
193 seddef="$seddef/^[ ]*\\\$theme_css[ ]*=/s/=.*/= SM_PATH . 'themes\/css\/squirrelmail-cn.css';/;
199 # Check for our dovecot package; if it is installed, assume it's used.
201 if dpkg -l dovecot-cn 2>/dev/null | grep -q '^ii'; then
202 seddef="$seddef/^[ ]*\\\$imap_server_type[ ]*=/ {s/cyrus/dovecot/;s/other/dovecot/;s/uw/dovecot/}
206 # Would there be any changes, perhaps?
208 if cp_check_and_sed '.' "$seddef" "$CONF"; then
213 # Check /etc/hostname and /etc/mailname, because
214 # $domain = trim(implode('', file('/etc/'.(file_exists('/etc/mailname')?'mail':'host').'name')));
218 grep -q '\.' /etc/hostname || nodots=1
219 [ -e /etc/mailname ] || nomailname=1
222 # Check for hr_HR locale.
224 if [ -f /etc/locale.gen ]; then
225 if ! egrep -q '^hr_HR ISO-8859-2\b' /etc/locale.gen; then
226 echo "hr_HR ISO-8859-2" >> /etc/locale.gen
227 cp_echo "CN: Added hr_HR locale to /etc/locale.gen."
232 echo "hr_HR ISO-8859-2" > /etc/locale.gen
233 cp_echo "CN: /etc/locale.gen created."
239 # Check Apache2 web server for restart.
241 if [ $need_restart -eq 1 ]; then
242 if apache2ctl configtest 2>/dev/null; then
243 invoke-rc.d apache2 force-reload || true
245 cp_echo "CN: Your Apache2 configuration is either broken or nonexistant."
252 if [ "$nodots" -o "$nomailname" ]; then
254 cp_echo "CN: Make sure that /etc/mailname contains a fully qualified domain name"
255 cp_echo "CN of this machine! Sending mail via squirrelmail might fail if the FQDN"
256 cp_echo "CN cannot be found in either /etc/mailname or /etc/hostname."
257 cp_echo "CN Read mailname(5) man page for details."
258 cp_echo -mailonly "CN If this machine receives mail for both user@`hostname -f` and "
259 cp_echo -mailonly "CN user@`hostname -d`, you can also put just the domain in there."
266 # dh_installdeb will replace this with shell code automatically
267 # generated by other debhelper scripts.