diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2017-08-29 13:52:31 +1000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2017-10-04 16:41:17 +1100 |
commit | e1e2ca689661791ba38bf2572df8a65e36258ac2 (patch) | |
tree | 1dc9b48c120b6488b4d1178fbd375be69c68c9f6 /ui | |
parent | af51ccb8b8664eb9462aa4a6e7e2a9f52430647f (diff) | |
download | talos-petitboot-e1e2ca689661791ba38bf2572df8a65e36258ac2.tar.gz talos-petitboot-e1e2ca689661791ba38bf2572df8a65e36258ac2.zip |
ui/ncurses: Spawn shell in exit handler
In cui_on_exit()_ instead of exiting the program spawn a sh instance.
This allows the user to drop to the shell and return without losing any
custom boot options, for example.
SIGINT still calls cui_abort() to properly exit Petitboot.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ncurses/nc-cui.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 8fba7d5..6ced24c 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -151,7 +151,30 @@ void cui_resize(struct cui *cui) void cui_on_exit(struct pmenu *menu) { - cui_abort(cui_from_pmenu(menu)); + struct cui *cui = cui_from_pmenu(menu); + char *sh_cmd; + + sh_cmd = talloc_asprintf(cui, + "echo \"Exiting petitboot. Type 'exit' to return.\";\ + echo \"You may run 'pb-sos' to gather diagnostic data\";\ + %s", pb_system_apps.sh); + + if (!sh_cmd) { + pb_log("Failed to allocate shell arguments\n"); + return; + } + + const char *argv[] = { + pb_system_apps.sh, + "-c", + sh_cmd, + NULL + }; + + cui_run_cmd(cui, argv); + + nc_scr_status_printf(cui->current, _("Returned from shell")); + talloc_free(sh_cmd); } /** @@ -173,6 +196,10 @@ int cui_run_cmd(struct cui *cui, const char **cmd_argv) nc_scr_status_printf(cui->current, _("Running %s..."), cmd_argv[0]); + nc_scr_unpost(cui->current); + clear(); + refresh(); + def_prog_mode(); endwin(); @@ -182,6 +209,7 @@ int cui_run_cmd(struct cui *cui, const char **cmd_argv) refresh(); redrawwin(cui->current->main_ncw); + nc_scr_post(cui->current); if (result) { pb_log("%s: failed: '%s'\n", __func__, cmd_argv[0]); |