diff options
author | jkh <jkh@FreeBSD.org> | 1997-07-31 11:08:47 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1997-07-31 11:08:47 +0000 |
commit | 0c6d177de60f3da08196544c58ec36b1e34c2e84 (patch) | |
tree | b456c51cea6c5b05810342463733621e0d601c02 /usr.sbin/sysinstall/termcap.c | |
parent | d9570c1f69e582d758470f6f2dd312d1458a7bef (diff) | |
download | FreeBSD-src-0c6d177de60f3da08196544c58ec36b1e34c2e84.zip FreeBSD-src-0c6d177de60f3da08196544c58ec36b1e34c2e84.tar.gz |
Make serial console based installs actually work by:
1. Detecting the split /dev/ttyv0 / /dev/console case, e.g. you've
booted with the -h flag and you have a VGA card also.
2. Adding an extra "menu" for selecting terminal type and adding ANSI
to the list of compiled-in terms.
3. Opening the proper file descriptors before disowning ourselves.
Requested by: pst
Diffstat (limited to 'usr.sbin/sysinstall/termcap.c')
-rw-r--r-- | usr.sbin/sysinstall/termcap.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/usr.sbin/sysinstall/termcap.c b/usr.sbin/sysinstall/termcap.c index 992cb60..fa9c19f 100644 --- a/usr.sbin/sysinstall/termcap.c +++ b/usr.sbin/sysinstall/termcap.c @@ -21,6 +21,50 @@ #define VTY_STATUS_LINE 24 #define TTY_STATUS_LINE 23 +static void +prompt_term(char **termp, char **termcapp) +{ + char str[80]; + static struct { + const char *term, *termcap; + } lookup[] = { { "ansi", termcap_ansi }, + { "vt100", termcap_vt100 }, + { "cons25", termcap_cons25 }, + { "cons25-m", termcap_cons25_m } }; + + if (RunningAsInit) { + while (1) { + int i; + + printf("\nThese are the predefined terminal types available to\n"); + printf("sysinstall when running stand-alone. Please choose the\n"); + printf("closest match for your particular terminal.\n\n"); + printf("1 ...................... Standard ANSI terminal.\n"); + printf("2 ...................... VT100 or compatible terminal.\n"); + printf("3 ...................... FreeBSD system console (color).\n"); + printf("4 ...................... FreeBSD system console (monochrome).\n\n"); + printf("Your choice: (1-4) "); + fflush(stdout); + fgets(str, 80, stdin); + i = str[0] - '0'; + if (i > 0 && i < 5) { + *termp = (char *)lookup[i - 1].term; + *termcapp = (char *)lookup[i - 1].termcap; + break; + } + else + printf("\007Invalid choice, please try again.\n\n"); + } + } + else { + printf("\nPlease set your TERM variable before running this program.\n"); + printf("Defaulting to an ANSI compatible terminal - please press RETURN\n"); + fgets(str, 80, stdin); /* Just to make it interactive */ + *termp = (char *)"ansi"; + *termcapp = (char *)termcap_ansi; + } +} + int set_termcap(void) { @@ -31,7 +75,7 @@ set_termcap(void) term = getenv("TERM"); stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay); - if (getpid() != 1) { + if (!RunningAsInit) { if (getenv("SYSINSTALL_DEBUG")) DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644); else @@ -42,9 +86,12 @@ set_termcap(void) if (!OnVTY || (stat < 0)) { if (!term) { - if (setenv("TERM", "vt100", 1) < 0) + char *term, *termcap; + + prompt_term(&term, &termcap); + if (setenv("TERM", term, 1) < 0) return -1; - if (setenv("TERMCAP", termcap_vt100, 1) < 0) + if (setenv("TERMCAP", termcap, 1) < 0) return -1; } if (DebugFD == -1) |