summaryrefslogtreecommitdiffstats
path: root/busybox.pkg/prerm
blob: ad8e8634b4b162a82719d8eb17fdbb41eb7a44d1 (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
26
27
28
#!/bin/sh

# Ensure opkg saved a copy of busybox and its links.  Otherwise, opkg could
# remove busybox, try to use gzip, crash, and leave behind a broken system.
if [ x"${OPKG_BUSYBOX_SAVED+set}" != x'set' ]; then
	exit 1
fi

if [ "x${1}" = 'xupgrade' ]; then
	if [ -f /usr/share/busybox/init-scripts ]; then
		while read -r script enabled; do
			"/etc/init.d/${script}" stop
		done </usr/share/busybox/init-scripts
	fi
	while read link; do
		update-alternatives --remove "${link##*/}" /bin/busybox
	done </usr/share/busybox/alternatives
	if [ -f /usr/share/busybox/www/SHA256SUMS ]; then
		if [ -f /var/www/index.html ] && \
				sha256sum -cs /usr/share/busybox/www/SHA256SUMS
		then
			# /var/www/index.html exists and hasn't been modified by
			# the user.
			rm /var/www/index.html
		fi
		rm /usr/share/busybox/www/SHA256SUMS
	fi
fi