|
|
1.1 ! root 1: /* ! 2: * install.c ! 3: * ! 4: * Last hacked 07/01/93, COH 4.2-Alpha ! 5: * ! 6: * Install COHERENT disks on a system. ! 7: * This is the back end of the initial COHERENT installation procedure; ! 8: * the first part is in build.c. ! 9: * Without the -b option, it installs an update to an existing COH system. ! 10: * If -b or -u selected, suppress copying of files from /compressed directory ! 11: * on floppies and actually uncompress and unarchive them into place. ! 12: * Uses common routines in build0.o: cc install.c build0.c ! 13: * Usage: install [ -bdv ] id device ndisks ! 14: * Options: ! 15: * -b Build: special processing for build, part 2. ! 16: * -d Debug, echo commands without executing ! 17: * -u Update: special processing for build, part 2. ! 18: * -v Verbose ! 19: */ ! 20: ! 21: #include <stdio.h> ! 22: #include "build0.h" ! 23: ! 24: #define VERSION "3.1" ! 25: #define USAGE "Usage: /etc/install [ -bduv ] id device ndisks\n" ! 26: ! 27: /* Forward. */ ! 28: void config(); ! 29: void done(); ! 30: void install(); ! 31: int newdisk(); ! 32: void newusr(); ! 33: void setbaud(); ! 34: ! 35: /* Globals. */ ! 36: int bflag; /* build flag */ ! 37: char *device; /* special device name */ ! 38: char *id; /* disk id */ ! 39: int ndisks; /* number of disks */ ! 40: int update; /* perform update install */ ! 41: ! 42: /* ! 43: * Baud rate table for serial port initialization. ! 44: * The index in the table gives the baud rate value from <sgtty.h>. ! 45: */ ! 46: #if !_I386 ! 47: #define MAXBAUD 17 ! 48: int baudrate[MAXBAUD+1] = { ! 49: 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2000, ! 50: 2400, 3600, 4800, 7200, 9600, 19200 ! 51: }; ! 52: #endif ! 53: ! 54: main(argc, argv) int argc; char *argv[]; ! 55: { ! 56: register char *s; ! 57: register int i; ! 58: ! 59: argv0 = argv[0]; ! 60: abortmsg = 1; ! 61: usagemsg = USAGE; ! 62: if (argc > 1 && argv[1][0] == '-') { ! 63: for (s = &argv[1][1]; *s; ++s) { ! 64: switch(*s) { ! 65: case 'b': ++bflag; break; ! 66: case 'd': ++dflag; break; ! 67: case 'u': ++update; break; ! 68: case 'v': ++vflag; break; ! 69: case 'V': ! 70: fprintf(stderr, "%s: V%s\n", argv0, VERSION); ! 71: break; ! 72: default: usage(); break; ! 73: } ! 74: } ! 75: --argc; ! 76: ++argv; ! 77: } ! 78: if (argc != 4) ! 79: usage(); ! 80: id = argv[1]; ! 81: device = argv[2]; ! 82: ndisks = atoi(argv[3]); ! 83: ! 84: /* Add line to /etc/install.log. */ ! 85: sprintf(cmd, "/bin/echo /etc/install: %s %s %s >>/etc/install.log", ! 86: argv[1], argv[2], argv[3]); ! 87: sys(cmd, S_NONFATAL); ! 88: sys("/bin/date >>/etc/install.log", S_NONFATAL); ! 89: ! 90: #if 0 ! 91: /* Remove old ids and postfile if present. */ ! 92: if (bflag || update) /* Leave disk 1 marker on /. */ ! 93: sprintf(cmd, "/bin/rm -f /%s.[023456789]* /conf/%s.post", id, id); ! 94: else ! 95: sprintf(cmd, "/bin/rm -f /%s.* /conf/%s.post", id, id); ! 96: sys(cmd, S_IGNORE); ! 97: #endif /* bob h proposed removal of code */ ! 98: ! 99: if (bflag || update) ! 100: sys("/etc/mount.all", S_NONFATAL); ! 101: cls(0); ! 102: ! 103: #if 0 ! 104: /* Execute prefile. Not required for the moment. */ ! 105: sprintf(cmd, "/conf/%s.pre", id); ! 106: if (exists(cmd)) { ! 107: cls(0); ! 108: sys(cmd, S_NONFATAL); ! 109: } ! 110: #endif ! 111: ! 112: /* ! 113: * Install disks. ! 114: * Disk numbers are 2 to ndisks for build, 1 to ndisks otherwise. ! 115: */ ! 116: for (i = ((bflag || update) ? 2 : 1); i <= ndisks; ++i) ! 117: install(i); ! 118: if (bflag) ! 119: newusr(); ! 120: if (bflag || update) { ! 121: config(); ! 122: done(); ! 123: } ! 124: ! 125: /* Delete ids and execute postfile if present. */ ! 126: sprintf(cmd, "/bin/rm -f /%s.*", id); ! 127: sys(cmd, S_NONFATAL); ! 128: sprintf(cmd, "/conf/%s.post", id); ! 129: if (exists(cmd)) { ! 130: cls(0); ! 131: if (update) ! 132: strcat(cmd, " -u"); ! 133: sys(cmd, S_NONFATAL); ! 134: } ! 135: sys("/bin/echo /etc/install: success >>/etc/install.log", S_NONFATAL); ! 136: sys("/bin/date >>/etc/install.log", S_NONFATAL); ! 137: sys("/bin/echo >>/etc/install.log", S_NONFATAL); ! 138: if (bflag || update) ! 139: sys("/etc/umount.all", S_NONFATAL); ! 140: cls(0); ! 141: printf("You have completed the %s procedure successfully.\n", ! 142: (update) ? "update" : "installation"); ! 143: printf("Don't forget to remove the last diskette from the disk drive.\n"); ! 144: sync(); ! 145: exit(0); ! 146: } ! 147: ! 148: /* ! 149: * System-specific configuration. A lot of grunge. ! 150: */ ! 151: void ! 152: config() ! 153: { ! 154: register int port, i, polled, parallel; ! 155: char device[6+1]; /* e.g. "com1pr" */ ! 156: char rdevice[7+1]; ! 157: ! 158: cls(1); ! 159: ! 160: #if 0 /* well, waddayaknow... Norm finally added but we've switched to Taylor ! 161: * UUCP. Oh well... ! 162: */ ! 163: if (bflag) { ! 164: /* ! 165: * graft customer's serial number into /usr/lib/uucp/L.sys to ! 166: * reduce tech calls. ! 167: */ ! 168: sprintf(cmd, "/bin/sed -e s/SERIALNUM/`cat /etc/serialno`/g " ! 169: "</usr/lib/uucp/L.sys >/tmp/L.sys ; " ! 170: "/bin/cp /tmp/L.sys /usr/lib/uucp/L.sys ; /bin/rm /tmp/L.sys"); ! 171: sys(cmd, S_NONFATAL); ! 172: } ! 173: # endif ! 174: if (yes_no("Does your computer system have a modem")) { ! 175: printf( ! 176: "You must specify which asychronous serial line your modem will use.\n" ! 177: "See the article \"%s\" in the COHERENT documentation for details.\n", ! 178: #if _I386 ! 179: "asy"); ! 180: #else ! 181: "com"); ! 182: #endif ! 183: port = get_int(1, 4, "Enter 1 to 4 for COM1 through COM4:"); ! 184: i = (port > 2) ? port - 2 : port; /* 1 or 2 */ ! 185: printf( ! 186: "If your computer system uses both ports COM%d and COM%d,\n" ! 187: "one must be run in polled mode rather than interrupt-driven.\n", ! 188: i, i+2); ! 189: polled = yes_no("Do you want to run COM%d in polled mode", port); ! 190: sprintf(cmd, "/bin/ln -f /dev/com%d%sl /dev/modem", ! 191: port, (polled) ? "p" : ""); ! 192: if (sys(cmd, S_NONFATAL) == 0) ! 193: printf("/dev/modem is now linked to /dev/com%d%sl.\n", ! 194: port, (polled) ? "p" : ""); ! 195: printf("\n"); ! 196: } ! 197: if (bflag && yes_no("Does your computer system have a printer")) { ! 198: printf( ! 199: "Your printer is connected to your computer system either through a\n" ! 200: "parallel port or through a serial port; most printers are connected\n" ! 201: "through parallel port LPT1.\n" ! 202: ); ! 203: again: ! 204: parallel = yes_no("Is your printer connected through a parallel port"); ! 205: if (parallel) { ! 206: port = get_int(1, 3, "Enter 1, 2 or 3 for port LPT1, LPT2 or LPT3:"); ! 207: sprintf(device, "lpt%d", port); ! 208: } else { ! 209: port = get_int(1, 4, "Enter 1 to 4 for COM1 through COM4:"); ! 210: i = (port > 2) ? port - 2 : port; ! 211: printf( ! 212: "If your computer system uses both ports COM%d and COM%d,\n" ! 213: "one must be run in polled mode rather than interrupt-driven.\n", ! 214: i, i+2); ! 215: polled = yes_no("Do you want to run COM%d in polled mode", port); ! 216: sprintf(device, "com%d%sl", port, (polled) ? "p" : ""); ! 217: printf("By default, COM%d runs at 9600 baud.\n", port); ! 218: #if _I386 ! 219: printf( ! 220: "If you need a different speed, refer to lexicon article \"asy\" after\n" ! 221: "the installation procedure completes.\n"); ! 222: #else ! 223: if (yes_no("Does your device use a different baud rate")) ! 224: setbaud(port); ! 225: #endif ! 226: } ! 227: printf( ! 228: "Even if you know which port your printer uses under your existing operating\n" ! 229: "system, under COHERENT the port name may be different. For this reason,\n" ! 230: "we strongly recommend that you test your printer configuration.\n" ! 231: "If you test your printer configuration and see no output on your printer,\n" ! 232: "you can try a different configuration until you find the one which works.\n" ! 233: ); ! 234: if (yes_no("Do you want to test whether your printer configuration is correct")) { ! 235: /* The command below is backgrounded in case it hangs. */ ! 236: if (yes_no("Is your printer a PostScript language printer")) ! 237: sprintf(cmd, ! 238: "/bin/echo 'PostScript\ndevice\n/dev/%s.' | prps -p10 >/dev/%s&", ! 239: device, device); ! 240: else /* non-PS printer */ ! 241: sprintf(cmd, ! 242: "/bin/echo -n 'This is printing on device /dev/%s.\r\n\014' >/dev/%s&", ! 243: device, device); /* 014 is formfeed */ ! 244: printf("Testing /dev/%s: process ", device); ! 245: fflush(stdout); ! 246: sys(cmd, S_IGNORE); ! 247: if (!yes_no("\nDid output appear on your printer")) { ! 248: printf( ! 249: "Now try again, specifying a different port for your printer.\n" ! 250: ); ! 251: goto again; ! 252: } ! 253: } ! 254: sprintf(cmd, "/bin/ln -f /dev/%s /dev/lp", device); ! 255: if (sys(cmd, S_NONFATAL) == 0) ! 256: printf("/dev/lp is now linked to /dev/%s.\n", device); ! 257: if (yes_no("Is your printer an HP LaserJet compatible laser printer")) { ! 258: sprintf(cmd, "/bin/ln -f /dev/%s /dev/hp", device); ! 259: if (sys(cmd, S_NONFATAL) == 0) ! 260: printf("/dev/hp is now linked to /dev/%s.\n", device); ! 261: sprintf(rdevice, "%s%s", (parallel) ? "r" : "", device); ! 262: sprintf(cmd, "/bin/ln -f /dev/%s /dev/rhp", rdevice); ! 263: if (sys(cmd, S_NONFATAL) == 0) ! 264: printf("/dev/rhp is now linked to /dev/%s.\n", rdevice); ! 265: } ! 266: printf("\n"); ! 267: } ! 268: } ! 269: ! 270: /* ! 271: * Finish up. ! 272: */ ! 273: void ! 274: done() ! 275: { ! 276: cls(1); ! 277: ! 278: /* Replace the install version of /etc/brc with the normal one. */ ! 279: sys("/bin/rm /etc/brc", S_NONFATAL); ! 280: sys("/bin/ln -f /etc/brc.coh /etc/brc", S_NONFATAL); ! 281: } ! 282: ! 283: /* ! 284: * Install disk n. ! 285: */ ! 286: void ! 287: install(n) int n; ! 288: { ! 289: register int i; ! 290: ! 291: again: ! 292: get_line("Insert a disk from the installation kit into the drive and hit <Enter>.", ! 293: n); ! 294: sprintf(cmd, "/etc/mount %s /mnt -r", device); ! 295: if (sys(cmd, S_NONFATAL)) ! 296: goto again; ! 297: if ((i = newdisk()) == 0) { ! 298: sprintf(cmd, "/etc/umount %s", device); ! 299: sys(cmd, S_NONFATAL); ! 300: goto again; ! 301: } ! 302: printf("Copying disk %d. This will take a few minutes...\n", i); ! 303: sprintf(cmd, "/bin/cpdir -ad%s -smnt %s %s /mnt /", ! 304: (vflag) ? "v" : "", ! 305: (bflag || update) ? "-scompressed" : "", ! 306: (update) ? "`cat /conf/upd_suppress`" : ""); ! 307: sys(cmd, S_FATAL); ! 308: /* ! 309: * If called from /etc/build as part of the COHERENT install/update, ! 310: * suppress any files in directory "compressed" and then go install ! 311: * those files individually while uncompressing and unarchiving. ! 312: */ ! 313: if ((bflag || update) && is_dir("/mnt/compressed")) { ! 314: sys( ! 315: "cd / \n" ! 316: "for Archive in /mnt/compressed/* \n" ! 317: "do \n" ! 318: " case $Archive in \n" ! 319: " *tar*) \n" ! 320: " /usr/bin/gunzip -c $Archive | /usr/bin/ustar xf - ;;\n" ! 321: " *cpio*) \n" ! 322: " /usr/bin/gunzip -c $Archive | /usr/bin/cpio -icdmu ;;\n" ! 323: " /mnt/compressed/\\*) \n" ! 324: " exit 0 ;;\n" ! 325: " *) echo Unknown archive type in file $Archive ;;\n" ! 326: " esac \n" ! 327: "done \n", ! 328: S_NONFATAL); ! 329: } ! 330: sprintf(cmd, "/etc/umount %s", device); ! 331: sys(cmd, S_NONFATAL); ! 332: sprintf(cmd, "/bin/echo /etc/install: disk %d installed >>/etc/install.log", ! 333: i); ! 334: sys(cmd, S_NONFATAL); ! 335: sync(); ! 336: } ! 337: ! 338: /* ! 339: * Check for an appropriate id on the disk on /mnt. ! 340: * Return 0 if not found, disk number otherwise. ! 341: */ ! 342: int ! 343: newdisk() ! 344: { ! 345: register int i; ! 346: static int n; ! 347: ! 348: if (dflag) ! 349: return (n >= ndisks) ? 0 : ++n; ! 350: for (i = 1; i <= ndisks; i++) { ! 351: sprintf(buf, "/mnt/%s.%d", id, i); ! 352: if (!exists(buf)) ! 353: continue; /* not disk i */ ! 354: sprintf(buf, "/%s.%d", id, i); ! 355: if (exists(buf)) { /* exists on root */ ! 356: printf( ! 357: "The disk you inserted is disk %d of the kit;\n" ! 358: "it has already been copied to the hard disk.\n" ! 359: "Please try again.\n", ! 360: i); ! 361: return 0; /* wrong disk */ ! 362: } ! 363: return i; /* ok */ ! 364: } ! 365: printf( ! 366: "The disk you inserted is not part of the kit.\n" ! 367: "Please try again.\n" ! 368: ); ! 369: return 0; /* no id found */ ! 370: } ! 371: ! 372: /* ! 373: * Install new users. ! 374: */ ! 375: void ! 376: newusr() ! 377: { ! 378: static int flag = 0; ! 379: register int n, status, passwd; ! 380: register char *s; ! 381: char homeparent[80], user[80]; ! 382: ! 383: cls(0); ! 384: printf( ! 385: "Your COHERENT system initially allows logins by users \"root\" (superuser)\n" ! 386: "and \"bin\" (system administrator). In addition, the password file contains\n" ! 387: "special entries for \"remacc\" (to control remote access, e.g. via modem),\n" ! 388: "\"daemon\" (the spooler), \"sys\" (to access system information), and\n" ! 389: "\"uucp\" (for communication with other COHERENT systems).\n" ! 390: "\n" ! 391: "If your system has multiple users or allows remote logins, you should assign\n" ! 392: "a password to each user.\n" ! 393: "\n" ! 394: ); ! 395: passwd = yes_no("Do you want to assign passwords to users"); ! 396: if (passwd) { ! 397: printf("You must enter each password twice.\n"); ! 398: if (yes_no("Do you want to assign a password for user \"root\"")) ! 399: sys("passwd root", S_NONFATAL); ! 400: if (yes_no("Do you want to assign a remote access password")) ! 401: sys("passwd remacc", S_NONFATAL); ! 402: if (yes_no("Do you want to assign a password for user \"bin\"")) ! 403: sys("passwd bin", S_NONFATAL); ! 404: if (yes_no("Do you want to assign a password for user \"uucp\"")) ! 405: sys("passwd uucp", S_NONFATAL); ! 406: } ! 407: printf( ! 408: "\nYou should create a login for each additional user of your system.\n" ! 409: ); ! 410: for (n = 0; ;) { ! 411: if (!yes_no("Do you want to create another login")) ! 412: break; ! 413: if (++n == 1) { ! 414: printf( ! 415: "You must specify a login name, a full name and a shell for each user.\n" ! 416: "Joe Smith might have login name \"joe\" and full name \"Joseph H. Smith.\"\n" ! 417: "His home directory would be in \"/usr\" by default, namely \"/usr/joe\".\n" ! 418: "Do not type quotation marks around the names you enter.\n" ! 419: ); ! 420: if (yes_no("Do you want home directories in \"/usr\"")) ! 421: strcpy(homeparent, "/usr"); ! 422: else { ! 423: again: ! 424: s = get_line("Where do you want home directories?"); ! 425: if (*s != '/') { ! 426: printf( ! 427: "Please enter a name beginning with '/', such as \"/u\".\n" ! 428: ); ! 429: goto again; ! 430: } else ! 431: strcpy(homeparent, s); ! 432: } ! 433: if ((status = is_dir(homeparent)) == -1) { ! 434: printf("%s is not a directory, try again.\n", ! 435: homeparent); ! 436: goto again; ! 437: } else if (status == 0) { ! 438: sprintf(cmd, "/bin/mkdir -r %s", homeparent); ! 439: if (sys(cmd, S_NONFATAL) != 0) ! 440: goto again; ! 441: } ! 442: } ! 443: s = get_line("Login name:"); ! 444: strcpy(user, s); ! 445: sprintf(cmd, "/etc/newusr %s ", s); ! 446: s = get_line("Full name:"); ! 447: sprintf(&cmd[strlen(cmd)], "\"%s\" %s", s, homeparent); ! 448: if (flag == 0) { ! 449: ++flag; /* print only first time through */ ! 450: printf( ! 451: "COHERENT includes three different command line interpreters, or shells.\n" ! 452: "A command line interpreter is a program which reads and executes each\n" ! 453: "command which the user types. The available command line interpreters\n" ! 454: "are the Bourne shell (/bin/sh), the Korn shell (/usr/bin/ksh) and the\n" ! 455: "visual (full screen) shell (/usr/bin/vsh).\n\n" ! 456: "Use the visual shell if you prefer a menu-driven interface. Use the\n" ! 457: "Bourne shell if you are not sure which shell to use.\n\n" ! 458: "After you have finished installing COHERENT, you can change the shell\n" ! 459: "for any user by editing the password file /etc/passwd.\n" ! 460: ); ! 461: } ! 462: for (s = NULL; s == NULL; ) { ! 463: if (yes_no("Do you want to user %s to use the Bourne shell (/bin/sh)", ! 464: user)) ! 465: s = "/bin/sh"; ! 466: else if (yes_no("Do you want to user %s to use the visual shell (/usr/bin/vsh)", ! 467: user)) ! 468: s = "/usr/bin/vsh"; ! 469: else if (yes_no("Do you want to user %s to use the Korn shell (/usr/bin/ksh)", ! 470: user)) ! 471: s = "/usr/bin/ksh"; ! 472: else ! 473: printf("You must specify either the Bourne, visual or Korn shell.\n"); ! 474: } ! 475: sprintf(&cmd[strlen(cmd)], " %s", s); ! 476: sys(cmd, S_NONFATAL); ! 477: if (passwd && yes_no("Do you want to assign a password for user \"%s\"", user)) { ! 478: sprintf(cmd, "passwd %s", user); ! 479: sys(cmd, S_NONFATAL); ! 480: } ! 481: } ! 482: printf("\n"); ! 483: } ! 484: ! 485: #if !_I386 ! 486: /* ! 487: * Set a serial port baud rate. ! 488: * Patch the running COHERENT image and /coherent accordingly. ! 489: */ ! 490: void ! 491: setbaud(port) int port; ! 492: { ! 493: register int i, baud; ! 494: ! 495: again: ! 496: printf( ! 497: "The COHERENT serial port driver supports the following baud rates:\n" ! 498: " 50, 75, 110, 134, 150, 200, 300, 600, 1200,\n" ! 499: " 1800, 2000, 2400, 3600, 4800, 7200, 9600, 19200\n" ! 500: "Enter the baud rate of your device (or 0 if your baud rate" ! 501: ); ! 502: baud = get_int(0, 19200, "is not listed):"); ! 503: if (baud == 0) ! 504: return; ! 505: for (i = 1; i <= MAXBAUD; i++) ! 506: if (baudrate[i] == baud) ! 507: break; ! 508: if (i > MAXBAUD) { ! 509: printf("COHERENT does not support baud rate %d.\n", baud); ! 510: goto again; ! 511: } ! 512: ! 513: /* Patch the running COHERENT for possible subsequent test. */ ! 514: sprintf(cmd, "/conf/patch -K /coherent C%dBAUD_=%d", port, i); ! 515: sys(cmd, S_NONFATAL); ! 516: ! 517: /* Patch /coherent for specified baudrate. */ ! 518: sprintf(cmd, "/conf/patch /coherent C%dBAUD_=%d", port, i); ! 519: sys(cmd, S_NONFATAL); ! 520: } ! 521: #endif /* !_I386 */ ! 522: /* end of install.c */ ! 523:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.