#!/bin/sh -e

# Debian alternc-changepass postinst
# Benjamin Sonntag <benjamin@alternc.org>

. /usr/share/debconf/confmodule

case "$1" in
configure)

    # On ajoute la ligne GLOBAL dans local.php si le fichier ne la contient pas ... (pour les alternc < 0.9.3)
    FL=/var/alternc/bureau/class/local.php
    echo -n "Configuring local.php "
    if grep -qs "^global" $FL
        then
        echo "no patch needed, global already present"
    else
        echo "applying patch"
        # the .php is here for security reasons ! as local.php contains the mysql password !
        rm -f $FL.alternc_procmail.php
        sed -e "s/^\$L_MX/\\
global \$L_MYSQL_HOST,\$L_MYSQL_LOGIN,\$L_MYSQL_PWD,\$L_MYSQL_DATABASE,\$L_SHOWVERSION,\$L_VERSION,\$L_FQDN,\$L_HOSTING,\$L_NS2,\$L_NS1,\$L_MX; \\
\$L_MX/" <$FL >$FL.alternc_procmail.php
        mv -f $FL.alternc_procmail.php $FL
    fi
    db_get alternc-changepass/warning_squirrelmail_plugin || true

    ;;

abort-upgrade)
    exit 0
    ;;

abort-remove|abort-deconfigure)
    exit 0
    ;;

*)
    echo "postinst called with unknown argument '$1'" >&2
    exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
