Allow canceling sysinstall(8) and sysupgrade(8) gracefully.
This commit is contained in:
parent
252c78f010
commit
a90d4dbf23
|
@ -146,6 +146,15 @@ void prompt(char* buffer,
|
|||
size_t buffer_size,
|
||||
const char* question,
|
||||
const char* answer)
|
||||
{
|
||||
promptx(buffer, buffer_size, question, answer, false);
|
||||
}
|
||||
|
||||
void promptx(char* buffer,
|
||||
size_t buffer_size,
|
||||
const char* question,
|
||||
const char* answer,
|
||||
bool catch_if_shell)
|
||||
{
|
||||
while ( true )
|
||||
{
|
||||
|
@ -169,9 +178,11 @@ void prompt(char* buffer,
|
|||
}
|
||||
if ( !strcmp(buffer, "!") )
|
||||
{
|
||||
printf("Type 'exit' to return to install.\n");
|
||||
printf("Type 'exit' to return to the %s.\n", prompt_man_page);
|
||||
fflush(stdout);
|
||||
execute((const char*[]) { "sh", NULL }, "f");
|
||||
if ( catch_if_shell )
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
if ( !strcmp(buffer, "!man") )
|
||||
|
|
|
@ -31,6 +31,11 @@ void prompt(char* buffer,
|
|||
size_t buffer_size,
|
||||
const char* question,
|
||||
const char* answer);
|
||||
void promptx(char* buffer,
|
||||
size_t buffer_size,
|
||||
const char* question,
|
||||
const char* answer,
|
||||
bool catch_if_shell);
|
||||
void password(char* buffer,
|
||||
size_t buffer_size,
|
||||
const char* question);
|
||||
|
|
|
@ -774,7 +774,7 @@ int main(void)
|
|||
text("\n");
|
||||
|
||||
textf("We are now ready to install %s %s. Take a moment to verify "
|
||||
"everything is sane.\n", BRAND_DISTRIBUTION_NAME, VERSIONSTR);
|
||||
"everything is in order.\n", BRAND_DISTRIBUTION_NAME, VERSIONSTR);
|
||||
text("\n");
|
||||
printf(" %-16s system architecture\n", uts.machine);
|
||||
for ( size_t i = 0; i < mountpoints_used; i++ )
|
||||
|
@ -798,14 +798,24 @@ int main(void)
|
|||
while ( true )
|
||||
{
|
||||
prompt(input, sizeof(input),
|
||||
"Install " BRAND_DISTRIBUTION_NAME "? (yes/no)", "yes");
|
||||
if ( strcasecmp(input, "yes") != 0 )
|
||||
"Install " BRAND_DISTRIBUTION_NAME "? (yes/no/poweroff/reboot)",
|
||||
"yes");
|
||||
if ( !strcasecmp(input, "yes") )
|
||||
break;
|
||||
else if ( !strcasecmp(input, "no") )
|
||||
{
|
||||
text("Everything isn't sane? Answer '!' to get a shell or type ^C "
|
||||
"to abort the install.\n");
|
||||
text("Answer '!' to get a shell. Type !man to view the "
|
||||
"installation(7) manual page.\n");
|
||||
text("Alternatively, you can answer 'poweroff' or 'reboot' to "
|
||||
"cancel the installation.\n");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
else if ( !strcasecmp(input, "poweroff") )
|
||||
exit(0);
|
||||
else if ( !strcasecmp(input, "reboot") )
|
||||
exit(1);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
text("\n");
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ int main(void)
|
|||
conf.grub && (conf.ports || (conf.system && can_run_old_abi));
|
||||
|
||||
textf("We are now ready to upgrade to %s %s. Take a moment to verify "
|
||||
"everything is sane.\n", BRAND_DISTRIBUTION_NAME, VERSIONSTR);
|
||||
"everything is in order.\n", BRAND_DISTRIBUTION_NAME, VERSIONSTR);
|
||||
text("\n");
|
||||
char abibuf[16];
|
||||
printf(" %-16s system architecture\n", uts.machine);
|
||||
|
@ -692,15 +692,33 @@ int main(void)
|
|||
printf(" %-16s will not be updated\n", "bootloader");
|
||||
text("\n");
|
||||
|
||||
prompt(input, sizeof(input),
|
||||
"Upgrade? (yes/no)", "yes");
|
||||
if ( strcasecmp(input, "yes") != 0 )
|
||||
while ( true )
|
||||
{
|
||||
text("Everything isn't sane? Answer '!' to get a shell or type ^C "
|
||||
"to abort the upgrade.\n");
|
||||
continue;
|
||||
promptx(input, sizeof(input),
|
||||
"Upgrade? (yes/no/poweroff/reboot)", "yes", true);
|
||||
if ( !strcasecmp(input, "yes") )
|
||||
break;
|
||||
else if ( !strcasecmp(input, "no") )
|
||||
{
|
||||
text("Answer '!' to get a shell. Type !man to view the "
|
||||
"upgrade(7) manual page. You can edit the upgrade.conf(5) "
|
||||
"configuration file of the target system to change which "
|
||||
"upgrade operations are performed.\n");
|
||||
text("Alternatively, you can answer 'poweroff' or 'reboot' to "
|
||||
"cancel the upgrade.\n");
|
||||
continue;
|
||||
}
|
||||
else if ( !strcasecmp(input, "poweroff") )
|
||||
exit(0);
|
||||
else if ( !strcasecmp(input, "reboot") )
|
||||
exit(1);
|
||||
else if ( !strcasecmp(input, "!") )
|
||||
break;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
if ( !strcasecmp(input, "yes") )
|
||||
break;
|
||||
}
|
||||
text("\n");
|
||||
|
||||
|
|
Loading…
Reference in New Issue