aboutsummaryrefslogtreecommitdiffstats
path: root/main/nginx/nginx.post-upgrade
blob: 8404e1ceb3137364dad1a5a4ab3485f686e67b43 (plain) (blame)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh

ver_new="$1"
ver_old="$2"

if [ "$(apk version -t "$ver_old" "1.10.1-r3")" = "<" ]; then
	cat 1>&2 <<-EOF
	*
	* The nginx package has been modified to use dynamic modules. Now there's
	* just single package providing nginx executable and bunch of nginx-mod-*
	* subpackages.
	*
	* Lua support is now provided by package nginx-mod-http-lua, RTMP support
	* is provided by nginx-mod-rtmp.
	*
	* Modules mail and stream are dynamic modules too and so not included
	* by default anymore. If you use them, install nginx-mod-mail and
	* nginx-mod-stream.
	* 
	EOF
fi

# Handle transition from /etc/nginx/conf.d to /etc/nginx/http.d.
if [ "$(apk version -t "$ver_old" '1.18.0-r13')" = '<' ]; then
	default_conf='/usr/share/nginx/http-default_server.conf'

	if [ -z "$(ls -A /etc/nginx/conf.d 2>/dev/null)" ]; then
		# conf.d dir doesn't exist or is empty, so the user doesn't use it.
		# Thus we can install default.conf to the new directory.
		install -m644 "$default_conf" /etc/nginx/http.d/default.conf

		# Symlink conf.d to http.d for backward compatibility.
		rmdir /etc/nginx/conf.d 2>/dev/null
		ln -s http.d /etc/nginx/conf.d

	else
		if ! [ -e /etc/nginx/conf.d/default.conf ]; then
			# conf.d dir exists and is not empty, but there's no default.conf
			# file, so the user probably did not modify it and apk has removed
			# it during this upgrade. Prior this version, the default.conf
			# would be installed, so install it now for backward compatibility.
			install -m644 "$default_conf" /etc/nginx/conf.d/default.conf
		fi
		if ! [ -e /etc/nginx/nginx.conf.apk-new ]; then
			# There's no updated nginx.conf, so the user didn't modify this
			# config and apk replaced it during this upgrade. However, the
			# user has some vhost configs in the old directory, so we have
			# to revert the include back to the legacy path.
			sed -i \
				-e 's|include /etc/nginx/http\.d|#&|' \
				-e 's|#\(include /etc/nginx/conf\.d\)|\1|' \
				/etc/nginx/nginx.conf
		fi
	fi

	cat >&2 <<-EOF
	*
	* The default and preferred location for nginx vhost configs has been changed
	* from /etc/nginx/conf.d to /etc/nginx/http.d. Although we did our best to not
	* break existing setups by this upgrade, we strongly recommend to verify it.
	*
	EOF
fi

exit 0