Skip to content

Instantly share code, notes, and snippets.

@kangear
Created November 7, 2014 09:56
Show Gist options
  • Save kangear/f479109606da1d12093a to your computer and use it in GitHub Desktop.
Save kangear/f479109606da1d12093a to your computer and use it in GitHub Desktop.
#!/system/bin/sh
# 1.判断busybox是否存在 如果存在获致其路径
echo "Determining If 'busybox' Exist..."
BUSYBOX_PATH=`busybox find / -name busybox -type f`
if [ $? != 0 ] ; then
echo "Sorry, 'busybox' NOT exist"
exit 1
fi
echo "'busybox' exist will GO ON."
# 2.创建/system/bin/cmdbak目录以备份要替换掉的命令
echo "Create '/system/bin/cmdbak' for backup your cmds ..."
CMDBAK=/system/bin/cmdbak/
if [ ! -d $CMDBAK ] ; then
mkdir /system/bin/cmdbak/
if [ $? != 0 ] ; then
echo "Create /system/bin/cmdbak failed. :( "
exit 1
fi
fi
echo "Create ok will GO ON."
# 3.开始备份和创建链接
echo "Begin backup your old cmd And Create new busybox cmd ..."
CMDS="ls " #cmd you can add it.
for x in $CMDS
do
if [ -fl "/system/bin/$x" ] ; then
mv /system/bin/$x /system/bin/cmdbak/
if [ $? != 0 ] ; then
echo "mv /system/bin/$x /system/bin/cmdbak/ failed. :( "
exit 1
fi
fi
ln -s $BUSYBOX_PATH /system/bin/$x
if [ $? != 0 ] ; then
echo "ln -s $BUSYBOX_PATH /system/bin/$x failed. :( "
exit 1
fi
done
# 4.报告创建状态
echo "Create busybox cmd OK!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment