aboutsummaryrefslogtreecommitdiffstats
path: root/main/nginx/nginx.pre-upgrade
blob: 67f05dda1c06a924a185d84e4481360b49fca2c9 (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
#!/bin/ash

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

if [ "$(apk version -t "$ver_old" '1.12.0-r1')" = '<' ]; then
	tmp_new=/var/tmp/nginx
	tmp_old=/var/lib/nginx/tmp

	# Create a new temp directory, move data from the old one to the new
	# one and delete the old one.
	if [ -d "$tmp_old" ]; then
		echo "* Moving data from $tmp_old to $tmp_new..." >&2

		[ -d "$tmp_new" ] \
			|| install -d -m 700 -o nginx -g nginx "$tmp_new"
		rmdir "$tmp_old" 2>/dev/null \
			&& exit 0 \
			|| mv "$tmp_old"/* "$tmp_new"/
		rmdir "$tmp_old" 2>/dev/null \
			&& exit 0 \
			|| mv "$tmp_old"/.[!.]* "$tmp_new"/  # move dot files
		rmdir "$tmp_old"
	fi
fi

exit 0