参考http://www.motobbs.com/thread-447117-1-1.html
code如下,完成各种判断和软件下载设置。只需要运行下面的脚本就一切搞定了。
代码: 全选
#!bin/bash
#判断是否是ubuntu
echo "make sure your systerm is ubuntu"
#判断是否安装p2ktest
declare -i n=2
declare -i k=0
echo "k=$k"
for (( n=2 ; n<7 ;n=n+1 ))
do
m=`locate p2ktest | grep "bin" | grep "p2ktest" | cut -d "/" -f $n `
echo $m
if [ "$m" = "p2ktest" ] ; then
k=k+1
echo "k=$k"
fi
done
if [ "$k" > "0" ] ; then
echo "your systerm has p2ktest!"
else
echo "there is no p2ktest,and now start to install p2ktest"
echo "if you want to continue , type y "
read yn
if [ "$yn" = "y" ] || [ "$yn" = "Y" ] ; then
echo "continue"
else
echo "exit"
exit
fi
sudo apt-get install p2ktest
fi
#判断是否安装moto4lin
declare -i n=2
declare -i k=0
echo "k=$k"
for (( n=2 ; n<7 ;n=n+1 ))
do
m=`locate moto4lin | grep "bin" | grep "moto4lin" | cut -d "/" -f $n `
echo $m
if [ "$m" = "moto4lin" ] ; then
k=k+1
echo "k=$k"
fi
done
if [ "$k" > "0" ] ; then
echo "your systerm has moto4lin!"
else
echo "there is no p2ktest,and now start to install p2ktest"
echo "if you want to continue , type y "
read yn
if [ "$yn" = "y" ] || [ "$yn" = "Y" ] ; then
echo "continue"
else
echo "exit"
exit
fi
sudo apt-get install moto4lin
fi
#判断是否有motorola_ve.options文件
if [ -f /etc/modprobe.d/motorola_ve.options ] ; then
echo "motorola_ve.options is ok"
else
echo "motorola_ve.options should be created"
获取uid和pid
echo ">>get uid and pid , waiting!"
uid=`lsusb | grep "Motorola" | cut -d " " -f 6 | cut -d ":" -f1`
pid=`lsusb | grep "Motorola" | cut -d " " -f 6 | cut -d ":" -f2`
echo "uid is $uid"
echo "pid is $pid"
#建立文件/etc/modprobe.d/motorola_ve.options
echo "creating /etc/modprobe.d/motorola_ve.options "
sudo echo "alias usb:v"$uid"p"$pid"* usbserial" > /etc/modprobe.d/motorola_ve.options
sudo echo "options usbserial vendor=0x$uid product=0x$pid" >> /etc/modprobe.d/motorola_ve.options
fi
#运行p2ktest
echo "run p2ktest"
sudo p2ktest
#运行moto4lin
echo "run moto4lin"
echo "now you can do what you want to do!"
sudo moto4lin
运行命令:
代码: 全选
sudo bash p2kmoto.sh