[1] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
[866] | 3 | # $Id: install-additional-tools 1315 2007-04-16 14:13:59Z bruno $
|
---|
[1] | 4 | #
|
---|
| 5 | ########################################################################
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | Die() {
|
---|
| 9 | echo "Fatal error! $1" >> /dev/stderr
|
---|
| 10 | exit 1
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | # ------------ main -----------
|
---|
| 16 |
|
---|
| 17 | # if the file '/tmp/CDROM-LIVES-HERE' exists then we should use the CD
|
---|
| 18 |
|
---|
| 19 | LogIt "Starting install-additional-tools"
|
---|
| 20 | mountdir=$GROOVY
|
---|
| 21 | mkdir -p $mountdir
|
---|
| 22 | diskno=1
|
---|
| 23 | res=0
|
---|
| 24 | if [ -e "/tmp/TAPEDEV-HAS-DATA-DISKS" ] ; then
|
---|
| 25 | LogIt "I am assuming the data disks' contents are already in $mountdir."
|
---|
| 26 | else
|
---|
| 27 | while [ "$diskno" -lt "20" ] ; do
|
---|
[866] | 28 | LogIt "PLEASE WAIT. Untarring and softlinking disk #$diskno" 2
|
---|
| 29 | untar-and-softlink $diskno $mountdir /
|
---|
| 30 | res=$(($res+$?))
|
---|
| 31 | [ -e "/LAST-DISK" ] && diskno=999
|
---|
| 32 | diskno=$(($diskno+1))
|
---|
| 33 | [ -e "/tmp/CDROM-LIVES-HERE" ] && [ ! -f "/mnt/cdrom/images/$diskno.tar.gz" ] && break
|
---|
[1] | 34 | done
|
---|
| 35 | fi
|
---|
| 36 | rm -f /LAST-DISK
|
---|
| 37 |
|
---|
| 38 | echo -e -n "Recombining large files..."
|
---|
| 39 | biggienumber=0
|
---|
| 40 | while [ -e "$mountdir/slice-$biggienumber.name" ] ; do
|
---|
| 41 | stub=$mountdir/slice-$biggienumber
|
---|
| 42 | biggiefname=`cat $stub.name`
|
---|
| 43 | biggiefsize=`cat $stub.size`
|
---|
| 44 | rm -f $stub.name $stub.size
|
---|
| 45 | > /tmp/out.dat
|
---|
| 46 | sliceno=0
|
---|
| 47 | while [ "$sliceno" -le "999" ] ; do
|
---|
[866] | 48 | slicefile=$stub.
|
---|
[1] | 49 | [ "$sliceno" -lt "100" ] && slicefile="$slicefile"0
|
---|
[866] | 50 | [ "$sliceno" -lt "10" ] && slicefile="$slicefile"0
|
---|
| 51 | slicefile="$slicefile"$sliceno
|
---|
| 52 | [ ! -e "$slicefile" ] && break
|
---|
| 53 | cat $slicefile >> /tmp/out.dat
|
---|
| 54 | rm -f $slicefile
|
---|
| 55 | sliceno=$(($sliceno+1))
|
---|
| 56 | done
|
---|
[1] | 57 |
|
---|
[1315] | 58 | echo "$biggiefname ($biggiefsize KB) restored. $sliceno slices." >> $LOGFILE
|
---|
[1] | 59 |
|
---|
| 60 | mkdir -p $biggiefname
|
---|
| 61 | rmdir $biggiefname 2> /dev/null
|
---|
| 62 | chmod +x /tmp/out.dat
|
---|
| 63 | cp -f /tmp/out.dat $biggiefname
|
---|
| 64 | rm -f /tmp/out.dat
|
---|
| 65 | biggienumber=$(($biggienumber+1))
|
---|
| 66 | echo -e -n "."
|
---|
| 67 | done
|
---|
| 68 | echo -en "Done. \r"
|
---|
| 69 | rm -f /slice*
|
---|
| 70 |
|
---|
| 71 | LogIt "Resolving softlinks"
|
---|
| 72 | echo -en "Finalizing softlinks..."
|
---|
| 73 |
|
---|
| 74 | cd $mountdir
|
---|
| 75 | for path in `find | grep -v /etc/fstab` ; do
|
---|
| 76 | if [ -d "$path" ] ; then
|
---|
[866] | 77 | mkdir /$path 2> /dev/null
|
---|
[1] | 78 | else
|
---|
| 79 | # Patch from Andrew Bulhak
|
---|
| 80 | if [ -h "/$path" ] ; then
|
---|
| 81 | # echo "removing symlink /$path"
|
---|
| 82 | rm -f /$path
|
---|
| 83 | fi
|
---|
| 84 | # end patch
|
---|
[866] | 85 | mv -f $path /$path
|
---|
[1] | 86 | fi
|
---|
| 87 | done
|
---|
| 88 | cp -f etc/fstab /tmp/fstab
|
---|
[866] | 89 | tar cf - sbin bin usr/bin usr/sbin lib usr/lib lib64 usr/lib64 | (cd / ; tar xf -)
|
---|
[1] | 90 |
|
---|
[229] | 91 | cd /
|
---|
[1] | 92 |
|
---|
| 93 | for i in modprobe lsmod depmod rmmod ; do
|
---|
| 94 | [ -e "$mountdir/sbin/$i" ] && ln -sf $mountdir/sbin/$i /sbin/$i
|
---|
| 95 | done
|
---|
| 96 |
|
---|
| 97 | sync;sync;sync
|
---|
| 98 |
|
---|
| 99 | echo "Done."
|
---|
| 100 |
|
---|
| 101 | for j in io.sys msdos.sys embleer.B.bz2 embleer.C.bz2 ; do
|
---|
| 102 | [ -e "$mountdir/$j" ] && ln -sf $mountdir/$j /$j
|
---|
| 103 | done
|
---|
| 104 | [ -e "$mountdir/etc/fstab" ] && ln -sf $mountdir/etc/fstab /tmp/fstab
|
---|
| 105 | [ -e "$mountdir/etc/raidtab" ] && ln -sf $mountdir/etc/raidtab /tmp/raidtab
|
---|
| 106 |
|
---|
| 107 | which gawk 2> /dev/null > /dev/null
|
---|
| 108 | [ "$?" -ne "0" ] && which awk 2> /dev/null > /dev/null && ln -sf `which awk` /usr/bin/gawk
|
---|
| 109 |
|
---|
| 110 | LogIt "Exiting install-additional-tools"
|
---|
| 111 | exit 0
|
---|
| 112 |
|
---|
| 113 | # exit $res
|
---|
| 114 |
|
---|