[Bash Script][xdotool][Embedded System] How to use script to download firmware automatically
#!/bin/bash
# cp file from A place to tftp
DATE=`date +%m%d`
Comannd='set'
Parameter='UBFINAME1 '
Filename='a-3.5.0.24-12'$DATE'.img'
Bootloader='u-boot.bin'
myapp1_filesystem='myapp1.sqfs.pad'
myapp2_filesystem='myapp2.sqfs.pad'
echo " "
echo "*********************"
echo "** **"
echo "** mount to server **"
echo "** **"
echo "*********************"
echo " "
if [ ! -d "~/111.2.1.69" ]; then
gvfs-mount smb://111.2.1.69/home/
gvfs-mount smb://111.2.1.93/home/
gvfs-mount smb://111.2.1.148/home/
sudo ln -sf /home/egf/.gvfs/home\ on\ 111.2.1.69/ ../111.2.1.69
sudo ln -sf /home/egf/.gvfs/home\ on\ 111.2.1.93/ ../111.2.1.93
sudo ln -sf /home/egf/.gvfs/home\ on\ 111.2.1.148/ ../111.2.1.148
fi
echo " "
echo " "
echo "*************************************************************************************************************"
echo "** **"
echo "** 1./home/egf/111.2.1.69/luke/20121012/abc/base/a/build/a/images/ **"
echo "** **"
echo "*************************************************************************************************************"
echo "Please input download folder : "
read folder # read character input
case $folder in
1)
File_Position='/home/egf/111.2.1.69/luke/20121012/abc/base/a/build/a/images/'
;;
*)
clear
sleep 1;; # leave the message on the screen for 5 seconds
esac
# display the menu
echo " "
echo " "
echo " ***************************************************************************"
echo " ** **"
echo " ** Enter the number of the system **"
echo " ** a - Kernel **"
echo " ** b - DOCSIS **"
echo " ** c - Intel GW code **"
echo " ** d - APP1(DLNA, NTFS-3G) (APP1 = myapp1.sqfs.pad) **"
echo " ** e - APP2 (WIFI Driver+SAMBA)(APP2 = myapp2.sqfs.pad) **"
echo " ** f - Bootloader **"
echo " ** g - NVRAM **"
echo " ** **"
echo " ** 1 - Bootloader Upgrade **"
echo " ** 2 - "$Filename" (a + b + c) **"
echo " ** 3 - "$Filename".medium (a + b + c + d + e) **"
echo " ** 4 - "$Filename".full (a + b + c + d + e + f + g) **"
echo " ** 5 - myapp1.sqfs.pad ( filesystem - DLNA/NTFS3g ) **"
echo " ** 6 - myapp2.sqfs.pad ( filesystem - WIFI driver/SAMBA ) **"
echo " ** **"
echo " ***************************************************************************"
echo "File location : \033[1;31m $File_Position \033[m"
echo "Please choose a number : "
read input # read character input
case $input in
1)
# Update Bootloader
rm $Bootloader
rsync -azv --progress $File_Position$Bootloader /home/egf/tftp
chmod 777 ./$Bootloader
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type 'run update_uboot'
xdotool key 'Return'
xdotool type 'protect off 0x48020000 +20000'
xdotool key 'Return'
xdotool type 'erase 0x48020000 +20000'
xdotool key 'Return'
xdotool type 'reset'
xdotool key 'Return' ;;
2)
# It is the same as before. Remember, this image do not contect APP1 & APP2.
rm $Filename
rsync -azv --progress $File_Position$Filename /home/egf/tftp
chmod 777 ./$Filename
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type $Comannd
xdotool key space
xdotool type $Parameter
xdotool key space
xdotool type $Filename
xdotool key 'Return'
sleep 0.1
xdotool type 'run update1'
xdotool key 'Return' ;;
3)
# Remember, this image contect APP1 & APP2. Kernel + DOCSIS + Intel GW code + APP1(DLNA, NTFS-3G) + APP2 (WIFI Driver+SAMBA).
rm $Filename.medium
rsync -azv --progress $File_Position$Filename.medium /home/egf/tftp
chmod 777 ./$Filename.medium
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type $Comannd
xdotool key space
xdotool type $Parameter
xdotool key space
xdotool type $Filename.medium
xdotool key 'Return'
sleep 0.1
xdotool type 'run update1'
xdotool key 'Return' ;;
4)
# Remember, this image contect APP1 & APP2. Kernel + DOCSIS + Intel GW code + APP1(DLNA, NTFS-3G) + APP2 (WIFI Driver+SAMBA) + Bootloader + NVRAM.
rm $Filename.full
rsync -azv --progress $File_Position$Filename.full /home/egf/tftp
chmod 777 ./$Filename.full
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type $Comannd
xdotool key space
xdotool type $Parameter
xdotool key space
xdotool type $Filename.full
xdotool key 'Return'
sleep 0.1
xdotool type 'run update1'
xdotool key 'Return' ;;
5)
# DLNA/NTFS3g code change to the CM, please download 'a-3.5.0.24-121001.img.full' or 'myapp1.sqfs.pad' to CM in order to apply new setting.
rm $myapp1_filesystem
rsync -azv --progress $File_Position$myapp1_filesystem /home/egf/tftp
chmod 777 ./$myapp1_filesystem
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type $Comannd
xdotool key space
xdotool type $Parameter
xdotool key space
xdotool type $myapp1_filesystem
xdotool key 'Return'
sleep 0.1
xdotool type 'run updatefss2'
xdotool key 'Return' ;;
6)
# WIFI driver/SAMBA code change to the CM, download 'a-3.5.0.24-121001.img.full' or 'myapp2.sqfs.pad' to CM in order to apply new setting.
rm $myapp2_filesystem
rsync -azv --progress $File_Position$myapp2_filesystem /home/egf/tftp
chmod 777 ./$myapp2_filesystem
# change ifconfig eth0 IP address
sudo ifconfig eth1 192.168.100.20
ifconfig
sleep 1
#use xdotool finish download code into board
xdotool key alt+1
xdotool type 'set serverip 192.168.100.20'
xdotool key 'Return'
sleep 0.1
xdotool type $Comannd
xdotool key space
xdotool type $Parameter
xdotool key space
xdotool type $myapp2_filesystem
xdotool key 'Return'
sleep 0.1
xdotool type 'run updatefss3'
xdotool key 'Return' ;;
*) clear
echo " "
echo " "
echo "I didn't understand that input."
sleep 5 ;; # leave the message on the screen for 5 seconds
esac
2012年10月12日 星期五
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言