-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
157 lines (131 loc) · 2.93 KB
/
start.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
TOKEN=""
help()
{
echo "##############################################"
echo "### Pls make sure open \"OEM lock\" ###"
echo "### Example:./start.sh unlock -s SN ###"
echo "### unlock/lock: unlock/lock bootloader ###"
echo "### -s SN: unlock/lock one device ###"
echo "### -a: unlock/lock all devices ###"
echo "### ###"
echo "### Add by lxj ###"
echo "##############################################"
}
unlock()
{
echo "################# Unlock bootloader #######################"
checkDevice $1
echo "3.Get device token"
sudo ./fastboot oem get_identifier_token > token.txt 2>&1
TOKEN=`cat token.txt | grep "^[0-9]\{1\}"`
if [ "${TOKEN}" = "" ];
then
echo "Identifier token: Null"
sudo ./fastboot reboot > /dev/null 2>&1
exit -1
fi
echo "Identifier token: $TOKEN"
echo "4.Unlock bootloader"
sudo ./signidentifier_unlockbootloader.sh ${TOKEN} rsa4096_vbmeta.pem signature.bin > /dev/null 2>&1
echo "5.flashing bootloader,Please press volume down botton !!!"
sudo ./fastboot flashing unlock_bootloader signature.bin > /dev/null 2>&1
sleep 5
if [ $? = 0 ] ;
then
echo "flashing success!"
else
echo "flashing fail! Is already unlock?"
fi
echo "6.Reboot"
sudo ./fastboot reboot > /dev/null 2>&1
}
lock()
{
echo "################# Lock bootloader #######################"
checkDevice $1
echo "3.Lock bootloader"
sudo ./fastboot flashing lock_bootloader > /dev/null 2>&1
if [ $? = 0 ] ;
then
echo "lock success!"
else
echo "lock fail!"
fi
echo "4.Reboot"
sudo ./fastboot reboot > /dev/null 2>&1
}
checkDevice()
{
echo "1.Reboot into bootloader: $1"
if [ "$1" != "" ];then
adb -s $1 reboot bootloader
if [ $? = 1 ];then
echo "Make sure SN: $1 is right and usb debug is open!!"
exit -1
fi
else
adb reboot bootloader
if [ $? = 1 ];then
exit -1
fi
fi
sleep 5
echo "2.Check devices"
devices=`sudo ./fastboot devices | grep "fastboot"`
if [ "${devices}" = "" ];
then
echo "Not found devices"
sudo ./fastboot reboot > /dev/null 2>&1
fi
}
lockAll()
{
echo "List Devices"
devices=`adb devices | grep -sw "device"`
devices=${devices//device/''} #remove char:device
for line in ${devices}
do
lock $line
done
}
unlockAll()
{
echo "List Devices"
devices=`adb devices | grep -sw "device"`
devices=${devices//device/''} #remove char:device
for line in ${devices}
do
unlock $line
done
}
#echo "Choose 1 to unlock or 2 to lock device"
#read input
#if [ "$input" = "2" ];
#then
# lock
#else
# unlock
#fi
if [ $# -lt 1 ] || [ $# -ge 4 ] ;then
echo "Must has more than one argument!"
help
exit -1
fi
if [ "$1" = "lock" ];then
if [ "$2" = "-s" ];then
lock $3
elif [ "$2" = "-a" ];then
lockAll
else
lock
fi
elif [ "$1" = "unlock" ];then
if [ "$2" = "-s" ];then
unlock $3
elif [ "$2" = "-a" ];then
unlockAll
else
unlock
fi
fi