aboutsummaryrefslogtreecommitdiffstats
path: root/main/nginx/nginx.pre-upgrade
blob: 72055c757a7db056f5d070a2f2f8a72e857b312d (plain)
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
#!/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
		[ -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