forked from ev3dev/ev3dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
live_update
executable file
·53 lines (39 loc) · 1.14 KB
/
live_update
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
#! /bin/bash
KIMAGE="./uImage"
MODPATH="./modules"
MODTAR="./modules.tar"
KRELEASE="3.3.0+"
if [ $# -lt 2 ]; then
printf 'usage: %s <user@hostname> <rpath>\n' "$0"
printf '\ne.g.: %s root@ev3 /\n' "$0"
exit 1
fi
if [ ! -r $KIMAGE ]; then
printf '%s: %s file not found\n' "$0" "$KIMAGE" 1>&2
exit 1
fi
if [ ! -d $MODPATH ]; then
printf '%s: %s directory not found\n' "$0" "$MODPATH" 1>&2
exit 1
fi
printf '%s: using kernel: %s\n' "$0" "$KIMAGE"
printf '%s: using modules: %s\n' "$0" "$MODPATH"
# tar-up the module directory for shipping
(cd $MODPATH && tar cf - .) > $MODTAR
if [ ! -s $MODTAR ]; then
printf '%s: failed to tar-up modules..\n' "$0"
rm -f $MODTAR
exit 1
fi
printf 'copying and unpacking modules...\n'
RCMD=$(printf '(cd %s && tar xvf -)' "$2")
cat $MODTAR | ssh $1 "$RCMD"
printf 'running depmod on EV3...\n'
RCMD=$(printf '(cd %slib/modules/%s/ && depmod)' "$2" "$KRELEASE")
ssh $1 "$RCMD"
RCMD=$(printf '(cd %s && chown -R root.root lib)' "$2")
ssh $1 "$RCMD"
printf 'saving existing image, copying new...\n'
RCMD=$(printf '(cd /media/mmc_p1/ && mv -v uImage uImage.old)')
ssh $1 "$RCMD"
scp "$KIMAGE" "$1:/media/mmc_p1/uImage"