Current Path : /var/lib/dpkg/info/ |
Current File : /var/lib/dpkg/info/ispmanager-pkg-nginx.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=nginx.conf . ${COREDIR}/lib/pkgsh/core_pkg_funcs.sh . ${COREDIR}/lib/pkgsh/ispmgr_pkg_funcs.sh CONFDIR=/etc/nginx CONFFILE=${CONFDIR}/nginx.conf case "$1" in configure) if [ -z ${2} ]; then if [ "#${ISPCONVERT}" = "#yes" ]; then PATHLIST="nginx-conf nginx-scripts nginx-vhosts nginx-vhosts-includes nginx-conf.d" PathConvert ${COREDIR}/etc/conf.d/nginx.conf MakeConfigLink nginx ReloadMgr ${ISPMGR} else if [ -f /usr/sbin/apache2ctl ]; then ${ISPMGRCTL} paramlist elid=WebModules | grep -q apache || DisableService apache2 ||: fi rm -f /etc/nginx/sites-enabled/default mkdir -p /etc/nginx/vhosts-includes DISABLEDCONF=${CONFDIR}/vhosts-includes/disabled.conf if [ ! -f ${DISABLEDCONF} ]; then echo -e "location /disabled/ {" > ${DISABLEDCONF} echo -e "\talias /usr/local/mgr5/www/disabled/;" >> ${DISABLEDCONF} echo -e "}" >> ${DISABLEDCONF} fi # (nginx.org) test -f ${CONFDIR}/conf.d/default.conf && echo "# disabled by ispmanager" > ${CONFDIR}/conf.d/default.conf test -f ${CONFDIR}/conf.d/example_ssl.conf && echo "# disabled by ispmanager" > ${CONFDIR}/conf.d/example_ssl.conf sed -i -r 's/^\s*user.*$/user www-data;/g' ${CONFFILE} # Disable gzip. It will be enabled for the virtualhost individually sed -i -r 's/^(\s*)(gzip\s* on.*)$/\1# \2/g' ${CONFFILE} if ! grep -q SCRIPT_FILENAME ${CONFDIR}/fastcgi_params ; then echo 'fastcgi_param SCRIPT_FILENAME $request_filename;' >> ${CONFDIR}/fastcgi_params fi # end (nginx.org) CheckDisabledPage if [ "${ISPMGR}" = "ispmgrnode" ]; then if ! grep -qE 'log_format\s*ispmgrnode' /etc/nginx/nginx.conf ; then sed -i -r "/http\s+\{/a \ log_format ispmgrnode '\$server_name \$request_length \$bytes_sent';" /etc/nginx/nginx.conf fi echo "access_log ${COREDIR}/var/nginx.log ispmgrnode;" >> /etc/nginx/vhosts-includes/ispmgrnode.conf echo "path nginx_log ${COREDIR}/var/nginx.log" >> ${COREDIR}/etc/conf.d/nginx.conf mkdir -p /etc/nginx/vhosts-resources echo "path nginx-vhosts-resources /etc/nginx/vhosts-resources" >> ${COREDIR}/etc/conf.d/nginx.conf fi if [ -f /etc/default/nginx ]; then grep -q "^ULIMIT=" /etc/default/nginx || echo 'ULIMIT="-n 4096"' >> /etc/default/nginx fi # Limit NOFILE if [ -d /etc/systemd/system/ ] && [ -n "$(which systemctl 2>/dev/null)" ]; then if [ ! -f /etc/systemd/system/nginx.service.d/nofile.conf ] && [ ! -f /etc/systemd/system/nginx.service.d/limits.conf ]; then mkdir -p /etc/systemd/system/nginx.service.d echo -e "[Service]\nLimitNOFILE=16384" > /etc/systemd/system/nginx.service.d/nofile.conf systemctl daemon-reload fi fi ReloadService nginx EnableService nginx AddWebModule nginx test -f ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME} || ln -sf ../conf.d/nginx.conf ${COREDIR}/etc/${ISPMGR}.conf.d/${CONFNAME} ReloadMgr ${ISPMGR} ServiceAddmon nginx # Afterinstall AfterinstallModule ${ISPMGR} nginx fi fi ;; triggered) for triggername in $2; do echo ispmanager-pkg-nginx: processing trigger "'$triggername'" case "$triggername" in "/etc/apache2/ports.conf") if [ -f /etc/apache2/ports.conf ] && grep -iEq '^Listen.+80' /etc/apache2/ports.conf ; then echo "Changing default apache port in /etc/apache2/ports.conf" sed -i -r 's/^Listen.+80/Listen 81/' /etc/apache2/ports.conf fi ;; *) echo "unhandled/unknown trigger!" exit 0 ;; esac done ;; 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