X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=1f30bd63391147b58ebeec369578e78096a48d39;hb=refs%2Fheads%2Fjessie;hp=ac161dcce98a331a5e73c74e94adeac4cf5708f4;hpb=10e1b23107ae734fcaa2efa79eac426ddc9e9bd7;p=squirrelmail-cn.git diff --git a/debian/postinst b/debian/postinst old mode 100644 new mode 100755 index ac161dc..1f30bd6 --- a/debian/postinst +++ b/debian/postinst @@ -31,9 +31,25 @@ FQDN=`hostname --fqdn` . /usr/share/carnet-tools/functions.sh unset CP_ECHO_RETURN + +if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then + . /usr/share/apache2/apache2-maintscript-helper + + squirrelmail_enable() { + cp_echo "CN: Enabling $PKG configuration for Apache2." + return 0 + } +else + cp_echo "CN: Could not load Apache 2.4 maintainer script helper." + + squirrelmail_enable() { + return 1 + } +fi + mv_old_backups () { # Clean up /etc, nove old jun^H^H^Hbackups where they belong - glob="$1.old.*-*-*.*:*:*" + local glob="$1.old.*-*-*.*:*:*" # ${glob%/*} (dirname $glob) does not work for files in root if [ -n "$(find ${glob%/*} -name ${glob##*/})" ]; then @@ -47,16 +63,19 @@ mv_old_backups () { # listconffiles () # -# Recursively walks /etc/apache2/apache2.conf for Include directives. +# Recursively walks /etc/apache2/apache2.conf for Include and +# IncludeOptional directives. # Returns all configfiles so defined. # listconffiles () { local i incs + local base_dir="`dirname $1`" - incs=`awk 'tolower($1) == "include" { sub("/$","/*",$2); print $2; }' $1` + incs=`awk 'tolower($1) ~ /include(optional)?/ { sub("/$","/*",$2); print $2; }' $1` + incs=`echo "$incs" | sed -r "s#^([^/])#${base_dir}/\1#"` if [ -n "$incs" ]; then for i in $incs; do - if [ -e "$i" ]; then echo "$i"; listconffiles "$i"; fi + if [ -e "$i" ]; then echo "`readlink -m -q $i`"; listconffiles "$i"; fi done fi } @@ -75,7 +94,6 @@ genlocales () { } -need_restart=0 DATE=`date +%Y-%m-%d.%H:%M:%S` CONFDIR=/etc/squirrelmail CONF=$CONFDIR/apache.conf @@ -97,7 +115,7 @@ if [ -f "$CONF" ]; then echo -n "CN: Updating Apache2 configuration for Squirrelmail" perl -n -e 'print if ! m|^Alias\s*/webmail|' "$CONF" > $CONF.tmp - cp-update -t squirrelmail-cn $CONF.tmp <<-EOF + cp-update -t $PKG $CONF.tmp <<-EOF # Force SSL for /webmail -> you can still use /squirrelmail Alias /webmail /usr/share/squirrelmail @@ -125,7 +143,6 @@ EOF if ! cmp -s "$CONF" "/var/backups/$backup_name.bak"; then echo "." cp_echo "CN: Updated Apache2 configuration for Squirrelmail." - need_restart=1 else echo "... no changes." fi @@ -136,20 +153,21 @@ fi hconf=/etc/apache2/apache2.conf sconf=/etc/apache2/sites-available/ssl -# Include Squirrelmail apache.conf in Apache2 web server configuration -# (directory /etc/apache2/conf.d/), but only if we are not present in -# Apache2 configuration at all. +# Remove obsolete symbolic link. # -# We're not using listconffiles from apache-common Debian package. -# apache-common is no longer available in Debian Lenny. We're using -# listconffiles() function instead. +if [ "`readlink -q -m /etc/apache2/conf.d/$PKG.conf`" = "$CONF" ]; then + rm -f /etc/apache2/conf.d/$PKG.conf +fi + +# Include Squirrelmail apache.conf in Apache2 web server configuration, +# but only if we are not present in Apache2 configuration at all. # apache2listconf=`listconffiles "$hconf" | grep "$CONF"` || true -apache2squirrel=`ls -l /etc/apache2/conf.d/ | grep "$CONF"` || true -if [ -z "$apache2listconf" -a -z "$apache2squirrel" ]; then - ln -s "$CONF" /etc/apache2/conf.d/squirrelmail-cn.conf - need_restart=1 +if [ -z "$apache2listconf" ]; then + if [ ! -L /etc/apache2/conf-available/$PKG.conf -a ! -f /etc/apache2/conf-available/$PKG.conf ]; then + ln -sf "$CONF" /etc/apache2/conf-available/$PKG.conf + fi fi @@ -203,11 +221,7 @@ if dpkg -l dovecot-cn 2>/dev/null | grep -q '^ii'; then " fi -# Would there be any changes, perhaps? -# -if cp_check_and_sed '.' "$seddef" "$CONF"; then - need_restart=1 -fi +cp_check_and_sed '.' "$seddef" "$CONF" || true # Check /etc/hostname and /etc/mailname, because @@ -226,24 +240,11 @@ if [ -f /etc/locale.gen ]; then echo "hr_HR ISO-8859-2" >> /etc/locale.gen cp_echo "CN: Added hr_HR locale to /etc/locale.gen." genlocales - need_restart=1 fi else echo "hr_HR ISO-8859-2" > /etc/locale.gen cp_echo "CN: /etc/locale.gen created." genlocales - need_restart=1 -fi - - -# Check Apache2 web server for restart. -# -if [ $need_restart -eq 1 ]; then - if apache2ctl configtest 2>/dev/null; then - invoke-rc.d apache2 force-reload || true - else - cp_echo "CN: Your Apache2 configuration is either broken or nonexistant." - fi fi @@ -257,15 +258,22 @@ if [ "$nodots" -o "$nomailname" ]; then cp_echo "CN Read mailname(5) man page for details." cp_echo -mailonly "CN If this machine receives mail for both user@`hostname -f` and " cp_echo -mailonly "CN user@`hostname -d`, you can also put just the domain in there." + cp_echo +fi + +if squirrelmail_enable; then + apache2_invoke enconf $PKG +fi + +if ! apache2ctl configtest >/dev/null 2>&1; then + cp_echo "CN: Your Apache2 configuration seems to be broken." + cp_echo "CN: Please, check the service after the installation finishes!" fi # Mail root # cp_mail "$PKG" -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - #DEBHELPER# exit 0