-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathsetup-tank-full-lineageos.cmd
394 lines (306 loc) · 8.72 KB
/
setup-tank-full-lineageos.cmd
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
@echo off
title Full Setup Script For Tank
set debug=0
set fireOsVersion=0.0.0.0
set fireOsDevice=none
set downgrade=0
set magiskZip=Magisk.zip
set adb="%~dp0bin\adb.exe"
set adbKill=%adb% kill-server
set adbStart=%adb% start-server
set adbWait=%adb% wait-for-device
set sleep="%~dp0bin\wait.exe"
set extractRAR="%~dp0bin\rar.exe" -y x
set cocolor="%~dp0bin\cocolor.exe"
set install=%adb% install
set uninstall=%adb% uninstall
set push=%adb% push
set pull=%adb% pull
set shell=%adb% shell
set twrp=%shell% twrp
if not exist "%temp%\firestick-loader" md "%temp%\firestick-loader"
:start
color 0e
:: Kill any adb instances before starting
%adbKill%
:: TWRP Requirement
set twrp_available=0
cls
echo Looking For TWRP Recovery...
echo.
%pull% /twres/twrp "%temp%\firestick-loader"
%sleep% 2
if exist "%temp%\firestick-loader\twrp" set twrp_available=1
if %twrp_available%==1 goto intro
if %twrp_available%==0 goto twrpfail
:twrpfail
%cocolor% 0c
cls
echo TWRP Not Found!
echo.
echo Trying To Force Boot Into Recovery...
echo.
%sleep% 3
%adb% reboot recovery
%sleep% 25
goto start
:intro
:: Reset TWRP Flags
if %twrp_available%==1 del /f /q "%temp%\firestick-loader\twrp"
if %twrp_available%==1 set twrp_available=0
color 0e
set rwcheck=0
cls
echo.
echo Mounting System To Check Device Settings...
echo.
%shell% "mount -o rw /system"
echo.
echo.
echo Press 1 if there is an error, otherwise just press ENTER
echo.
set /p rwcheck=
if %rwcheck%==1 echo.
if %rwcheck%==1 echo Waiting on Reboot...
if %rwcheck%==1 echo.
if %rwcheck%==1 %adb% reboot recovery
if %rwcheck%==1 %sleep% 25
if %rwcheck%==1 goto intro
:: Get FireOS Info
%shell% "cat /system/build.prop | grep ro.product.name>/sdcard/fireos-version.txt"
%pull% /sdcard/fireos-version.txt "%temp%"
%shell% "cat /system/build.prop | grep ro.product.device=>/sdcard/fireos-device.txt"
%pull% /sdcard/fireos-device.txt "%temp%"
for /f "tokens=2 delims==" %%f in ('type "%temp%\fireos-version.txt"') do set fireOsVersion=%%f
for /f "tokens=2 delims==" %%f in ('type "%temp%\fireos-device.txt"') do set fireOsDevice=%%f
%sleep% 1
%shell% "rm /sdcard/fireos-version.txt"
%shell% "rm /sdcard/fireos-device.txt"
if not %fireOsDevice%==tank goto notank
if not %fireOsVersion%==cm_tank goto nolineage
set continue=y
cls
%cocolor% 0a
echo TWRP Found!
echo.
%cocolor% 0b
echo Device: %fireOsDevice% / Product Name: %fireOsVersion%
echo.
echo.
%cocolor% 0e
echo Continue [Y/N]?
echo.
set /p continue=
if %continue%==y goto stage1
if %continue%==Y goto stage1
goto end
:notank
%cocolor% 0c
cls
echo Supports Tank Only!
echo.
echo This device is %fireOsDevice% and CANNOT continue!
echo.
pause
goto end
:nolineage
%cocolor% 0c
cls
echo Supports LineageOS Only!
echo.
echo This OS is %fireOsVersion% and CANNOT continue!
echo.
pause
goto end
:stage1
color 0e
set rwcheck=0
cls
echo Forcing Reboot Back To Recovery...
echo.
%adb% reboot recovery
%sleep% 25
cls
echo.
echo Mounting System as RW for System Install...
echo.
%shell% "mount -o rw /system"
echo.
echo Check For RW Mount Status
echo.
echo.
echo Press 1 if there is an error, otherwise just press ENTER
echo.
set /p rwcheck=
if %rwcheck%==1 echo.
if %rwcheck%==1 echo Waiting on Reboot...
if %rwcheck%==1 echo.
if %rwcheck%==1 %adb% reboot recovery
if %rwcheck%==1 %sleep% 25
if %rwcheck%==1 goto stage1
cls
echo Removing Some Pre-Installed Apps...
echo.
%sleep% 3
%shell% "rm -r /system/app/YouTubeLeanback/"
%sleep% 5
cls
echo Setting Up Directories For Restore...
echo.
%shell% "rm -r /sdcard/restore/"
%shell% "mkdir /sdcard/restore/"
%shell% "rm -r /sdcard/TitaniumBackup/"
%shell% "mkdir /sdcard/restore/apk/"
%shell% "mkdir /sdcard/restore/apk/system/"
%sleep% 2
cls
echo Pushing Restore Data to /sdcard/...
echo.
%push% "data\tank\post-debloated\lineageos-all\restore" /sdcard/restore/
%push% "data\tank\post-debloated\lineageos\restore" /sdcard/restore/
%sleep% 2
cls
echo Copying TitaniumBackup Data For Restore...
echo.
%shell% "cp -r /sdcard/restore/TitaniumBackup/ /sdcard/"
%sleep% 2
cls
echo Creating System Restore Directories and Setting Permissions...
echo.
%shell% "rm -r /system/restore/"
%shell% "mkdir /system/restore/"
%shell% "mkdir /system/restore/apk/"
%shell% "mkdir /system/restore/apk/system/"
%shell% "chmod 0777 /system/restore/"
%shell% "chown root:root /system/restore/"
%shell% "chmod 0777 /system/restore/apk/"
%shell% "chown root:root /system/restore/apk/"
%shell% "chmod 0777 /system/restore/apk/system/"
%shell% "chown root:root /system/restore/apk/system/"
cls
echo Copying Data from /sdcard to /system...
echo.
%shell% "cp -r /sdcard/restore/ /system/"
%sleep% 3
cls
echo Pushing Clean SD Card Script to Temp...
echo.
%push% "scripts\clean-sdcard-lite.sh" /data/local/tmp/
%sleep% 2
cls
echo Making Directories and Setting Permissions for Settings Scripts...
echo.
%shell% "rm -r /system/scripts/"
%shell% "mkdir /system/scripts/"
%shell% "chmod 0777 /system/scripts/"
%sleep% 2
cls
echo Copying Clean SD Card Script From Temp to /system...
echo.
%shell% "cp /data/local/tmp/clean-sdcard-lite.sh /system/scripts/clean-sdcard-lite.sh"
%sleep% 2
cls
echo Setting Permissions...
echo.
%shell% "chmod 0777 /system/scripts/*.sh"
%shell% "chown root:root /system/scripts/*.sh"
%sleep% 2
cls
echo Copying Apps to /system/app/...
echo.
%shell% "rm -r /system/app/LeanbackLauncher/"
%shell% "mkdir /system/app/LeanbackLauncher/"
%shell% "chmod 0775 /system/app/LeanbackLauncher/"
%shell% "chown root:root /system/app/LeanbackLauncher/"
%shell% "cp /system/restore/apk/system/LeanbackLauncher.apk /system/app/LeanbackLauncher/LeanbackLauncher.apk"
%shell% "rm -r /system/app/ScriptRunner/"
%shell% "mkdir /system/app/ScriptRunner/"
%shell% "chmod 0775 /system/app/ScriptRunner/"
%shell% "chown root:root /system/app/ScriptRunner/"
%shell% "cp /system/restore/apk/system/ScriptRunner.apk /system/app/ScriptRunner/ScriptRunner.apk"
%shell% "rm -r /system/app/TitaniumBackup/"
%shell% "mkdir /system/app/TitaniumBackup/"
%shell% "chmod 0775 /system/app/TitaniumBackup/"
%shell% "chown root:root /system/app/TitaniumBackup/"
%shell% "cp /system/restore/apk/system/TitaniumBackup.apk /system/app/TitaniumBackup/TitaniumBackup.apk"
%shell% "rm -r /system/app/TitaniumBackupAddon/"
%shell% "mkdir /system/app/TitaniumBackupAddon/"
%shell% "chmod 0775 /system/app/TitaniumBackupAddon/"
%shell% "chown root:root /system/app/TitaniumBackupAddon/"
%shell% "cp /system/restore/apk/system/TitaniumBackupAddon.apk /system/app/TitaniumBackupAddon/TitaniumBackupAddon.apk"
%sleep% 2
cls
echo Copying Apps to /system/priv-app/...
echo.
%shell% "rm -r /system/priv-app/LeanbackLauncher/"
%shell% "mkdir /system/priv-app/LeanbackLauncher/"
%shell% "chmod 0775 /system/priv-app/LeanbackLauncher/"
%shell% "chown root:root /system/priv-app/LeanbackLauncher/"
%shell% "cp /system/restore/apk/system/LeanbackLauncher.apk /system/priv-app/LeanbackLauncher/LeanbackLauncher.apk"
%sleep% 2
cls
echo Setting Permissions For System Apps...
echo.
%shell% "chmod 0644 /system/app/LeanbackLauncher/LeanbackLauncher.apk"
%shell% "chown root:root /system/app/LeanbackLauncher/LeanbackLauncher.apk"
%shell% "chmod 0644 /system/priv-app/LeanbackLauncher/LeanbackLauncher.apk"
%shell% "chown root:root /system/priv-app/LeanbackLauncher/LeanbackLauncher.apk"
%shell% "chmod 0644 /system/app/ScriptRunner/ScriptRunner.apk"
%shell% "chown root:root /system/app/ScriptRunner/ScriptRunner.apk"
%shell% "chmod 0644 /system/app/TitaniumBackup/TitaniumBackup.apk"
%shell% "chown root:root /system/app/TitaniumBackup/TitaniumBackup.apk"
%shell% "chmod 0644 /system/app/TitaniumBackupAddon/TitaniumBackupAddon.apk"
%shell% "chown root:root /system/app/TitaniumBackupAddon/TitaniumBackupAddon.apk"
%sleep% 2
set wipedata=n
cls
echo Wipe Data and Cache [Y/N]?
echo.
set /p wipedata=
if %wipedata%==n goto skipwipe
if %wipedata%==N goto skipwipe
cls
echo Wiping Data, Cache, and Dalvik Cache...
echo.
echo This May Take Several Minutes!
echo.
%twrp% wipe data
%sleep% 5
%twrp% wipe cache
%sleep% 5
%twrp% wipe dalvik
%sleep% 5
:skipwipe
cls
echo Re-Installing Magisk for SU Access...
echo.
%push% "rooting\%magiskZip%" /data/local/tmp/
%twrp% install /data/local/tmp/%magiskZip%
%sleep% 2
cls
echo Fixing Permissions...
echo.
:: Source: https://forum.xda-developers.com/showthread.php?t=2222297
%shell% "chown -R media_rw:media_rw /data/media/"
%shell% "find /data/media/ -type d -exec chmod 775 {} ';'"
%shell% "find /data/media/ -type f -exec chmod 664 {} ';'"
%shell% "restorecon -FR /data/media/"
%sleep% 5
cls
echo Preparing For Reboot...
echo.
%sleep% 8
%adb% reboot
%adbWait%
:finished
cls
color 0a
echo.
echo Once on Launcher, use TitaniumBackup to restore data for
echo ATV Launcher Home and SH Script Runner Settings
echo.
echo Use TitaniumBackup to restore apps for Mouse Toggle, Busybox and Autoruns
echo.
echo Press any key to exit...
pause>nul
:end