/[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 78 by dpavlin, Sun Nov 18 16:25:26 2007 UTC revision 81 by dpavlin, Tue Nov 20 18:14:16 2007 UTC
# Line 3  Line 3 
3  tftp=/srv/tftp/  tftp=/srv/tftp/
4  tmp=/tmp/tftp  tmp=/tmp/tftp
5  fw_info=bin/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  #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"`  #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  $fw_info $tftp/ 2>/dev/null | sort -k 2,1 -n | sed -e "s!$tftp/*!!" > $tmp.all  $fw_info $tftp/ 2>/dev/null | sed -e "s!$tftp/*!!" > $tmp.all
18    
19  echo -e "Currently selected version for flash:\n" > $tmp  echo -e "Currently selected versions to flash:\n" > $tmp
20    
21  grep "  BANT-.$" $tmp.all > $tmp.selected  grep "  BANT-.$" $tmp.all > $tmp.selected
22  cat $tmp.selected >> $tmp  cat $tmp.selected >> $tmp
23    
24  echo -e "\nAll versions available:\n" >> $tmp  echo -e "\nAll versions available by $sort:" >> $tmp
25    echo -e "<s:$alt_sort>Sort by $alt_sort\n" >> $tmp
26    
27  grep -v -f $tmp.selected $tmp.all | sed -e 's!^!<s>!' >> $tmp  grep -v -f $tmp.selected $tmp.all | $SORT |  sed -e 's!^!<s>!' >> $tmp
28    
29  which=`iselect -c -n "Select firmware" < $tmp`  which=`iselect -c -n "Select firmware" < $tmp`
30    
31  test -z "$which" && echo "No change" && exit  test -z "$which" && echo "No change" && exit
32    
33  version=`echo $which | cut -d" " -f1`  if [ ! -z "`echo $which | grep -E '(board|version)'`" ] ; then
34  board=`echo $which | cut -d" " -f2`          $0 $which
35  path=`echo "$which" | cut -c34-`  else
36    
37  #echo "$version|$board|$path"          version=`echo $which | cut -d" " -f1`
38            board=`echo $which | cut -d" " -f2`
39            path=`echo "$which" | cut -c34-`
40    
41  cp $tftp/$path $tftp/$board.new && mv $tftp/$board.new $tftp/$board || exit          #echo "$version|$board|$path"
42    
43  echo "Using $path for $board [$version]"          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    

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

  ViewVC Help
Powered by ViewVC 1.1.26