-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash_latest.sh
executable file
·60 lines (52 loc) · 1.66 KB
/
flash_latest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Allows the user to choose a kernel version and copies .dtb files to /etc/flash-kernel
# - defaults to current highest available kernel version
#
cdir=`pwd`
versions=`dpkg --list | grep linux-image-[0-9].* | cut -d" " -s -f 3 | sed s/^linux-image-// | sort -V`
current=`/usr/bin/uname -r`
out=/etc/flash-kernel/dtbs
echo -e "\nAvailable kernels:"
option=0
declare -a klist
for ver in $versions ; do
option=$((option+1))
klist[$option]=$ver
echo -n " [$option] $ver"
if [ $ver == $current ] ; then
echo " - currently running kernel"
else
echo
fi
done
read -p "Which kernel to link? [$option]: " choice
if [ -z "$choice" ] ; then choice=$option ; fi
echo
revision=${klist[$choice]}
if [ -z "$revision" ] ; then
echo "No valid kernel selected, exiting."
exit
fi
if [ -d "$revision" ]; then
echo -e "Cleaning '$out/' and copying in device tree binaries from '$revision/'"
sudo rm -f $out/*.dtb $out/origin*
else
echo "No builds found for selected kernel version: $revision"
echo " Try running ./make_trees.sh to generate them"
exit 1
fi
for file in `cd "$revision" ; ls *.dtb`; do
echo " $cdir/$revision/$file --> $out/$file"
sudo cp $cdir/$revision/$file $out
done
# Add a link to the output folder..
sudo ln -s $cdir/$revision $out/origin:$revision
echo
read -p "Run 'flash-kernel' to apply device tree? [Y]: " choice
if [[ "$choice" == [Yy]* ]] || [ -z "$choice" ] ; then
sudo flash-kernel
echo -e "\nIf flash-kernel was successful and configured properly the new device tree will be used after reboot"
else
echo "The new device tree will be used the next time flash-kernel is run"
fi
# fin