File: nginx.postinst

package info (click to toggle)
nginx 1.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 9,472 kB
  • sloc: ansic: 169,389; sh: 613; perl: 439; python: 240; makefile: 126; cpp: 19
file content (34 lines) | stat: -rw-r--r-- 700 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
#!/bin/sh
set -e

case "$1" in
  abort-upgrade|abort-remove|abort-deconfigure|configure)
    ;;
  triggered)
    if invoke-rc.d --quiet nginx status >/dev/null; then
      echo "Triggering nginx reload ..."
      invoke-rc.d nginx reload || true
    fi
    exit 0
    ;;
  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

if invoke-rc.d --quiet nginx status >/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

#DEBHELPER#

exit 0