summaryrefslogtreecommitdiffstats
path: root/busybox.pkg/postinst
blob: 07b5c1f8d46ab0ca12bcb862c13a14cfbcd2fd35 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh

if [ "x${1}" = 'xconfigure' ]; then
	while read link name prio; do
		update-alternatives --install "${link}" "${name}" \
			"${link}.busybox" "${prio}"
	done </usr/share/busybox/alternatives
	if [ -d /etc/network ] && ! [ -f /etc/network/interfaces ]; then
		exec 3>/etc/network/interfaces
		printf 'auto lo\niface lo inet loopback\n\n' >&3
		for iface in /sys/class/net/eth*; do
			iface="${iface##*/}"
			printf 'auto %s\niface %s inet dhcp\n\n' \
				"${iface}" "${iface}" >&3
		done
		exec 3>&-
	fi
	if [ "x$(ls -A /var/www/ | head -n 1)" = 'x' ]; then
		# There are no files in /var/www/.
		cp /usr/share/busybox/www/index.html /var/www/index.html
		sha256sum /var/www/index.html >/usr/share/busybox/www/SHA256SUMS
	elif [ -f /var/www/index.html ] && \
			[ -f /usr/share/busybox/www/SHA256SUMS ]; then
		if sha256sum -cs /usr/share/busybox/www/SHA256SUMS; then
			# /var/www/index.html exists and hasn't been modified by
			# the user.
			cp /usr/share/busybox/www/index.html /var/www/index.html
			sha256sum /var/www/index.html \
				>/usr/share/busybox/www/SHA256SUMS
		fi
	fi
	if ! [ -f /etc/rc.policy ]; then
		if [ "x$(cat /etc/proteanos_plat)" = 'xdev' ]; then
			printf 'disabled\n' >/etc/rc.policy
		else
			printf 'enabled\n' >/etc/rc.policy
		fi
	fi
	if [ -f /usr/share/busybox/init-scripts ]; then
		for script in $(cat /usr/share/busybox/init-scripts); do
			if [ "x${2:+set}" != 'xset' ]; then
				"/etc/init.d/${script}" enable
			fi
			"/etc/init.d/${script}" start
		done
	fi
fi