[1] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # 05/04/2003
|
---|
| 4 | # - added missing 'res=0' to line 34
|
---|
| 5 | # - replaced /mnt/groovy-stuff with $GROOVY
|
---|
| 6 | #
|
---|
| 7 | # 07/17/2002
|
---|
| 8 | # - delete dest files before moving src files there
|
---|
| 9 | #
|
---|
| 10 | # 07/11/2002
|
---|
| 11 | # - move softlinks from /mnt/groovy-stuff to / afterward
|
---|
| 12 | #
|
---|
| 13 | # 03/21/2002
|
---|
| 14 | # - added "PLEASE WAIT" when untarring/softlinking
|
---|
| 15 | #
|
---|
| 16 | # 02/18/2002
|
---|
| 17 | ########################################################################
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | Die() {
|
---|
| 21 | echo "Fatal error! $1" >> /dev/stderr
|
---|
| 22 | exit 1
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | # ------------ main -----------
|
---|
| 28 |
|
---|
| 29 | # if the file '/tmp/CDROM-LIVES-HERE' exists then we should use the CD
|
---|
| 30 |
|
---|
| 31 | LogIt "Starting install-additional-tools"
|
---|
| 32 | mountdir=$GROOVY
|
---|
| 33 | mkdir -p $mountdir
|
---|
| 34 | diskno=1
|
---|
| 35 | res=0
|
---|
| 36 | if [ -e "/tmp/TAPEDEV-HAS-DATA-DISKS" ] ; then
|
---|
| 37 | LogIt "I am assuming the data disks' contents are already in $mountdir."
|
---|
| 38 | else
|
---|
| 39 | while [ "$diskno" -lt "20" ] ; do
|
---|
| 40 | LogIt "PLEASE WAIT. Untarring and softlinking disk #$diskno" 2
|
---|
| 41 | untar-and-softlink $diskno $mountdir /
|
---|
| 42 | res=$(($res+$?))
|
---|
| 43 | [ -e "/LAST-DISK" ] && diskno=999
|
---|
| 44 | diskno=$(($diskno+1))
|
---|
| 45 | [ -e "/tmp/CDROM-LIVES-HERE" ] && [ ! -f "/mnt/cdrom/images/$diskno.tar.gz" ] && break
|
---|
| 46 | done
|
---|
| 47 | fi
|
---|
| 48 | rm -f /LAST-DISK
|
---|
| 49 |
|
---|
| 50 | echo -e -n "Recombining large files..."
|
---|
| 51 | biggienumber=0
|
---|
| 52 | while [ -e "$mountdir/slice-$biggienumber.name" ] ; do
|
---|
| 53 | stub=$mountdir/slice-$biggienumber
|
---|
| 54 | biggiefname=`cat $stub.name`
|
---|
| 55 | biggiefsize=`cat $stub.size`
|
---|
| 56 | rm -f $stub.name $stub.size
|
---|
| 57 | # echo -e -n "\rRecombining #$biggienumber ($biggiefname) \r"
|
---|
| 58 | > /tmp/out.dat
|
---|
| 59 | sliceno=0
|
---|
| 60 | while [ "$sliceno" -le "999" ] ; do
|
---|
| 61 | slicefile=$stub.
|
---|
| 62 | [ "$sliceno" -lt "100" ] && slicefile="$slicefile"0
|
---|
| 63 | [ "$sliceno" -lt "10" ] && slicefile="$slicefile"0
|
---|
| 64 | slicefile="$slicefile"$sliceno
|
---|
| 65 | [ ! -e "$slicefile" ] && break
|
---|
| 66 | # echo "biggienumber=$biggienumber slicefile=$slicefile" >> /tmp/mondo-restore.log
|
---|
| 67 | cat $slicefile >> /tmp/out.dat
|
---|
| 68 | rm -f $slicefile
|
---|
| 69 | sliceno=$(($sliceno+1))
|
---|
| 70 | done
|
---|
| 71 | # echo "$sliceno slices"
|
---|
| 72 |
|
---|
| 73 | echo "$biggiefname ($biggiefsize KB) restored. $sliceno slices." >> /tmp/mondo-restore.log
|
---|
| 74 |
|
---|
| 75 | # cat $stub.[0-9]* > /tmp/out.dat
|
---|
| 76 | # rm -f $stub.* ; # .[0-9]* for the slices, plus .name & .size
|
---|
| 77 |
|
---|
| 78 |
|
---|
| 79 | mkdir -p $biggiefname
|
---|
| 80 | rmdir $biggiefname 2> /dev/null
|
---|
| 81 | chmod +x /tmp/out.dat
|
---|
| 82 | cp -f /tmp/out.dat $biggiefname
|
---|
| 83 | rm -f /tmp/out.dat
|
---|
| 84 | biggienumber=$(($biggienumber+1))
|
---|
| 85 | echo -e -n "."
|
---|
| 86 | done
|
---|
| 87 | echo -en "Done. \r"
|
---|
| 88 | rm -f /slice*
|
---|
| 89 |
|
---|
| 90 | LogIt "Resolving softlinks"
|
---|
| 91 | echo -en "Finalizing softlinks..."
|
---|
| 92 |
|
---|
| 93 | cd $mountdir
|
---|
| 94 | for path in `find | grep -v /etc/fstab` ; do
|
---|
| 95 | if [ -d "$path" ] ; then
|
---|
| 96 | mkdir /$path 2> /dev/null
|
---|
| 97 | else
|
---|
| 98 | # Patch from Andrew Bulhak
|
---|
| 99 | if [ -h "/$path" ] ; then
|
---|
| 100 | # echo "removing symlink /$path"
|
---|
| 101 | rm -f /$path
|
---|
| 102 | fi
|
---|
| 103 | # end patch
|
---|
| 104 | mv -f $path /$path
|
---|
| 105 | fi
|
---|
| 106 | done
|
---|
| 107 | cp -f etc/fstab /tmp/fstab
|
---|
| 108 | cd /
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | # Was disabled in mid-March 2002 (?). Dunno why. Re-enabled July 11th, 2002.
|
---|
[229] | 112 | # BERLIOS: This doesn't work for symlink with new busybox in PXE mode
|
---|
| 113 | #for path in /sbin /bin /usr/bin /usr/sbin /lib /usr/lib /lib/* /usr/lib/* ; do
|
---|
| 114 | #[ ! -e "$path" ] && mkdir -p "$path"
|
---|
| 115 | #for i in `ls $mountdir/$path 2> /dev/null` ; do
|
---|
| 116 | #rm -f $path/$i 2> /dev/null
|
---|
| 117 | #mv $mountdir/$path/$i $path 2> /dev/null
|
---|
| 118 | #done
|
---|
| 119 | #done
|
---|
[1] | 120 |
|
---|
[229] | 121 | cd $mountdir
|
---|
| 122 | tar cf - sbin bin usr/bin usr/sbin lib usr/lib | (cd / ; tar xf -)
|
---|
| 123 | cd /
|
---|
[1] | 124 |
|
---|
[229] | 125 |
|
---|
[1] | 126 | for i in modprobe lsmod depmod rmmod ; do
|
---|
| 127 | [ -e "$mountdir/sbin/$i" ] && ln -sf $mountdir/sbin/$i /sbin/$i
|
---|
| 128 | done
|
---|
| 129 |
|
---|
| 130 | sync;sync;sync
|
---|
| 131 |
|
---|
| 132 | echo "Done."
|
---|
| 133 |
|
---|
| 134 | for j in io.sys msdos.sys embleer.B.bz2 embleer.C.bz2 ; do
|
---|
| 135 | [ -e "$mountdir/$j" ] && ln -sf $mountdir/$j /$j
|
---|
| 136 | done
|
---|
| 137 | [ -e "$mountdir/etc/fstab" ] && ln -sf $mountdir/etc/fstab /tmp/fstab
|
---|
| 138 | [ -e "$mountdir/etc/raidtab" ] && ln -sf $mountdir/etc/raidtab /tmp/raidtab
|
---|
| 139 |
|
---|
| 140 | which gawk 2> /dev/null > /dev/null
|
---|
| 141 | [ "$?" -ne "0" ] && which awk 2> /dev/null > /dev/null && ln -sf `which awk` /usr/bin/gawk
|
---|
| 142 |
|
---|
| 143 | LogIt "Exiting install-additional-tools"
|
---|
| 144 | exit 0
|
---|
| 145 |
|
---|
| 146 | # exit $res
|
---|
| 147 |
|
---|