Heray-Was-Here
Server : nginx/1.30.2
System : Linux elegant-dhawan.198-71-59-75.plesk.page 5.15.0-105-generic #115-Ubuntu SMP Mon Apr 15 09:52:04 UTC 2024 x86_64
User : realtyna_guys ( 10000)
PHP Version : 8.2.31
Disable Function : opcache_get_status
Directory :  /var/lib/dpkg/info/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/lib/dpkg/info/sw-nginx.postinst
### Copyright 1999-2026. 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_upgrade_proxy_sni_conf()
{
	local conf="/etc/nginx/conf.d/fixssl.conf"
	grep -q '^# Plesk fix ' "$conf" 2>/dev/null && [ -f "$conf.default" ] ||
		cp -af "$conf.default" "$conf"
}

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=$(grep -E -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=$(grep -E -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_proxy_sni_conf || :
		nginx_upgrade || :
		;;
	abort-upgrade|abort-remove|abort-deconfigure)
		;;
	*)
		echo "postinst called with unknown argument \`$1'" >&2
		exit 1
		;;
esac

exit 0


# vim:ft=sh:

Hry