forked from askeing/B2G-flash-tool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reset_phone.sh
executable file
·79 lines (65 loc) · 2.04 KB
/
reset_phone.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#==========================================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#==========================================================================
# Description:
# This script was written for reset the Firefox OS phone.
#
# Author: Askeing [email protected]
#
# History:
# 2014/02/27 Askeing: v1.0 First release.
#==========================================================================
####################
# Functions #
####################
## Show usage
function helper(){
echo -e "This script was written to reset the Firefox OS phone.\n"
echo -e "Usage: ./reset_phone.sh [parameters]"
echo -e " -s <serial number>\tdirects command to device with the given serial number."
echo -e " -h|--help\tdisplay help."
exit 0
}
## adb with flags
function run_adb() {
adb $ADB_FLAGS $@
}
#########################
# Processing Parameters #
#########################
## distinguish platform
case `uname` in
"Linux")
## add getopt argument parsing
TEMP=`getopt -o s::h --long help \
-n 'invalid option' -- "$@"`
if [ $? != 0 ]; then echo "Try '--help' for more information." >&2; exit 1; fi
eval set -- "$TEMP";;
"Darwin");;
esac
while true
do
case "$1" in
-s)
case "$2" in
"") shift 2;;
*) ADB_DEVICE=$2; ADB_FLAGS+="-s $2"; shift 2;;
esac ;;
-h|--help) helper; exit 0;;
--) shift;break;;
"") shift;break;;
*) helper; echo error occured; exit 1;;
esac
done
###################
# Run Reset Phone #
###################
echo "### Starting to Reset Firefox OS Phone..."
run_adb shell rm -r /cache/*
run_adb shell mkdir /cache/recovery > /dev/null
run_adb shell 'echo "--wipe_data" > /cache/recovery/command' &&
run_adb reboot recovery
echo "### Reset of Firefox OS Phone done."