#!/bin/bash stty erase '^H' function checkVerisonFormat() { CustomerSWVersion=$1 inputVersion=$2 curVer=`echo ${CustomerSWVersion:0:${#CustomerSWVersion}-3}` len=${#inputVersion} if [ $len -gt 7 ];then echo "input length is ok" >console else echo "Input length to short,please input again !" count=1 return $count fi input=`echo ${inputVersion:0:${#inputVersion}-3}` if [ $curVer == $input ];then count=0 return $count else echo "Input the version is wrong!please check " count=1 return $count fi } #loop main echo -e "\033[32m Change Version Step \033[0m" CustomerSWVersion=`cat deviceParaStatic.conf | grep CustomerSWVersion | awk -F '=' '{print$2}'` InnerSWVersion=`cat deviceParaStatic.conf | grep InnerSWVersion | awk -F '=' '{print$2}'` flag=0 while true do if [ $flag == 0 ];then echo -e "The CustomerSWVersion is \033[31m $CustomerSWVersion \033[0m" echo "you want to change CustomerSWVersion to:(enter space to skip)" read name if [ $name ];then a=$(checkVerisonFormat $CustomerSWVersion $name) if [ $? -eq 0 ];then sed -i "s|$CustomerSWVersion|$name|g" "deviceParaStatic.conf" sed -i "s|$CustomerSWVersion|$name|g" "devInf.conf" echo "$name" > ./.././.././.././../app_bsp/version/fwver.conf #app_bsp/version/fwver.conf echo -e "\033[32m you change CustomerSWVersion to $name success! \033[0m" echo -e "\033[32m deviceParaStatic.conf \033[0m" echo -e "\033[32m devInf.conf \033[0m" echo -e "\033[32m fwver.conf \033[0m" flag=1 fi else echo -e "\033[31m The input is a space ,skip the setting! \033[0m" flag=1 fi echo -e "\033[31m $a \033[0m" fi if [ $flag == 1 ];then echo -e "the InnerSWVersion is \033[31m $InnerSWVersion \033[0m" echo "you want to change InnerSWVersion to:(enter space to skip)" read name if [ $name ];then a=$(checkVerisonFormat $InnerSWVersion $name) if [ $? -eq 0 ];then sed -i "s|$InnerSWVersion|$name|g" "deviceParaStatic.conf" echo -e "\033[32m you change InnerSWVersion to $name success \033[0m" echo -e "\033[32m deviceParaStatic.conf \033[0m" flag=2 fi else echo -e "\033[31m The input is a space ,skip the setting! \033[0m" flag=2 fi echo -e "\033[31m $a \033[0m" fi if [ $flag == 2 ];then break fi done