# Set up BusyBox
if [ -e /bin/busybox ]; then
# Install busybox
echo "Copying busybox to /bin"
cp -a /bin/busybox tempfs/bin/
# Create a link to busybox to take the place of the linuxrc script
ln -s /bin/busybox tempfs/linuxrc
# Here's all the BusyBox commands
BUSYBOX_COMMANDS="adjtimex ar basename cat chgrp chmod chown chroot chvt clear cmp cp cpio cut date dc dd deallocvt df dirname dmesg dos2unix dpkg dpkg-deb du dumpkmap dutmp echo expr false fbset fdflush find free freeramdisk fsck.minix getopt grep gunzip gzip halt head hostid hostname id ifconfig init insmod kill killall klogd length ln loadacm loadfont loadkmap logger logname ls lsmod makedevs md5sum mkdir mkfifo mkfs.minix mknod mkswap mktemp more mount mt mv nc nslookup ping pivot_root poweroff printf ps pwd rdate readlink reboot renice reset rm rmdir rmmod route rpm2cpio sed setkeycodes sh sleep sort stty swapoff swapon sync syslogd tail tar tee telnet test tftp touch tr true tty umount uname uniq unix2dos update uptime usleep uudecode uuencode watchdog wc wget which whoami xargs yes zcat ["
# Create links for busybox using the existing system as a clue for destination
echo "Creating busybox links"
for BUSYBOX_COMMAND in $BUSYBOX_COMMANDS; do
FOUND_A_HOME="no"
for DEST_DIR in "bin" "sbin" "usr/bin" "usr/sbin"; do
if [ -e /$DEST_DIR/$BUSYBOX_COMMAND ]; then
ln -s /bin/busybox tempfs/$DEST_DIR/$BUSYBOX_COMMAND
FOUND_A_HOME="yes"
fi
done
# If we can't find a home for a command, put it in /bin
if [ "$FOUND_A_HOME" = "no" ]; then
ln -s /bin/busybox tempfs/bin/$BUSYBOX_COMMAND
fi
done
fi