1 |
#!/bin/sh |
2 |
|
3 |
tftp=/srv/tftp/ |
4 |
tmp=/tmp/tftp |
5 |
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"` |
17 |
$fw_info $tftp/ 2>/dev/null | sed -e "s!$tftp/*!!" > $tmp.all |
18 |
|
19 |
echo -e "Currently selected versions to flash:\n" > $tmp |
20 |
|
21 |
grep " BANT-.$" $tmp.all > $tmp.selected |
22 |
cat $tmp.selected >> $tmp |
23 |
|
24 |
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 | $SORT | sed -e 's!^!<s>!' >> $tmp |
28 |
|
29 |
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 |
|