From: Piotr Dymacz Date: Wed, 5 Apr 2017 22:06:16 +0000 (+0200) Subject: Run recovery script only if 'recovery' variable exists X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c36acfeef9f698148d255ba986ac94242406d7a3;p=oweals%2Fu-boot_mod.git Run recovery script only if 'recovery' variable exists This partially solves #131 --- diff --git a/u-boot/common/main.c b/u-boot/common/main.c index 4a59988..9ca775d 100644 --- a/u-boot/common/main.c +++ b/u-boot/common/main.c @@ -162,25 +162,32 @@ void main_loop(void) gd->flags &= ~(GD_FLG_SILENT); #endif - /* - * Always clear values of variables used in recovery script - * as they could be accidentally saved before - */ - setenv("stop_boot", NULL); - setenv("cnt", NULL); + /* Do we have recovery script in env var at all? */ + c = getenv("recovery"); + if (c == NULL) { + puts("** Warning: recovery script is missing\n"); + puts(" in env, use 'defenv' to reset env\n\n"); + } else { + /* + * Always clear values of variables used in recovery + * script as they could be accidentally saved before + */ + setenv("stop_boot", NULL); + setenv("cnt", NULL); - run_command("run recovery", 0); + run_command("run recovery", 0); - /* Should we stop booting after recovery mode? */ - c = getenv("stop_boot"); - stop_boot = c ? (int)simple_strtol(c, NULL, 10) : 0; + /* Should we stop booting after recovery mode? */ + c = getenv("stop_boot"); + stop_boot = c ? (int)simple_strtol(c, NULL, 10) : 0; - if (stop_boot) { - setenv("stop_boot", NULL); - bootcmd = NULL; - } + if (stop_boot) { + setenv("stop_boot", NULL); + bootcmd = NULL; + } - setenv("cnt", NULL); + setenv("cnt", NULL); + } } #endif /* CONFIG_RECOVERY_MODE */