File: /var/lib/dpkg/info/ispmanager-pkg-php.postinst
#!/bin/bash
# postinst script for coremanager
#
# see: dh_installdeb(1)
#set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
COREDIR=/usr/local/mgr5
CONFNAME=php.conf
. ${COREDIR}/lib/pkgsh/core_pkg_funcs.sh
. ${COREDIR}/lib/pkgsh/ispmgr_pkg_funcs.sh
FillPhpParams
PHPMOD=$ISP_PHP_MOD
PHPETC=$ISP_PHP_ETC
PHPBIN=${PHPMOD}
CONFDIR=${PHPETC}/apache2
CONFFILE=${CONFDIR}/php.ini
case "$1" in
configure)
if [ -z ${2} ]; then
if [ "#${ISPCONVERT}" = "#yes" ]; then
PATHLIST="php-cgi php_bin php_cfg php_ext php_ini php_ver"
PathConvert ${COREDIR}/etc/conf.d/php.conf
MakeConfigLink php
ReloadMgr all
else
TZ=$(cat /etc/timezone)
grep -q "^date.timezone =" ${CONFFILE} || sed -i -r "s|;date.timezone =|date.timezone = ${TZ}|" ${CONFFILE}
grep -q "^date.timezone =" ${PHPETC}/cgi/php.ini || sed -i -r "s|;date.timezone =|date.timezone = ${TZ}|" ${PHPETC}/cgi/php.ini
grep -q "^date.timezone =" ${PHPETC}/cli/php.ini || sed -i -r "s|;date.timezone =|date.timezone = ${TZ}|" ${PHPETC}/cli/php.ini
grep -qiE '^\s*short_open_tag\s*=\s*off' ${CONFFILE} && sed -i -r 's/(^\s*short_open_tag\s*=\s*)off/\1On/gi' ${CONFFILE}
grep -qiE '^\s*short_open_tag\s*=\s*off' ${PHPETC}/cgi/php.ini && sed -i -r 's/(^\s*short_open_tag\s*=\s*)off/\1On/gi' ${PHPETC}/cgi/php.ini
grep -qiE '^\s*short_open_tag\s*=\s*off' ${PHPETC}/cli/php.ini && sed -i -r 's/(^\s*short_open_tag\s*=\s*)off/\1On/gi' ${PHPETC}/cli/php.ini
a2enmod -q -f ${PHPMOD} || :
grep -qP "^\s*SetHandler application/x-httpd-php" /etc/apache2/mods-enabled/${PHPMOD}.conf && sed --follow-symlinks -i -r "/^\s*SetHandler application\/x-httpd-php/s|^|#|" /etc/apache2/mods-enabled/${PHPMOD}.conf
ReloadService apache2
test -f ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME} || ln -sf ../conf.d/php.conf ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME}
if ! grep -qE "^\s*path\s+php_ext" ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME}; then
PATH_PHP_EXT=$(${PHPBIN} -i | awk '$1 == "extension_dir" {print $3}')
echo "path php_ext ${PATH_PHP_EXT}" >> ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME}
fi
PHP_VER=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")
grep -q "path php_ver" ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME} || echo "path php_ver ${PHP_VER}" >> ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME}
AddPath php_cfg_cgi ${PHPETC}/cgi/conf.d php
AddPath php_cfg_apache ${PHPETC}/apache2/conf.d php
ReloadMgr ${ISPMGR}
fi
fi
AddPath enabled_mod_dir /etc/apache2/mods-enabled php
AddPath available_mod_dir /etc/apache2/mods-available php
AddPath nativeconf ${PHPMOD} php
if [ -z ${2} ]; then
# Afterinstall
AfterinstallModule ${ISPMGR} php
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
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.
exit 0