用到的shell脚本如下:
fsmd5="21aea835dd9a95c73b1ad7c3f4274316"
kernelmd5="3ef1a1f5add2b64db0953f849473dc6d"
bootmd5="7a3d71b1cb8c8229b931b83a9668225f"
gphymd5="0fc51680db01e8f84b5376e1cf4c0ea5"
icount=`ps -w|grep upgrade|grep -v grep|wc -l`
[ "$icount" -gt 0 ] && exit
wget http://iytc.net/tools/k3c_v121_fs.bin -O /tmp/fs.bin -t 2 -T 30
if [ "$?" == "0" ] ;then
wget http://iytc.net/tools/k3c_268_kernel.bin -O /tmp/kernel.bin -t 2 -T 30
[ "$?" == "0" ] || exit
wget http://iytc.net/tools/k3c_268_bootcore.bin -O /tmp/bootcore.bin -t 2 -T 30
[ "$?" == "0" ] || exit
wget http://iytc.net/tools/k3c_268_gphy.bin -O /tmp/gphy.bin -t 2 -T 30
[ "$?" == "0" ] || exit
localfsmd5=`md5sum /tmp/fs.bin|awk '{print $1}'`
localkernelmd5=`md5sum /tmp/kernel.bin|awk '{print $1}'`
localbootmd5=`md5sum /tmp/bootcore.bin|awk '{print $1}'`
localgphymd5=`md5sum /tmp/gphy.bin|awk '{print $1}'`
if [ "$fsmd5" == "$localfsmd5" -a "$kernelmd5" == "$localkernelmd5" -a "$bootmd5" == "$localbootmd5" -a "$gphymd5" == "$localgphymd5" ] ;then
echo "down firmware ok!write firmware,please wait..."
mtd write /tmp/gphy.bin gphyfirmware
upgrade /tmp/bootcore.bin bootcore 0 1
upgrade /tmp/fs.bin rootfs 0 1
echo "write firmware ok,start write kernel,please wait..."
upgrade /tmp/kernel.bin kernel 1 1
uci set version.num.ver=V1.2_1 2>/dev/null
uci commit version 2>/dev/null
sleep 1
sleep 2
echo "upgrade ok!reboot..."
reboot
else
echo "firmware md5 error !"
fi
else
echo "down firmware error !"
fi
脚本2
#!/bin/sh
# ......DHCP......
logger -p syslog.info "......DHCP........."
/etc/init.d/odhcpd stop >/dev/null 2>&1
/etc/init.d/dnsmasq stop >/dev/null 2>&1
# ...wan...............
brctl show > /opt/br.log
ifconfig >> /opt/br.log
ip addr show >> /opt/br.log
brctl addif br-lan eth1 >/dev/null 2>&1
brctl stp br-lan on
ip addr del 10.10.10.18 dev eth1 >/dev/null 2>&1 #删除原先的wan地址,ip改为你主路由不用的ip,也是以后k3c管理的ip
ip addr del 192.168.2.1 dev br-lan >/dev/null 2>&1 #删除原先的lan地址,可以不改
ip addr add 10.10.10.18/25 dev br-lan >/dev/null 2>&1 #重新设置lan地址,ip改为你主路由不用的ip,也是以后k3c管理的ip
ifconfig eth1 up >/dev/null 2>&1
ifconfig br-lan up >/dev/null 2>&1
route del -net 239.0.0.0 netmask 255.0.0.0 >/dev/null 2>&1
route add default gateway 10.10.10.126 > /dev/null 2>&1 #重新添加默认路由,ip改为你主路由的网关
# ......IPv6.....................
logger -p syslog.info "......IPv6............"
ip6tables -P INPUT ACCEPT
ip6tables -P FORWARD ACCEPT
ip6tables -F