source: trunk/mindi/rootfs/sbin/install-additional-tools @ 1

Last change on this file since 1 was 1, checked in by bcornec, 14 years ago

Initial import from latest mondo-2.04_cvs_20050503/mindi-1.04_cvs_20050503 on http://www.mondorescue.org

File size: 3.7 KB
Line 
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
20Die() {
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
31LogIt "Starting install-additional-tools"
32mountdir=$GROOVY
33mkdir -p $mountdir
34diskno=1
35res=0
36if [ -e "/tmp/TAPEDEV-HAS-DATA-DISKS" ] ; then
37    LogIt "I am assuming the data disks' contents are already in $mountdir."
38else
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
47fi
48rm -f /LAST-DISK
49
50echo -e -n "Recombining large files..."
51biggienumber=0
52while [ -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 "."
86done
87echo -en "Done.                                                              \r"
88rm -f /slice*
89
90LogIt "Resolving softlinks"
91echo -en "Finalizing softlinks..."
92
93cd $mountdir
94for 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
106done
107cp -f etc/fstab /tmp/fstab
108cd /
109
110
111# Was disabled in mid-March 2002 (?). Dunno why. Re-enabled July 11th, 2002.
112for path in /sbin /bin /usr/bin /usr/sbin /lib /usr/lib /lib/* /usr/lib/* ; do
113    mkdir -p $path
114    for i in `ls $mountdir/$path 2> /dev/null` ; do
115    rm -f $path/$i 2> /dev/null
116        mv $mountdir/$path/$i $path 2> /dev/null
117    done   
118done
119
120
121for i in modprobe lsmod depmod rmmod ; do
122    [ -e "$mountdir/sbin/$i" ] && ln -sf $mountdir/sbin/$i /sbin/$i
123done
124
125sync;sync;sync
126
127echo "Done."
128
129for j in io.sys msdos.sys embleer.B.bz2 embleer.C.bz2 ; do
130    [ -e "$mountdir/$j" ] && ln -sf $mountdir/$j /$j
131done
132[ -e "$mountdir/etc/fstab" ] && ln -sf $mountdir/etc/fstab /tmp/fstab
133[ -e "$mountdir/etc/raidtab" ] && ln -sf $mountdir/etc/raidtab /tmp/raidtab
134
135which gawk 2> /dev/null > /dev/null
136[ "$?" -ne "0" ] && which awk 2> /dev/null > /dev/null && ln -sf `which awk` /usr/bin/gawk
137
138LogIt "Exiting install-additional-tools"
139exit 0
140
141# exit $res
142
Note: See TracBrowser for help on using the repository browser.