D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
lib
/
dpkg
/
info
/
Filename :
sw-nginx.postinst
back
Copy
### Copyright 1999-2025. WebPros International GmbH. All rights reserved. [ -z "$PLESK_INSTALLER_DEBUG" ] || set -x [ -z "$PLESK_INSTALLER_STRICT_MODE" ] || set -e nginx_upgrade_systemd_limits_conf() { : # not necessary } nginx_graceful_upgrade() { local pidfile="/var/run/nginx.pid" local pidfile_old="/var/run/nginx.pid.oldbin" local pid # make nginx to spawn new master process pid=$(egrep -xm1 '[0-9]+' "$pidfile" 2>/dev/null) || return 1 kill -s USR2 "$pid" local i=0 # Wait for both old and new master to write their pid file while ! [ -s "$pidfile" -a -s "$pidfile_old" ]; do i=$((i+1)) ! [ $i -ge 10 ] || return 1 sleep 1 done # stop old master process pid=$(egrep -xm1 '[0-9]+' "$pidfile_old" 2>/dev/null) || return 1 kill -s QUIT "$pid" i=0 while [ -s "$pidfile_old" ]; do i=$((i+1)) ! [ $i -ge 10 ] || return 1 sleep 1 done return 0 } nginx_upgrade() { # upgrade isn't required if nginx isn't active /bin/systemctl is-active nginx.service -q || return 0 # do not restart nginx if config check is failed local msg rc=0 local nginx_config="/opt/psa/admin/sbin/nginx-config" if [ -x "$nginx_config" ]; then msg="`"$nginx_config" -T 2>&1`" || rc=$? else msg="`/usr/sbin/nginx -t 2>&1`" || rc=$? fi if [ $rc -ne 0 ]; then echo "$msg" >&2 echo "Nginx has not restarted during upgrade due to failure of configuration test" >&2 return $rc fi if ! nginx_graceful_upgrade; then echo "Unable to restart nginx gracefully, performing full restart" >&2 /bin/systemctl restart nginx.service || return $? fi return 0 } case "$1" in configure) sed -i -e 's|^\s*ULIMIT=|NGINX_ULIMIT=|g' /etc/default/nginx >/dev/null 2>&1 || true chmod 0750 /var/log/nginx >/dev/null 2>&1 nginx_upgrade_systemd_limits_conf || true nginx_upgrade || : ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac exit 0 # vim:ft=sh: