#!/bin/sh
 if [ ! -f "/sdcard/upd/rb/rtupdateagent" ]; then
 cp /system/bin/ota/rtupdateagent /sdcard/upd/rb/rtupdateagent 
 fi 
 if [ $1 = "test" ]; then
 echo 'Starting normal delta test.. ' > /sdcard/upd/rb_normal.log
 /sdcard/upd/rb/rtupdateagent -op=test -delta=/sdcard/upd/rb/normal_04.18.10CLEA-14-06__05.003.004CLEA-15-06.delta -fwpart=Flash -result=/sdcard/upd/rtupdateresult.txt -verbose=1 -logfile=/sdcard/upd/rb_normal.log -reboot=0
 else
 echo 'Starting normal update.. ' > /sdcard/upd/rb_normal.log
 if [ -f "/system/vendor/roadtrack/maps/brazil/Brazil-100693.meta.dct" ]; then
 mount -o rw,remount /system
 cp /sdcard/upd/Brazil-100693.meta.dct /system/vendor/roadtrack/maps/brazil/ 
 sed -i s/-05$/-06/g /system/vendor/roadtrack/maps/version.txt 
 echo "1" > /system/vendor/roadtrack/maps/maps.md5
 (cd /system/vendor/roadtrack/maps/;find . -type f| grep -v maps.md5 | LC_ALL=C sort | xargs md5sum | md5sum ) >> /system/vendor/roadtrack/maps/maps.md5
 chmod 666 /system/vendor/roadtrack/maps/maps.md5
 mount -o ro,remount /system
 fi 
 if [ -f "/system/vendor/roadtrack/maps/argentina_and_uruguay/Argentina_and_Uruguay-100693.meta.dct" ]; then
 mount -o rw,remount /system
 cp /sdcard/upd/Argentina_and_Uruguay-100693.meta.dct /system/vendor/roadtrack/maps/argentina_and_uruguay/ 
 sed -i s/-05$/-06/g /system/vendor/roadtrack/maps/version.txt 
 echo "1" > /system/vendor/roadtrack/maps/maps.md5
 (cd /system/vendor/roadtrack/maps/;find . -type f| grep -v maps.md5 | LC_ALL=C sort | xargs md5sum | md5sum ) >> /system/vendor/roadtrack/maps/maps.md5
 chmod 666 /system/vendor/roadtrack/maps/maps.md5
 mount -o ro,remount /system
 fi 
 /sdcard/upd/rb/rtupdateagent -delta=/sdcard/upd/rb/normal_04.18.10CLEA-14-06__05.003.004CLEA-15-06.delta -fwpart=Flash -result=/sdcard/upd/rtupdateresult.txt -op=update -verbose=1 -logfile=/sdcard/upd/rb_normal.log -reboot=0
 fi
