lusgr@vax1.cc.lehigh.edu (Steve Roseman) (03/08/91)
> > Is there any interest in my posting scripts and a program to: copy AIX update > tapes (and floppys) to disk and back (to make backups), and to read the > Table-Of-Contents file from an update tape and 1) make a script to rename the > above disk files to real names, and 2) produce a instupdt script to install > the products? > I guess 5 requests before 10 AM imply interest. Here's the program and scripts. Corrections, comments, and improvements welcome. Please no complaints about coding style, I'm a transplanted VMS and fortran programmer who hasn't learn all of the fancy C and shell script stuff yet... Steve ------------------------------------------------------------------------- Steve Roseman Lehigh University Computing Center LUSGR@VAX1.CC.Lehigh.EDU # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by lusgr on Fri Mar 08 10:02:27 EST 1991 # Contents: README.movef movef.c t2d d2t f2d d2f echo x - README.movef sed 's/^@//' > "README.movef" <<'@//E*O*F README.movef//' How to use: 1) find a directory with lots of free space (currently ~150MB) 2) copy the first distribution tape with the command t2d somename_ (that's 1 underline character) and the second tape with t2d somename__ (that's 2 underline characters) 3) back up the files to 2 new tapes using the commands d2t somename_ and d2t somename__ (the above can be used to backup up any distribution tapes, the following is for AIX updates.) 4) run this program movef somename it will read somename_3 and build 2 files, MOVEF.sh and MOVEF_INST.sh. Executing the first will cause the somename_ and somename__ files to be renamed to more meaningful names, like bos.obj, etc. 5) MOVEF_INST.sh contains commands to update the system with everything available. Edit out whatever you don't want. For 3003 and the files on a local disk, I just removed the first 2 (info) updates. 6) Point, via symbolic link or nfs mount, /usr/lpp.install to the directory containing the files, and run MOVEF_INST.sh (of course after doing all of the other stuff in the installation notes!!!) Note: I haven't yet done an install across a network. I suppose you can copy the bosnet updates to a local /usr/lpp.install, install everything except bosnet with nfs up, shut down nfs, and install bosnet. Caveat installer! Good luck, and suggestions welcome. Steve Roseman Lehigh University Computing Center lusgr@chili.cc.lehigh.edu 03/08/91 @//E*O*F README.movef// chmod u=rw,g=r,o=r README.movef echo x - movef.c sed 's/^@//' > "movef.c" <<'@//E*O*F movef.c//' /* rename installation files from TOC file movef prefix Writes 'MOVEF.sh', and 'MOVEF_INST.sh' Steve Roseman Lehigh University Computing Center lusgr@chili.cc.lehigh.edu 03/08/91 */ #include <stdio.h> main(argc, argv) int argc; char *argv[]; { FILE *outfile, *outfile_inst, *TOC; char fnbuf[80], full_name[80], file_no[10], inline[1024], skip, *colon, *lbrk, *per1, *perl; int i, tape_no; if (argc != 2) { printf("Usage: movef prefix\n"); exit(1); } sprintf(fnbuf, "%s_3", argv[1]); if ((TOC = fopen(fnbuf, "r")) == 0) { printf("Cannot open TOC file %s.\n", fnbuf); exit(1); } if ((outfile = fopen("MOVEF.sh", "w")) == 0) { printf("Cannot output output file 'MOVEF.sh'.\n"); exit(1); } chmod("MOVEF.sh", 0755); if ((outfile_inst = fopen("MOVEF_INST.sh", "w")) == 0) { printf("Cannot output output file 'MOVEF_INST.sh'.\n"); exit(1); } chmod("MOVEF_INST.sh", 0755); /* Got the files output, now loop through the TOC file to get the file names of each product. */ while (fgets(inline, 1000, TOC) != EOF) { if (strlen(inline) == 0) break; if ((colon = strchr(inline, ':')) == NULL) continue; if ((lbrk = strchr(inline, '{')) == NULL) continue; sscanf(inline, "%d%c%s", &tape_no, &skip, file_no); /* We got the tape number and file number. Next, get the product name. */ if (fgets(inline, 1000, TOC) == EOF) break; if (strlen(inline) == 0) break; sscanf(inline, "%s", full_name); if ((per1 = strchr(full_name, '.')) == NULL) { strcpy(fnbuf, full_name); } else { perl = per1; while (strchr(perl+1, '.')) { perl = strchr(perl+1, '.'); } *per1 = '\0'; strcpy(fnbuf, full_name); *per1 = '.'; strcat(fnbuf, perl); } /* Finally, build and output the 'mv' and the 'instupdt' commands. */ sprintf(inline, "mv %s", argv[1]); for (i=0 ; i<tape_no ; i++) strcat(inline, "_"); strcat(inline, file_no); strcat(inline, " "); strcat(inline, fnbuf); fprintf(outfile, "%s\n", inline); fprintf(outfile_inst, "instupdt 2>>/tmp/dlw.log -acq -d '/usr/lpp.install/%s' '-v' '-X' '-F' all\n", fnbuf); /* Skip until } found. */ do { if (fgets(inline, 1000, TOC) == EOF) break; if (strlen(inline) == 0) break; } while (inline[0] != '}'); } } @//E*O*F movef.c// chmod u=rw,g=r,o=r movef.c echo x - t2d sed 's/^@//' > "t2d" <<'@//E*O*F t2d//' #!/bin/ksh # # Copy files * from tape to disk (where * is $1 + sequential number # 1, 2, ..) until a zero-length file is reached. # # Usage: t2d prefix # file=1 loop=1 if [ $# -gt 0 ] then prefix=$1 else prefix='f_' fi tctl rewind while [ loop -ne 0 ] do file_name=$prefix"$file" echo Copying $file_name dd of=$file_name if=/dev/rmt0.1 bs=51200 ls -l $file_name if [ -s $file_name ] then let file=$file+1 else rm $file_name echo done tctl rewind & loop=0 fi done @//E*O*F t2d// chmod u=rwx,g=rx,o=rx t2d echo x - d2t sed 's/^@//' > "d2t" <<'@//E*O*F d2t//' #!/bin/ksh # # Copy files * from disk to tape (where * is $1 + sequential number # 1, 2, ..) # # Usage: d2t prefix # file=1 loop=1 if [ $# -gt 0 ] then prefix=$1 else prefix='f_' fi while [ loop -ne 0 ] do file_name=$prefix"$file" if [ -s $file_name ] then echo Copying $file_name dd if=$file_name of=/dev/rmt0.1 bs=5120 let file=$file+1 else echo done tctl rewind & loop=0 fi done @//E*O*F d2t// chmod u=rwx,g=rx,o=rx d2t echo x - f2d sed 's/^@//' > "f2d" <<'@//E*O*F f2d//' #!/bin/ksh # # Copy floppys to disk files name* (where * is $1 + sequential number # 1, 2, ..) Keeps requesting floppies until ^C entered. # # Usage: f2d prefix # file=1 loop=1 if [ $# -gt 0 ] then prefix=$1 else prefix='f_' fi while [ loop -ne 0 ] do file_name=$prefix"$file" echo echo Insert source floppy $file and press Enter, or ^C read a echo Copying $file_name dd if=/dev/fd0 of=$file_name bs=90k ls -l $file_name let file=$file+1 done @//E*O*F f2d// chmod u=rwx,g=rx,o=rx f2d echo x - d2f sed 's/^@//' > "d2f" <<'@//E*O*F d2f//' #!/bin/ksh # # Copy floppy image files * from disk to floppy (where * is $1 + # sequential number 1, 2, ..) # # Usage: d2f prefix # file=1 loop=1 if [ $# -gt 0 ] then prefix=$1 else prefix='f_' fi while [ loop -ne 0 ] do file_name=$prefix"$file" if [ -s $file_name ] then echo echo Insert destination floppy $file and press Enter read a echo Copying $file_name dd if=$file_name of=/dev/fd0 bs=90k let file=$file+1 else loop=0 fi done @//E*O*F d2f// chmod u=rwx,g=rx,o=rx d2f exit 0