Sometimes you want to quickly populate a chroot environment with busybox links to various system commands. This small script will help you with that.
The Script
#!/bin/bash
# This script links to busybox
# function: print and execute command
exe()
{
echo "# ""$1"
echo "--------------------------------------------------------------------------------"
$1
}
out=$PWD/out
busybox=/sbin/busybox
cmds=`$busybox --help|grep "^Currently defined functions:-*$" -A10|grep \,`
for cmd in $cmds
do
cmd="${cmd/,/}"
cmdo=`which $cmd 2>/dev/null`
# command exists?
if [ -x "$cmdo" ];then
# link not yet created?
if ! [ -x "$out$cmdo" ]; then
echo "[*] "`man -f $(basename $cmdo)|head -n1|cut -d "-" -f2`
# create the dir?
d=`dirname "$out$cmdo"`
if ! [ -d "$d" ];then
exe "mkdir -p "$d""
fi
# create the link
exe "ln -s $busybox $out$cmdo"
fi
fi
done
exe "mkdir -p $out$(dirname $busybox)"
exe "cp -f $busybox $out$busybox"
| < Prev | Next > |
|---|