blob: 88d54aca46e70a225eb0d0ed3efc8738e9929be1 [file] [log] [blame]
Dees_Troy812660f2012-09-20 09:55:17 -04001/* OpenRecoveryScript class for TWRP
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 *
17 * The code was written from scratch by Dees_Troy dees_troy at
18 * yahoo
19 *
20 * Copyright (c) 2012
21 */
22
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <sys/stat.h>
27#include <sys/vfs.h>
28#include <unistd.h>
29#include <vector>
30#include <dirent.h>
31#include <time.h>
32#include <errno.h>
33
34#include "twrp-functions.hpp"
35#include "partitions.hpp"
36#include "common.h"
37#include "openrecoveryscript.hpp"
38#include "variables.h"
39extern "C" {
40#include "data.h"
41#include "twinstall.h"
42int TWinstall_zip(const char* path, int* wipe_cache);
43}
44
45static const char *SCRIPT_FILE_CACHE = "/cache/recovery/openrecoveryscript";
46static const char *SCRIPT_FILE_TMP = "/tmp/openrecoveryscript";
47#define SCRIPT_COMMAND_SIZE 512
48
49int OpenRecoveryScript::check_for_script_file(void) {
50 char exec[512];
51
52 if (!PartitionManager.Mount_By_Path(SCRIPT_FILE_CACHE, false)) {
53 LOGE("Unable to mount /cache for OpenRecoveryScript support.\n");
54 return 0;
55 }
56 if (TWFunc::Path_Exists(SCRIPT_FILE_CACHE)) {
57 LOGI("Script file found: '%s'\n", SCRIPT_FILE_CACHE);
58 // Copy script file to /tmp
59 strcpy(exec, "cp ");
60 strcat(exec, SCRIPT_FILE_CACHE);
61 strcat(exec, " ");
62 strcat(exec, SCRIPT_FILE_TMP);
63 system(exec);
64 // Delete the file from /cache
65 strcpy(exec, "rm ");
66 strcat(exec, SCRIPT_FILE_CACHE);
67 system(exec);
68 return 1;
69 }
70 return 0;
71}
72
73int OpenRecoveryScript::run_script_file(void) {
74 FILE *fp = fopen(SCRIPT_FILE_TMP, "r");
75 int ret_val = 0, cindex, line_len, i, remove_nl;
76 char script_line[SCRIPT_COMMAND_SIZE], command[SCRIPT_COMMAND_SIZE],
77 value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
78 value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
79 char *val_start, *tok;
80
81 if (fp != NULL) {
82 while (fgets(script_line, SCRIPT_COMMAND_SIZE, fp) != NULL && ret_val == 0) {
83 cindex = 0;
84 line_len = strlen(script_line);
85 if (line_len < 2)
86 continue; // there's a blank line or line is too short to contain a command
87 //ui_print("script line: '%s'\n", script_line);
88 for (i=0; i<line_len; i++) {
89 if ((int)script_line[i] == 32) {
90 cindex = i;
91 i = line_len;
92 }
93 }
94 memset(command, 0, sizeof(command));
95 memset(value, 0, sizeof(value));
96 if ((int)script_line[line_len - 1] == 10)
97 remove_nl = 2;
98 else
99 remove_nl = 1;
100 if (cindex != 0) {
101 strncpy(command, script_line, cindex);
102 LOGI("command is: '%s' and ", command);
103 val_start = script_line;
104 val_start += cindex + 1;
105 strncpy(value, val_start, line_len - cindex - remove_nl);
106 LOGI("value is: '%s'\n", value);
107 } else {
108 strncpy(command, script_line, line_len - remove_nl + 1);
109 ui_print("command is: '%s' and there is no value\n", command);
110 }
111 if (strcmp(command, "install") == 0) {
Dees_Troy83a3b122012-10-01 14:16:43 -0400112 // Install Zip
113 ret_val = Install_Command(value);
Dees_Troy812660f2012-09-20 09:55:17 -0400114 } else if (strcmp(command, "wipe") == 0) {
115 // Wipe
116 if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) {
117 ui_print("-- Wiping Cache Partition...\n");
118 PartitionManager.Wipe_By_Path("/cache");
119 ui_print("-- Cache Partition Wipe Complete!\n");
120 } else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) {
121 ui_print("-- Wiping Dalvik Cache...\n");
122 PartitionManager.Wipe_Dalvik_Cache();
123 ui_print("-- Dalvik Cache Wipe Complete!\n");
124 } else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) {
125 ui_print("-- Wiping Data Partition...\n");
126 PartitionManager.Factory_Reset();
127 ui_print("-- Data Partition Wipe Complete!\n");
128 } else {
129 LOGE("Error with wipe command value: '%s'\n", value);
130 ret_val = 1;
131 }
132 } else if (strcmp(command, "backup") == 0) {
133 // Backup
134 tok = strtok(value, " ");
135 strcpy(value1, tok);
136 tok = strtok(NULL, " ");
137 if (tok != NULL) {
138 memset(value2, 0, sizeof(value2));
139 strcpy(value2, tok);
140 line_len = strlen(tok);
141 if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13) {
142 if ((int)value2[line_len - 1] == 10 || (int)value2[line_len - 1] == 13)
143 remove_nl = 2;
144 else
145 remove_nl = 1;
146 } else
147 remove_nl = 0;
148 strncpy(value2, tok, line_len - remove_nl);
149 DataManager_SetStrValue(TW_BACKUP_NAME, value2);
150 ui_print("Backup folder set to '%s'\n", value2);
Dees_Troyc9ff7a32012-09-27 10:09:41 -0400151 if (PartitionManager.Check_Backup_Name(true) != 0) {
152 ret_val = 1;
153 continue;
154 }
Dees_Troy812660f2012-09-20 09:55:17 -0400155 } else {
156 char empt[50];
157 strcpy(empt, "(Current Date)");
158 DataManager_SetStrValue(TW_BACKUP_NAME, empt);
159 }
Dees_Troy83a3b122012-10-01 14:16:43 -0400160 ret_val = Backup_Command(value1);
Dees_Troy812660f2012-09-20 09:55:17 -0400161 } else if (strcmp(command, "restore") == 0) {
162 // Restore
163 PartitionManager.Mount_All_Storage();
164 DataManager_SetIntValue(TW_SKIP_MD5_CHECK_VAR, 0);
165
166 string val = value, restore_folder, restore_partitions;
167 size_t pos = val.find_last_of(" ");
168 if (pos == string::npos) {
169 ui_print("Malformed restore parameter: '%s'\n", value1);
170 ret_val = 1;
171 continue;
172 }
173 restore_folder = val.substr(0, pos);
174 char folder_path[512], partitions[512];
175 strcpy(folder_path, restore_folder.c_str());
176 restore_partitions = val.substr(pos + 1, val.size() - pos - 1);
177 strcpy(partitions, restore_partitions.c_str());
178 LOGI("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions);
179 ui_print("Restoring '%s'\n", folder_path);
180
181 if (folder_path[0] != '/') {
182 char backup_folder[512];
183 sprintf(backup_folder, "%s/%s", DataManager_GetStrValue(TW_BACKUPS_FOLDER_VAR), folder_path);
184 LOGI("Restoring relative path: '%s'\n", backup_folder);
185 if (!TWFunc::Path_Exists(backup_folder)) {
186 if (DataManager_GetIntValue(TW_HAS_DUAL_STORAGE)) {
187 if (DataManager_GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
188 LOGI("Backup folder '%s' not found on external storage, trying internal...\n", folder_path);
189 DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 0);
190 } else {
191 LOGI("Backup folder '%s' not found on internal storage, trying external...\n", folder_path);
192 DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 1);
193 }
194 sprintf(backup_folder, "%s/%s", DataManager_GetStrValue(TW_BACKUPS_FOLDER_VAR), folder_path);
195 LOGI("2Restoring relative path: '%s'\n", backup_folder);
196 }
197 }
198 strcpy(folder_path, backup_folder);
199 } else {
200 if (folder_path[strlen(folder_path) - 1] == '/')
201 strcat(folder_path, ".");
202 else
203 strcat(folder_path, "/.");
204 }
205 if (!TWFunc::Path_Exists(folder_path)) {
206 ui_print("Unable to locate backup '%s'\n", folder_path);
207 ret_val = 1;
208 continue;
209 }
210 DataManager_SetStrValue("tw_restore", folder_path);
211
212 PartitionManager.Set_Restore_Files(folder_path);
213 if (strlen(partitions) != 0) {
214 int tw_restore_system = 0;
215 int tw_restore_data = 0;
216 int tw_restore_cache = 0;
217 int tw_restore_recovery = 0;
218 int tw_restore_boot = 0;
219 int tw_restore_andsec = 0;
220 int tw_restore_sdext = 0;
221 int tw_restore_sp1 = 0;
222 int tw_restore_sp2 = 0;
223 int tw_restore_sp3 = 0;
224
225 memset(value2, 0, sizeof(value2));
226 strcpy(value2, partitions);
227 ui_print("Setting restore options: '%s':\n", value2);
228 line_len = strlen(value2);
229 for (i=0; i<line_len; i++) {
230 if ((value2[i] == 'S' || value2[i] == 's') && DataManager_GetIntValue(TW_RESTORE_SYSTEM_VAR) > 0) {
231 tw_restore_system = 1;
232 ui_print("System\n");
233 } else if ((value2[i] == 'D' || value2[i] == 'd') && DataManager_GetIntValue(TW_RESTORE_DATA_VAR) > 0) {
234 tw_restore_data = 1;
235 ui_print("Data\n");
236 } else if ((value2[i] == 'C' || value2[i] == 'c') && DataManager_GetIntValue(TW_RESTORE_CACHE_VAR) > 0) {
237 tw_restore_cache = 1;
238 ui_print("Cache\n");
239 } else if ((value2[i] == 'R' || value2[i] == 'r') && DataManager_GetIntValue(TW_RESTORE_RECOVERY_VAR) > 0) {
240 tw_restore_recovery = 1;
241 ui_print("Recovery\n");
242 } else if (value2[i] == '1' && DataManager_GetIntValue(TW_RESTORE_SP1_VAR) > 0) {
243 tw_restore_sp1 = 1;
244 ui_print("%s\n", "Special1");
245 } else if (value2[i] == '2' && DataManager_GetIntValue(TW_RESTORE_SP2_VAR) > 0) {
246 tw_restore_sp2 = 1;
247 ui_print("%s\n", "Special2");
248 } else if (value2[i] == '3' && DataManager_GetIntValue(TW_RESTORE_SP3_VAR) > 0) {
249 tw_restore_sp3 = 1;
250 ui_print("%s\n", "Special3");
251 } else if ((value2[i] == 'B' || value2[i] == 'b') && DataManager_GetIntValue(TW_RESTORE_BOOT_VAR) > 0) {
252 tw_restore_boot = 1;
253 ui_print("Boot\n");
254 } else if ((value2[i] == 'A' || value2[i] == 'a') && DataManager_GetIntValue(TW_RESTORE_ANDSEC_VAR) > 0) {
255 tw_restore_andsec = 1;
256 ui_print("Android Secure\n");
257 } else if ((value2[i] == 'E' || value2[i] == 'e') && DataManager_GetIntValue(TW_RESTORE_SDEXT_VAR) > 0) {
258 tw_restore_sdext = 1;
259 ui_print("SD-Ext\n");
260 } else if (value2[i] == 'M' || value2[i] == 'm') {
261 DataManager_SetIntValue(TW_SKIP_MD5_CHECK_VAR, 1);
262 ui_print("MD5 check skip is on\n");
263 }
264 }
265
266 if (DataManager_GetIntValue(TW_RESTORE_SYSTEM_VAR) && !tw_restore_system)
267 DataManager_SetIntValue(TW_RESTORE_SYSTEM_VAR, 0);
268 if (DataManager_GetIntValue(TW_RESTORE_DATA_VAR) && !tw_restore_data)
269 DataManager_SetIntValue(TW_RESTORE_DATA_VAR, 0);
270 if (DataManager_GetIntValue(TW_RESTORE_CACHE_VAR) && !tw_restore_cache)
271 DataManager_SetIntValue(TW_RESTORE_CACHE_VAR, 0);
272 if (DataManager_GetIntValue(TW_RESTORE_RECOVERY_VAR) && !tw_restore_recovery)
273 DataManager_SetIntValue(TW_RESTORE_RECOVERY_VAR, 0);
274 if (DataManager_GetIntValue(TW_RESTORE_BOOT_VAR) && !tw_restore_boot)
275 DataManager_SetIntValue(TW_RESTORE_BOOT_VAR, 0);
276 if (DataManager_GetIntValue(TW_RESTORE_ANDSEC_VAR) && !tw_restore_andsec)
277 DataManager_SetIntValue(TW_RESTORE_ANDSEC_VAR, 0);
278 if (DataManager_GetIntValue(TW_RESTORE_SDEXT_VAR) && !tw_restore_sdext)
279 DataManager_SetIntValue(TW_RESTORE_SDEXT_VAR, 0);
280 if (DataManager_GetIntValue(TW_RESTORE_SP1_VAR) && !tw_restore_sp1)
281 DataManager_SetIntValue(TW_RESTORE_SP1_VAR, 0);
282 if (DataManager_GetIntValue(TW_RESTORE_SP2_VAR) && !tw_restore_sp2)
283 DataManager_SetIntValue(TW_RESTORE_SP2_VAR, 0);
284 if (DataManager_GetIntValue(TW_RESTORE_SP3_VAR) && !tw_restore_sp3)
285 DataManager_SetIntValue(TW_RESTORE_SP3_VAR, 0);
286 } else {
287 ui_print("No restore options set.\n");
288 ret_val = 1;
289 continue;
290 }
291 PartitionManager.Run_Restore(folder_path);
292 ui_print("Restore complete!\n");
293 } else if (strcmp(command, "mount") == 0) {
294 // Mount
295 if (value[0] != '/') {
296 strcpy(mount, "/");
297 strcat(mount, value);
298 } else
299 strcpy(mount, value);
300 if (PartitionManager.Mount_By_Path(mount, true))
301 ui_print("Mounted '%s'\n", mount);
302 } else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) {
303 // Unmount
304 if (value[0] != '/') {
305 strcpy(mount, "/");
306 strcat(mount, value);
307 } else
308 strcpy(mount, value);
309 if (PartitionManager.UnMount_By_Path(mount, true))
310 ui_print("Unmounted '%s'\n", mount);
311 } else if (strcmp(command, "set") == 0) {
312 // Set value
313 tok = strtok(value, " ");
314 strcpy(value1, tok);
315 tok = strtok(NULL, " ");
316 strcpy(value2, tok);
317 ui_print("Setting '%s' to '%s'\n", value1, value2);
318 DataManager_SetStrValue(value1, value2);
319 } else if (strcmp(command, "mkdir") == 0) {
320 // Make directory (recursive)
321 ui_print("Making directory (recursive): '%s'\n", value);
322 if (TWFunc::Recursive_Mkdir(value)) {
323 LOGE("Unable to create folder: '%s'\n", value);
324 ret_val = 1;
325 }
326 } else if (strcmp(command, "reboot") == 0) {
327 // Reboot
328 } else if (strcmp(command, "cmd") == 0) {
329 if (cindex != 0) {
330 system(value);
331 } else {
332 LOGE("No value given for cmd\n");
333 }
334 } else if (strcmp(command, "print") == 0) {
335 ui_print("%s\n", value);
336 } else {
337 LOGE("Unrecognized script command: '%s'\n", command);
338 ret_val = 1;
339 }
340 }
341 fclose(fp);
342 ui_print("Done processing script file\n");
343 } else {
344 LOGE("Error opening script file '%s'\n", SCRIPT_FILE_TMP);
345 return 1;
346 }
347 return ret_val;
348}
349
Dees_Troy83a3b122012-10-01 14:16:43 -0400350int OpenRecoveryScript::Install_Command(string Zip) {
351 // Install zip
352 string ret_string;
353 int ret_val = 0, wipe_cache = 0;
354
355 PartitionManager.Mount_All_Storage();
356 if (Zip.substr(0, 1) != "/") {
357 // Relative path given
358 string Full_Path;
359
360 Full_Path = DataManager_GetCurrentStoragePath();
361 Full_Path += "/" + Zip;
362 LOGI("Full zip path: '%s'\n", Full_Path.c_str());
363 if (!TWFunc::Path_Exists(Full_Path)) {
364 ret_string = Locate_Zip_File(Full_Path, DataManager_GetCurrentStoragePath());
365 if (!ret_string.empty()) {
366 Full_Path = ret_string;
367 } else if (DataManager_GetIntValue(TW_HAS_DUAL_STORAGE)) {
368 if (DataManager_GetIntValue(TW_USE_EXTERNAL_STORAGE)) {
369 LOGI("Zip file not found on external storage, trying internal...\n");
370 DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 0);
371 } else {
372 LOGI("Zip file not found on internal storage, trying external...\n");
373 DataManager_SetIntValue(TW_USE_EXTERNAL_STORAGE, 1);
374 }
375 Full_Path = DataManager_GetCurrentStoragePath();
376 Full_Path += "/" + Zip;
377 LOGI("Full zip path: '%s'\n", Full_Path.c_str());
378 ret_string = Locate_Zip_File(Full_Path, DataManager_GetCurrentStoragePath());
379 if (!ret_string.empty())
380 Full_Path = ret_string;
381 }
382 }
383 Zip = Full_Path;
384 } else {
385 // Full path given
386 if (!TWFunc::Path_Exists(Zip)) {
387 ret_string = Locate_Zip_File(Zip, DataManager_GetCurrentStoragePath());
388 if (!ret_string.empty())
389 Zip = ret_string;
390 }
391 }
392
393 if (!TWFunc::Path_Exists(Zip)) {
394 // zip file doesn't exist
395 ui_print("Unable to locate zip file '%s'.\n", Zip.c_str());
396 ret_val = 1;
397 } else {
398 ui_print("Installing zip file '%s'\n", Zip.c_str());
399 ret_val = TWinstall_zip(Zip.c_str(), &wipe_cache);
400 }
401 if (ret_val != 0) {
402 LOGE("Error installing zip file '%s'\n", Zip.c_str());
403 ret_val = 1;
404 } else if (wipe_cache)
405 PartitionManager.Wipe_By_Path("/cache");
406
407 return ret_val;
408}
409
Dees_Troy812660f2012-09-20 09:55:17 -0400410string OpenRecoveryScript::Locate_Zip_File(string Zip, string Storage_Root) {
411 string Path = TWFunc::Get_Path(Zip);
412 string File = TWFunc::Get_Filename(Zip);
413 string pathCpy = Path;
414 string wholePath;
415 size_t pos = Path.find("/", 1);
416
417 while (pos != string::npos)
418 {
419 pathCpy = Path.substr(pos, Path.size() - pos);
420 wholePath = pathCpy + "/" + File;
421 if (TWFunc::Path_Exists(wholePath))
422 return wholePath;
423 wholePath = Storage_Root + "/" + wholePath;
424 if (TWFunc::Path_Exists(wholePath))
425 return wholePath;
426
427 pos = Path.find("/", pos + 1);
428 }
429 return "";
Dees_Troy83a3b122012-10-01 14:16:43 -0400430}
431
432int OpenRecoveryScript::Backup_Command(string Options) {
433 char value1[SCRIPT_COMMAND_SIZE];
434 int line_len, i;
435
436 strcpy(value1, Options.c_str());
437
438 DataManager_SetIntValue(TW_BACKUP_SYSTEM_VAR, 0);
439 DataManager_SetIntValue(TW_BACKUP_DATA_VAR, 0);
440 DataManager_SetIntValue(TW_BACKUP_CACHE_VAR, 0);
441 DataManager_SetIntValue(TW_BACKUP_RECOVERY_VAR, 0);
442 DataManager_SetIntValue(TW_BACKUP_SP1_VAR, 0);
443 DataManager_SetIntValue(TW_BACKUP_SP2_VAR, 0);
444 DataManager_SetIntValue(TW_BACKUP_SP3_VAR, 0);
445 DataManager_SetIntValue(TW_BACKUP_BOOT_VAR, 0);
446 DataManager_SetIntValue(TW_BACKUP_ANDSEC_VAR, 0);
447 DataManager_SetIntValue(TW_BACKUP_SDEXT_VAR, 0);
448 DataManager_SetIntValue(TW_BACKUP_SDEXT_VAR, 0);
449 DataManager_SetIntValue(TW_USE_COMPRESSION_VAR, 0);
450 DataManager_SetIntValue(TW_SKIP_MD5_GENERATE_VAR, 0);
451
452 ui_print("Setting backup options:\n");
453 line_len = Options.size();
454 for (i=0; i<line_len; i++) {
455 if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") {
456 DataManager_SetIntValue(TW_BACKUP_SYSTEM_VAR, 1);
457 ui_print("System\n");
458 } else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") {
459 DataManager_SetIntValue(TW_BACKUP_DATA_VAR, 1);
460 ui_print("Data\n");
461 } else if (Options.substr(i, 1) == "C" || Options.substr(i, 1) == "c") {
462 DataManager_SetIntValue(TW_BACKUP_CACHE_VAR, 1);
463 ui_print("Cache\n");
464 } else if (Options.substr(i, 1) == "R" || Options.substr(i, 1) == "r") {
465 DataManager_SetIntValue(TW_BACKUP_RECOVERY_VAR, 1);
466 ui_print("Recovery\n");
467 } else if (Options.substr(i, 1) == "1") {
468 DataManager_SetIntValue(TW_BACKUP_SP1_VAR, 1);
469 ui_print("%s\n", "Special1");
470 } else if (Options.substr(i, 1) == "2") {
471 DataManager_SetIntValue(TW_BACKUP_SP2_VAR, 1);
472 ui_print("%s\n", "Special2");
473 } else if (Options.substr(i, 1) == "3") {
474 DataManager_SetIntValue(TW_BACKUP_SP3_VAR, 1);
475 ui_print("%s\n", "Special3");
476 } else if (Options.substr(i, 1) == "B" || Options.substr(i, 1) == "b") {
477 DataManager_SetIntValue(TW_BACKUP_BOOT_VAR, 1);
478 ui_print("Boot\n");
479 } else if (Options.substr(i, 1) == "A" || Options.substr(i, 1) == "a") {
480 DataManager_SetIntValue(TW_BACKUP_ANDSEC_VAR, 1);
481 ui_print("Android Secure\n");
482 } else if (Options.substr(i, 1) == "E" || Options.substr(i, 1) == "e") {
483 DataManager_SetIntValue(TW_BACKUP_SDEXT_VAR, 1);
484 ui_print("SD-Ext\n");
485 } else if (Options.substr(i, 1) == "O" || Options.substr(i, 1) == "o") {
486 DataManager_SetIntValue(TW_USE_COMPRESSION_VAR, 1);
487 ui_print("Compression is on\n");
488 } else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") {
489 DataManager_SetIntValue(TW_SKIP_MD5_GENERATE_VAR, 1);
490 ui_print("MD5 Generation is off\n");
491 }
492 }
493 if (!PartitionManager.Run_Backup()) {
494 LOGE("Backup failed!\n");
495 return 1;
496 }
497 ui_print("Backup complete!\n");
498 return 0;
499}