[Android Software/Hacking General [Developers Only]] dk_zero-cool:
Most Android ROMs use toolbox as primary binary with symlinks in /system/bin and /system/xbin. The problem with toolbox is that it sucks. On some ROMs it's even so limited that it does not even allow for --prefix

Busybox is a great replacement for toolbox, but in order to use it, you have to call it using 'busybox cmd'. I would much rather use it by calling 'cmd' but this would execute toolbox instead of busybox.

Most would think the command 'busybox --install' would fix this, but it does'nt. It tries to install links at /bin and /sbin.

The script below will replace any toolbox links in /system/bin and /system/xbin that is supported by the busybox version installed on the Android device running the script. This will make busybox the default binary when executing regular commands without adding 'busybox' at the beginning of the command.

For an example 'ls' instead of 'busybox ls'

Download as an update.zip

v1.3.0 (Nov 17, 2012) (MD5: c233964f0f62a16d7376739041e8b250) - busybox_installer.zip (Only for ArmV7 devices)

v1.3.0 (Nov 17, 2012) (MD5: e921a6c4119644a18d4feea565824ab1) - busybox_installer-nobin (Without binaries)

busybox.sh

#!/sbin/sh

for cmd in test find basename readlink ln rm; do
eval export "_$cmd=\"/sbin/busybox $cmd\""
done

_busybox=$($_find /system -type f -name "busybox")
_toolbox=$($_find /system -type f -name "toolbox")

if $_test -e "$_busybox" && $_test -e "$_toolbox"; then
sToolboxList="watchprops wipe vmstat date uptime reboot getevent getprop setprop id iftop ioctl ionice log lsof nandread newfs_msdos notify ps r schedtop sendevent setconsole setprop sleep smd start stop top"
sBusyboxList="`$_busybox --list`"

for applet in $sBusyboxList; do
if $_test -L /system/bin/$applet; then
if $_test "`$_basename $($_readlink -f /system/bin/$applet)`" = "toolbox"; then
$_ln -sf $_busybox /system/bin/$applet

if $_test -L /system/xbin/$applet; then
$_rm -rf /system/xbin/$applet
fi
fi

elif $_test -L /system/xbin/$applet; then
if $_test "`$_basename $($_readlink -f /system/xbin/$applet)`" = "toolbox"; then
$_ln -sf $_busybox /system/xbin/$applet
fi

elif ! $_test -e /system/bin/$applet && ! $_test -e /system/xbin/$applet; then
$_ln -sf $_busybox /system/bin/$applet
fi
done

for applet in $sToolboxList; do
$_ln -sf $_toolbox /system/bin/$applet
done
fi

Toolbox install links

watchprops, wipe, vmstat, date, uptime, reboot, getevent, getprop, setprop, id, iftop, ioctl, ionice, log, lsof, nandread, newfs_msdos, notify, ps, r, su, schedtop, sendevent, setconsole, setprop, sleep, smd, start, stop, top

Busybox install links

Whatever the currently installed busybox supports that is not in the list of toolbox install links

Change log

Dec 10 2011, 21:39 UTC:

The script will now leave skip replacing /system/bin/reboot as it needs to be pointed at toolbox

Dec 11 2011, 10:08 UTC:

Added an update zip that will configure busybox and it provides an extended 1.4MB binary instead of the regular 480KB most ROM's provide

Dec 12 2011, 09:25 UTC:

Added new busybox build (1.20.0.git 2011-12-11) since there was problem with the old one for some people

Added more busybox search dirs (/system/sbin and /sbin)

Added Toolbox install to make sure that some android specific links uses toolbox instead of busybox. See list above.

Jun 27 2012, 13:45 UTC:

Better Busybox and Toolbox search

Added symlink check to make sure that busybox only replaces toolbox links and not things like "sh -> mksh"

Nov 17 2012, 10:30 UTC:

Added a custom toolbox binary to the ArmV7 installer

Added latest CM9 busybox binary to the ArmV7 binary

Added an auto search function to locate the binaries on the device

Fixed both installers to work with newer devices that uses EXT4 file system