/[mdap]/tftp-iselect.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /tftp-iselect.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 38 by dpavlin, Mon May 7 18:34:11 2007 UTC revision 81 by dpavlin, Tue Nov 20 18:14:16 2007 UTC
# Line 2  Line 2 
2    
3  tftp=/srv/tftp/  tftp=/srv/tftp/
4  tmp=/tmp/tftp  tmp=/tmp/tftp
5  fw_info=/root/mdap/fw-info.pl  fw_info=bin/fw-info.pl
6    sort=$1
7    test -z "$sort" && sort="version";
8    if [ "$sort" == "version" ] ; then
9            alt_sort="board"
10            SORT="sort -k1n"
11    else
12            alt_sort="version"
13            SORT="sort -k2"
14    fi
15    
16  echo "Select firmware image to flash: " > $tmp  #which=`find $tftp -type f | xargs -i $fw_info {} 2>/dev/null | sort | sed -e "s!$tftp!!" -e 's!^!<s>!' -e 's!^<s>\(.* BANT-R\)!\1!' | iselect -c -n "Select firmware file"`
17  echo > $tmp  $fw_info $tftp/ 2>/dev/null | sed -e "s!$tftp/*!!" > $tmp.all
18    
19  which=`find $tftp -type f | xargs -i $fw_info {} 2>/dev/null | sort | sed -e "s!$tftp!!" -e 's!^!<s>!' -e 's!^<s>\(.* BANT-R\)!\1!' | iselect -c -n "Select firmware file"`  echo -e "Currently selected versions to flash:\n" > $tmp
20    
21  test -z "$which" && exit  grep "  BANT-.$" $tmp.all > $tmp.selected
22    cat $tmp.selected >> $tmp
23    
24  version=`echo $which | cut -d" " -f1`  echo -e "\nAll versions available by $sort:" >> $tmp
25  path=`echo $which | cut -d" " -f2-`  echo -e "<s:$alt_sort>Sort by $alt_sort\n" >> $tmp
26    
27  echo "Using $path [$version]"  grep -v -f $tmp.selected $tmp.all | $SORT |  sed -e 's!^!<s>!' >> $tmp
28    
29  cp $tftp/$path $tftp/BANT-R.new && mv $tftp/BANT-R.new $tftp/BANT-R  which=`iselect -c -n "Select firmware" < $tmp`
30    
31    test -z "$which" && echo "No change" && exit
32    
33    if [ ! -z "`echo $which | grep -E '(board|version)'`" ] ; then
34            $0 $which
35    else
36    
37            version=`echo $which | cut -d" " -f1`
38            board=`echo $which | cut -d" " -f2`
39            path=`echo "$which" | cut -c34-`
40    
41            #echo "$version|$board|$path"
42    
43            cp $tftp/$path $tftp/$board.new && mv $tftp/$board.new $tftp/$board || exit
44            chmod 644 $tftp/$board || exit
45    
46            echo "Using $path for $board [$version]"
47    
48    fi
49    
 rm $tmp  

Legend:
Removed from v.38  
changed lines
  Added in v.81

  ViewVC Help
Powered by ViewVC 1.1.26