File: nginx-extras.postinst

package info (click to toggle)
nginx 1.18.0-6.1%2Bdeb11u3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 19,344 kB
  • sloc: ansic: 250,653; perl: 7,548; sh: 1,408; ruby: 879; python: 358; makefile: 338; awk: 36; cpp: 18
file content (38 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
set -e

case "$1" in
  abort-upgrade|abort-remove|abort-deconfigure|configure)
    ;;
  triggered)
    if [ -x /etc/init.d/nginx ]; then
      if [ -s /run/nginx.pid ] && pidof /usr/sbin/nginx >/dev/null; then
        echo "Triggering nginx reload ..."
        invoke-rc.d nginx reload || true
      fi
    fi
    exit 0
    ;;
  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

if [ -x /etc/init.d/nginx ]; then
  if [ -f /run/nginx.pid ] && pidof /usr/sbin/nginx >/dev/null; then
    invoke-rc.d nginx upgrade || invoke-rc.d nginx restart
    exit $?
  else
    if [ -z "$(ss -nlt 'sport = 80' | grep -v ^State)" ]; then
      invoke-rc.d nginx start || exit $?
    else
      echo "Not attempting to start NGINX, port 80 is already in use."
      exit 0
    fi
  fi
fi

#DEBHELPER#

exit 0