71744e610bee086efb8c80e6f4bd4463f3dcf413
[openwrt.git] / target / linux / au1000 / base-files / lib / upgrade / platform.sh
1 KERNEL_IMG="openwrt-au1000-au1500-vmlinux.bin"
2 ROOTFS_IMG="openwrt-au1000-au1500-root.fs"
3
4 platform_check_image() {
5         [ "$ARGC" -gt 1 ] && return 1
6         case "$(get_magic_word "$1")" in
7                 6f70)
8                         ( get_image "$1" | tar -tf - $KERNEL_IMG >/dev/null && \
9                           get_image "$1" | tar -tf - $ROOTFS_IMG >/dev/null) || {
10                                 echo "Invalid image contents"
11                                 return 1
12                         }
13                         return 0;;
14                 *)
15                         echo "Invalid image type"
16                         return 1;;
17         esac
18 }
19
20 platform_do_upgrade() {
21         sync
22         local conf=""
23         [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && conf="-j $CONF_TAR"
24         get_image "$1" | tar -Oxvf - $KERNEL_IMG | mtd write - "kernel"
25         get_image "$1" | tar -Oxvf - $ROOTFS_IMG | mtd $conf write - "rootfs"
26 }
27
28 disable_watchdog() {
29         killall watchdog
30         ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
31                 echo 'Could not disable watchdog'
32                 return 1
33         }
34 }
35
36 append sysupgrade_pre_upgrade disable_watchdog