diff options
Diffstat (limited to 'modules.d/busybox/hooks/s3-install-busybox-stage4.sh')
-rwxr-xr-x | modules.d/busybox/hooks/s3-install-busybox-stage4.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules.d/busybox/hooks/s3-install-busybox-stage4.sh b/modules.d/busybox/hooks/s3-install-busybox-stage4.sh new file mode 100755 index 00000000..f5c0aae9 --- /dev/null +++ b/modules.d/busybox/hooks/s3-install-busybox-stage4.sh @@ -0,0 +1,35 @@ +#!/bin/ash + +# copy busybox to NEWROOT unless one exists at the expected path. +bb_target_path="/opt/openslx/bin/busybox" +bb_source_path="$( type -p busybox )" +[ -x "$bb_source_path" ] || bb_source_path="$( command -v busybox )" + +if ! [ -x "$bb_source_path" ]; then + echo "Busybox binary not found in initrd!?" + exit 1 +fi + +if [ -x "${NEWROOT}${bb_target_path}" ]; then + echo "Not installing busybox in stage 4 - already exists" + exit 1 +fi + +mkdir -p -- "${NEWROOT}/opt/openslx/bin" "${NEWROOT}/opt/openslx/sbin" +cp -f -- "$bb_source_path" "${NEWROOT}${bb_target_path}" +# --list-full gives {s,}bin prefixes +for app in $( busybox --list-full ); do + # No -f, so we skip any tools that might already exist + ln -ns -- "$bb_target_path" "${NEWROOT}/opt/openslx/$app" +done +# compat: /bin/ash if not exists +# also accept dead symlinks as it might be relative and just look dead +# to us from outside NEWROOT +if ! [ -e "${NEWROOT}/bin/ash" ] && ! [ -L "${NEWROOT}/bin/ash" ]; then + ln -nsf -- "$bb_target_path" "${NEWROOT}/bin/ash" +else + # either valid symlink or binary, log it and ignore. + echo "'/bin/ash' is a symlink or binary, leaving it alone." +fi + +exit 0 |