--- tftp-iselect.sh 2007/04/25 10:53:40 36 +++ tftp-iselect.sh 2007/11/20 18:14:16 81 @@ -2,20 +2,48 @@ tftp=/srv/tftp/ tmp=/tmp/tftp -fw_info=/root/mdap/fw-info.pl +fw_info=bin/fw-info.pl +sort=$1 +test -z "$sort" && sort="version"; +if [ "$sort" == "version" ] ; then + alt_sort="board" + SORT="sort -k1n" +else + alt_sort="version" + SORT="sort -k2" +fi -echo "Select firmware image to flash: " > $tmp -echo > $tmp +#which=`find $tftp -type f | xargs -i $fw_info {} 2>/dev/null | sort | sed -e "s!$tftp!!" -e 's!^!!' -e 's!^\(.* BANT-R\)!\1!' | iselect -c -n "Select firmware file"` +$fw_info $tftp/ 2>/dev/null | sed -e "s!$tftp/*!!" > $tmp.all -which=`find $tftp -type f | xargs -i $fw_info {} 2>/dev/null | sed -e "s!$tftp!!" -e 's!^!!' -e 's!^\(.* BANT-R\)!\1!' | iselect -c -n "Select firmware file"` +echo -e "Currently selected versions to flash:\n" > $tmp -test -z "$which" && exit +grep " BANT-.$" $tmp.all > $tmp.selected +cat $tmp.selected >> $tmp -version=`echo $which | cut -d" " -f1` -path=`echo $which | cut -d" " -f2-` +echo -e "\nAll versions available by $sort:" >> $tmp +echo -e "Sort by $alt_sort\n" >> $tmp -echo "Using $path [$version]" +grep -v -f $tmp.selected $tmp.all | $SORT | sed -e 's!^!!' >> $tmp -cp $tftp/$path $tftp/BANT-R.new && mv $tftp/BANT-R.new $tftp/BANT-R +which=`iselect -c -n "Select firmware" < $tmp` + +test -z "$which" && echo "No change" && exit + +if [ ! -z "`echo $which | grep -E '(board|version)'`" ] ; then + $0 $which +else + + version=`echo $which | cut -d" " -f1` + board=`echo $which | cut -d" " -f2` + path=`echo "$which" | cut -c34-` + + #echo "$version|$board|$path" + + cp $tftp/$path $tftp/$board.new && mv $tftp/$board.new $tftp/$board || exit + chmod 644 $tftp/$board || exit + + echo "Using $path for $board [$version]" + +fi -rm $tmp