summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscript/run-factory-reset.sh77
1 files changed, 46 insertions, 31 deletions
diff --git a/script/run-factory-reset.sh b/script/run-factory-reset.sh
index 30307fe..c84c571 100755
--- a/script/run-factory-reset.sh
+++ b/script/run-factory-reset.sh
@@ -45,6 +45,14 @@ done
cd ${ROOTDIR}
+check_user_partition() {
+ RET=`/bin/cat /etc/fstab | /bin/grep "user"`
+ if [ "z$RET" = "z" ]; then
+ echo "There is no user partition: 2 partitions?" >> $logfile
+ NO_USRPART=1
+ fi
+}
+
kill_normal_daemons () {
LIST=`/bin/ls /proc/`
for i in $LIST
@@ -121,34 +129,36 @@ fs_ready() {
/bin/umount -lf ${OPT}/storage/sdcard
# modem binary images should be preserved.
/bin/umount -lf ${OPT}/modem
+ if [ "z$NO_USRPART" = "z" ]; then
# phone usr partition should be reset
- /bin/mkdir -p $USRDATADIR
- /bin/mount $USRDATADIR
- mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $1}'`
- #device=`/bin/grep "$USRDATADIR" /etc/fstab | /usr/bin/awk '{print $1}'`
- device=`blkid --match-token LABEL=user -o device`
- device=`/usr/bin/readlink -f $device`
- if [[ "z$mret" != "z" && "$mret" != "$device" ]]; then
- echo "$mret != $device" >> $logfile
- echo "$USRDATADIR may be encrypted : FAIL" >> $logfile
+ /bin/mkdir -p $USRDATADIR
+ /bin/mount $USRDATADIR
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $1}'`
+ #device=`/bin/grep "$USRDATADIR" /etc/fstab | /usr/bin/awk '{print $1}'`
+ device=`blkid --match-token LABEL=user -o device`
+ device=`/usr/bin/readlink -f $device`
+ if [[ "z$mret" != "z" && "$mret" != "$device" ]]; then
+ echo "$mret != $device" >> $logfile
+ echo "$USRDATADIR may be encrypted : FAIL" >> $logfile
+ check_fail
+ fi
+ if [[ "z$mret" = "z" && "z$device" != "z" ]]; then
+ # mount failed. format and remount
+ echo "$USRDATADIR mount failed. format and retry to mount again" >> $logfile
+ fstype=`/bin/grep "$USRDATADIR " /etc/fstab | /usr/bin/awk '{print $3}'`
+ fstype=`blkid --match-token LABEL=user -o device`
+ /sbin/mkfs.$fstype $device -F
+ /bin/mount -t $fstype $device $USRDATADIR
+ fi
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $2}'`
+ if [ "z$mret" = "z" ]; then
+ echo "$USRDATADIR MOUNT : FAIL" >> $logfile
+ # reboot and retry
+ /bin/sync
+ /sbin/reboot
+ fi
check_fail
fi
- if [[ "z$mret" = "z" && "z$device" != "z" ]]; then
- # mount failed. format and remount
- echo "$USRDATADIR mount failed. format and retry to mount again" >> $logfile
- fstype=`/bin/grep "$USRDATADIR " /etc/fstab | /usr/bin/awk '{print $3}'`
- fstype=`blkid --match-token LABEL=user -o device`
- /sbin/mkfs.$fstype $device -F
- /bin/mount -t $fstype $device $USRDATADIR
- fi
- mret=`/bin/grep "$USRDATADIR " /proc/mounts | /usr/bin/awk '{print $2}'`
- if [ "z$mret" = "z" ]; then
- echo "$USRDATADIR MOUNT : FAIL" >> $logfile
- # reboot and retry
- /bin/sync
- /sbin/reboot
- fi
- check_fail
}
disable_keys() {
@@ -222,6 +232,7 @@ fi
##kill_before_reset
+check_user_partition
fs_ready
echo "file system ready for factory reset" >> $logfile
@@ -252,18 +263,22 @@ if [ -r /usr/bin/resetCCMode ]; then
/usr/bin/resetCCMode >> $logfile
fi
-/sbin/fstrim -v $USRDATADIR >> $logfile
+if [ "z$NO_USRPART" = "z" ]; then
+ /sbin/fstrim -v $USRDATADIR >> $logfile
+fi
# Delete finished. Restore starts here.
cd /
$RSTCMD
echo "$RSTCMD return $?" >> $logfile
-mret=`/bin/grep "$USRDATADIR " /proc/mounts | /bin/grep rw | /usr/bin/awk '{print $2}'`
-if [ "z$mret" = "z" ]; then
- echo "$USRDATADIR is not RW MOUNTED, RESTORATION : FAIL" >> $logfile
- /bin/rm -rf $USRDATADIR
- check_fail
+if [ "z$NO_USRPART" = "z" ]; then
+ mret=`/bin/grep "$USRDATADIR " /proc/mounts | /bin/grep rw | /usr/bin/awk '{print $2}'`
+ if [ "z$mret" = "z" ]; then
+ echo "$USRDATADIR is not RW MOUNTED, RESTORATION : FAIL" >> $logfile
+ /bin/rm -rf $USRDATADIR
+ check_fail
+ fi
fi
#check_verify