forked from sehraf/d1-riscv-arch-image-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_kernel.sh
More file actions
executable file
·72 lines (55 loc) · 1.3 KB
/
upload_kernel.sh
File metadata and controls
executable file
·72 lines (55 loc) · 1.3 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/sh
set -e
set -x
. ./consts.sh
if [ -z "$1" ] ; then
echo "Usage: $0 user@host"
exit 1
fi
SSH_TARGET="$1"
SSH="ssh $SSH_TARGET"
if [ ! -f output/Image ] || [ ! -f output/8723ds.ko ] ; then
echo "run ./1_compile.sh first"
exit 1
fi
MODULES="/usr/lib/modules/$KERNEL_RELEASE"
if [ ! -d "$MNT/$MODULES" ] ; then
echo "mount the flashed SD card to $MNT"
exit 1
fi
# make remote temp folder
tmpfile=$($SSH mktemp -d arch-image-builder.XXXXXX)
# copy files
scp "$OUT_DIR"/Image "$OUT_DIR"/8723ds.ko "$SSH_TARGET":"$tmpfile"
scp -r "$MNT/$MODULES" "$SSH_TARGET":"$tmpfile"
# write install script
$SSH sh -c "cat <<EOF > "$tmpfile"/install.sh
#!/usr/bin/sh
set -e
set -x
# backup kernel
if [ -f /boot/Image ] ; then
if [ -f /boot/Image.old ] ; then
rm /boot/Image.old
fi
mv /boot/Image /boot/Image.old
fi
# backup modules
if [ -d "$MODULES" ] ; then
if [ -d "$MODULES".old ] ; then
rm -r "$MODULES".old
fi
mv "$MODULES" "$MODULES".old
fi
# copy modules
mv "$KERNEL_RELEASE" /usr/lib/modules
mv 8723ds.ko /usr/lib/modules/"$KERNEL_RELEASE"/kernel/drivers/net/wireless/8723ds.ko
# copy kernel
mv Image /boot
# depmod
depmod -v
EOF"
# run install script
ssh -t $SSH_TARGET "cd $tmpfile; pwd; sudo sh ./install.sh"
# clean up
$SSH rm -r "$tmpfile"