File: //var/lib/dpkg/info/nginx.postinst
#!/bin/sh
set -e
if [ "$1" != "configure" ]; then
exit 0
fi
# Touch and set permisions on default log files on installation
if [ -z "$2" ]; then
if [ -d /var/log/nginx ]; then
if [ ! -e /var/log/nginx/access.log ]; then
touch /var/log/nginx/access.log
chmod 640 /var/log/nginx/access.log
chown nginx:adm /var/log/nginx/access.log
fi
if [ ! -e /var/log/nginx/error.log ]; then
touch /var/log/nginx/error.log
chmod 640 /var/log/nginx/error.log
chown nginx:adm /var/log/nginx/error.log
fi
fi
fi
if [ -x "/etc/init.d/nginx" ]; then
if [ -f "/var/run/nginx.pid" ] && kill -0 `cat /var/run/nginx.pid` >/dev/null; then
/etc/init.d/nginx upgrade || echo \
"Binary upgrade failed, please check nginx's error.log"
else
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d nginx start || true
else
/etc/init.d/nginx start || true
fi
fi
fi
# Automatically added by dh_installinit/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -x "/etc/init.d/nginx" ]; then
update-rc.d nginx defaults >/dev/null || exit 1
fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'nginx.service' >/dev/null || true
# was-enabled defaults to true, so new installations run enable.
if deb-systemd-helper --quiet was-enabled 'nginx.service'; then
# Enables the unit on first installation, creates new
# symlinks on upgrades if the unit file has changed.
deb-systemd-helper enable 'nginx.service' >/dev/null || true
else
# Update the statefile to add new symlinks (if any), which need to be
# cleaned up on purge. Also remove old symlinks.
deb-systemd-helper update-state 'nginx.service' >/dev/null || true
fi
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.6ubuntu1
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if deb-systemd-helper debian-installed 'nginx-debug.service'; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask 'nginx-debug.service' >/dev/null || true
if deb-systemd-helper --quiet was-enabled 'nginx-debug.service'; then
# Create new symlinks, if any.
deb-systemd-helper enable 'nginx-debug.service' >/dev/null || true
fi
fi
# Update the statefile to add new symlinks (if any), which need to be cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state 'nginx-debug.service' >/dev/null || true
fi
# End automatically added section
exit 0