File: /var/lib/dpkg/info/ispmanager-pkg-httpd.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=apache.conf
. ${COREDIR}/lib/pkgsh/ispmgr_pkg_funcs.sh
if [ "$(lsb_release -s -c)" = "focal" ] || [ "$(lsb_release -s -c)" = "bullseye" ]; then
PHPETC=/etc/php/7.4
PHPMOD=php7.4
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "buster" ]; then
PHPETC=/etc/php/7.3
PHPMOD=php7.3
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "bionic" ]; then
PHPETC=/etc/php/7.2
PHPMOD=php7.2
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "xenial" ] || [ "$(lsb_release -s -c)" = "stretch" ]; then
PHPETC=/etc/php/7.0
PHPMOD=php7.0
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "jammy" ]; then
PHPETC=/etc/php/8.1
PHPMOD=php8.1
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "bookworm" ]; then
PHPETC=/etc/php/8.2
PHPMOD=php8.2
PHPLIB=/usr/lib/php
elif [ "$(lsb_release -s -c)" = "noble" ]; then
PHPETC=/etc/php/8.3
PHPMOD=php8.3
PHPLIB=/usr/lib/php
else
PHPETC=/etc/php5
PHPMOD=php5
PHPLIB=/usr/lib/php5
fi
case "$1" in
configure)
# Enable remoteip. Disable rpaf. Fix int #24630 ext #2241
APACHE_VER=$(apachectl -v | awk -F "[ /]" '/Server version/ {print $4}')
if [ -f /usr/lib/apache2/modules/mod_rpaf.so ] && strings /usr/lib/apache2/modules/mod_rpaf.so | grep -iq 'RPAF_SetHTTPS' ; then
# Skipping removing rpaf if new rpaf. Fix #30036
:
else
if dpkg --compare-versions ${APACHE_VER} ge 2.4; then
if [ -f /etc/apache2/mods-enabled/remoteip.conf ] && [ ! -L /etc/apache2/mods-enabled/remoteip.conf ] && [ ! -f /etc/apache2/mods-available/remoteip.conf ]; then
mv /etc/apache2/mods-enabled/remoteip.conf /etc/apache2/mods-available/remoteip.conf
ln -s ../mods-available/remoteip.conf /etc/apache2/mods-enabled/remoteip.conf
apachectl -t >/dev/null
fi
if [ -f /etc/apache2/mods-enabled/rpaf.conf ]; then
a2dismod -q -f rpaf || :
A2_RELOAD=yes
fi
if [ ! -f /etc/apache2/mods-enabled/remoteip.load ]; then
if [ ! -f /etc/apache2/mods-available/remoteip.conf ]; then
echo "RemoteIPHeader X-Forwarded-For" > /etc/apache2/mods-available/remoteip.conf
echo "RemoteIPInternalProxy 127.0.0.1" >> /etc/apache2/mods-available/remoteip.conf
fi
a2enmod -q -f remoteip || :
A2_RELOAD=yes
fi
if grep -qE "^\s*LogFormat.+%h.*" /etc/apache2/apache2.conf ; then
sed -i -r '/^\s*LogFormat.+%h.*/s/(^\s*LogFormat.+)%h(.*)/\1%a\2/g' /etc/apache2/apache2.conf
A2_RELOAD=yes
fi
else
if [ ! -f /etc/apache2/mods-enabled/rpaf.conf ]; then
a2enmod -q -f rpaf || :
A2_RELOAD=yes
fi
fi
fi
for mod in headers include proxy proxy_fcgi proxy_http; do
if [ ! -e /etc/apache2/mods-enabled/${mod}.load ]; then
a2enmod -q -f ${mod} || :
A2_RELOAD=yes
fi
done
if [ -z "${2}" ]; then
if [ "#${ISPCONVERT}" = "#yes" ]; then
PATHLIST="apachectl apacheroot apache.conf apache-vhosts-default apache-vhosts apache-conf.d"
PathConvert ${COREDIR}/etc/conf.d/httpd.conf
MakeConfigLink apache httpd
ReloadMgr ${ISPMGR}
else
if [ -f /etc/apache2/mods-available/mpm_itk.load ]; then
a2dismod -f mpm_itk >/dev/null 2>&1 || :
fi
# Включаем модули
if [ -f /etc/apache2/mods-available/mpm_prefork.load ]; then
a2dismod -f mpm_event >/dev/null 2>&1 || :
a2enmod -f mpm_prefork || :
fi
a2dismod -f ${PHPMOD} >/dev/null 2>&1 || :
a2enmod -f suexec cgi rewrite vhost_alias ssl actions fcgid >/dev/null 2>&1 || :
a2dissite -q -f default >/dev/null 2>&1 || :
# Комментим Listen и NameVirtualHost
sed -i.orig -r 's:^(\s*(Listen|NameVirtualHost)):#\1:g' /etc/apache2/ports.conf
# Creating vhosts dir
mkdir -p /etc/apache2/vhosts
mkdir -p /etc/apache2/vhosts-default
# Adding inclues if not exists
grep -q "^Include conf.d/" /etc/apache2/apache2.conf || echo "Include conf.d/" >> /etc/apache2/apache2.conf
grep -qE "^Include(Optional)? vhosts-default/" /etc/apache2/apache2.conf || echo "IncludeOptional vhosts-default/*.conf" >> /etc/apache2/apache2.conf
grep -qE "^Include(Optional)? vhosts/" /etc/apache2/apache2.conf || echo "IncludeOptional vhosts/*/*.conf" >> /etc/apache2/apache2.conf
sed -i -r '/^<Directory\s*\/var\/www\/>/,/^<\/Directory>/{/^\s*Options\s*/d}' /etc/apache2/apache2.conf
AddFix "fix_ISP6-2012_remove_options"
echo "ApacheConfExt .conf" >> ${COREDIR}/etc/conf.d/httpd.conf
mkdir -p /etc/apache2/vhosts-resources
echo "path apache-vhosts-resources /etc/apache2/vhosts-resources" >> ${COREDIR}/etc/conf.d/httpd.conf
mkdir -p /etc/apache2/users-resources
echo "path apache-users-resources /etc/apache2/users-resources" >> ${COREDIR}/etc/conf.d/httpd.conf
AddFix "fix_ISP6-1883_host_limits_apache"
# Limit NOFILE
if [ -d /etc/systemd/system/ ] && [ -n "$(which systemctl 2>/dev/null)" ]; then
if [ ! -f /etc/systemd/system/apache2.service.d/nofile.conf ] && [ ! -f /etc/systemd/system/apache2.service.d/limits.conf ]; then
mkdir -p /etc/systemd/system/apache2.service.d
echo -e "[Service]\nLimitNOFILE=16384" > /etc/systemd/system/apache2.service.d/nofile.conf
systemctl daemon-reload
fi
fi
EnableService apache2
ReloadService apache2
test -f ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME} || ln -sf ../conf.d/httpd.conf ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME}
CheckDisabledPage
AddWebModule apache
ServiceAddmon apache2
# Afterinstall
AfterinstallModule ${ISPMGR} apache
fi
else
sed -ri 's/^Include(Optional)?\svhosts\/$/IncludeOptional vhosts\/*\/*/' /etc/apache2/apache2.conf
if AddFix "fix_ISP6-2012_remove_options"; then
ls /etc/apache2*/apache2.conf | xargs sed -i -r '/^<Directory\s*\/var\/www\/>/,/^<\/Directory>/{/^\s*Options\s*/d}' >/dev/null 2>&1 || :
A2_RELOAD=yes
fi
if AddFix "fix_ISP6-1883_host_limits_apache"; then
mkdir -p /etc/apache2/vhosts-resources
echo "path apache-vhosts-resources /etc/apache2/vhosts-resources" >> ${COREDIR}/etc/conf.d/httpd.conf
mkdir -p /etc/apache2/users-resources
echo "path apache-users-resources /etc/apache2/users-resources" >> ${COREDIR}/etc/conf.d/httpd.conf
fi
test -n "${A2_RELOAD}" && ReloadService apache2
fi
test -d /etc/apache2/webdav-users || mkdir -p /etc/apache2/webdav-users
AddPath apache-webdav /etc/apache2/webdav-users apache
AddPath apache-modules-includes /etc/apache2/modules-includes apache
if [ -n "${2}" ]; then
ReloadMgr ${ISPMGR}
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