factory_install: Allow debug console if cros_debug is defined.

When installation failed, we do want a friendly environment to help debugging.
Since kernel is always signed, a cros_debug ensures that the system was not boot
as official signed images.

To enable the flag:
 - netboot: Override command line by files on TFTP.
 - factory install shim: Add cros_debug into --boot_args.

BUG=none
TEST=build_image factory_install --boot_args "noinitrd cros_debug"

Change-Id: I6e24c8a2ceda8d696be66ff212b45c5ab697fb3f
Reviewed-on: https://chromium-review.googlesource.com/249006
Reviewed-by: Ricky Liang <jcliang@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Commit-Queue: Hung-Te Lin <hungte@chromium.org>
diff --git a/factory_install.sh b/factory_install.sh
index ac9bcc7..336d5ee 100644
--- a/factory_install.sh
+++ b/factory_install.sh
@@ -123,10 +123,16 @@
     local tty_num="${LOG_TTY##*[^0-9]}"
     log "See ${LOG_TTY} (Ctrl-Alt-F${tty_num}) for detailed information."
     log "(The F${tty_num} key is ${tty_num} keys to the right of 'esc' key.)"
-    exit 1
   else
     log "See ${LOG_FILE} for detailed information."
   fi
+
+  # Open a terminal if the kernel command line allows debugging.
+  if grep -qw "cros_debug" /proc/cmdline 2>/dev/null; then
+    sh
+  fi
+
+  exit 1
 }
 
 kill_bg_jobs() {