summaryrefslogtreecommitdiffstats
path: root/modules.d/busybox/install-busybox-stage4.sh
blob: bcd1f94d00e7ba187a15aadabea6f92d92f20921 (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
#!/bin/bash

if hash busybox; then
	# copy busybox to NEWROOT unless one exists at the expected path.
	bb_target_path="/opt/openslx/bin/busybox"
	bb_source_path="$(type -p busybox)"

	if [ -n "$bb_source_path" ] && [ ! -x "${NEWROOT}${bb_target_path}" ]; then
		mkdir -p "${NEWROOT}"/opt/openslx/{s,}bin
		cp -f "$bb_source_path" "${NEWROOT}${bb_target_path}"
		# --list-full gives {s,}bin prefixes
		for app in $(busybox --list-full); do
			ln -s "$bb_target_path" "${NEWROOT}/opt/openslx/$app"
		done
	fi
	# compat: /bin/ash if not exists
	if [ ! -e "${NEWROOT}/bin/ash" ]; then
		# either dead symlink or nothing there.
		ln -sf "$bb_target_path" "${NEWROOT}/bin/ash"
	else
		# either valid symlink or binary, log it and ignore.
		type -p warn &>/dev/null || . /lib/dracut-lib.sh
		warn "'/bin/ash' is a valid symlink or binary, ignoring."
	fi
fi
true