255699bb31978725f1d213907b68bb535dee1ba6
2 # Copyright (C) 2014 OpenWrt.org
5 platform_get_rootfs
() {
8 if read cmdline
< /proc
/cmdline
; then
11 rootfsdev
="${cmdline##*root=}"
12 rootfsdev
="${rootfsdev%% *}"
20 platform_copy_config
() {
21 case "$(board_name)" in
23 mount
-t vfat
/dev
/sda1
/mnt
24 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
28 mount
-t vfat
/dev
/mmcblk1p1
/mnt
29 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
34 mount
-t vfat
/dev
/mmcblk0p1
/mnt
35 cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
47 local board_dir
=$
(tar tf
"$tar_file" |
grep -m 1 '^sysupgrade-.*/$')
48 board_dir
=${board_dir%/}
49 [ -n "$board_dir" ] ||
return 1
53 if [ $board = "itus,shield-router" ]; then
54 # mmcblk1p1 (fat) contains all ELF-bin images for the Shield
55 mount
/dev
/mmcblk1p1
/boot
57 echo "flashing Itus Kernel to /boot/$kernel (/dev/mmblk1p1)"
58 tar -Oxf $tar_file "$board_dir/kernel" > /boot
/$kernel
60 mount
-t vfat
/dev
/$kernel /boot
62 [ -f /boot
/vmlinux
.64 -a ! -L /boot
/vmlinux
.64 ] && {
63 mv /boot
/vmlinux
.64 /boot
/vmlinux
.64.previous
64 mv /boot
/vmlinux
.64.md5
/boot
/vmlinux
.64.md5.previous
67 echo "flashing kernel to /dev/$kernel"
68 tar xf
$tar_file $board_dir/kernel
-O > /boot
/vmlinux
.64
69 md5sum /boot
/vmlinux
.64 | cut
-f1 -d " " > /boot
/vmlinux
.64.md5
72 echo "flashing rootfs to ${rootfs}"
73 tar xf
$tar_file $board_dir/root
-O |
dd of
="${rootfs}" bs
=4096
79 platform_do_upgrade
() {
81 local board
=$
(board_name
)
82 local rootfs
="$(platform_get_rootfs)"
85 [ -b "${rootfs}" ] ||
return 1
96 kernel
=ItusrouterImage
102 platform_do_flash
$tar_file $board $kernel $rootfs
107 platform_check_image
() {
108 local board
=$
(board_name
)
111 local board_dir
=$
(tar tf
"$tar_file" |
grep -m 1 '^sysupgrade-.*/$')
112 board_dir
=${board_dir%/}
113 [ -n "$board_dir" ] ||
return 1
118 itus
,shield-router | \
119 ubnt
,edgerouter-4 | \
121 local kernel_length
=$
(tar xf
$tar_file $board_dir/kernel
-O |
wc -c 2> /dev
/null
)
122 local rootfs_length
=$
(tar xf
$tar_file $board_dir/root
-O |
wc -c 2> /dev
/null
)
123 [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
124 echo "The upgrade image is corrupt."
131 echo "Sysupgrade is not yet supported on $board."