source: MondoRescue/branches/2.0.8/mindi/rootfs/sbin/install-additional-tools@ 576

Last change on this file since 576 was 229, checked in by bcornec, 18 years ago

Fix another bug for PXE and the new busybox around mv which doesn't want to move inexistant symlinks. Replaced by tar.
Bug fix in init on dirimg
Preparation of use of udhcpc by adding a symlink

  • Property svn:keywords set to Id
File size: 3.9 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.
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
120
121cd $mountdir
122tar cf - sbin bin usr/bin usr/sbin lib usr/lib | (cd / ; tar xf -)
123cd /
124
125
126for i in modprobe lsmod depmod rmmod ; do
127 [ -e "$mountdir/sbin/$i" ] && ln -sf $mountdir/sbin/$i /sbin/$i
128done
129
130sync;sync;sync
131
132echo "Done."
133
134for j in io.sys msdos.sys embleer.B.bz2 embleer.C.bz2 ; do
135 [ -e "$mountdir/$j" ] && ln -sf $mountdir/$j /$j
136done
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
140which gawk 2> /dev/null > /dev/null
141[ "$?" -ne "0" ] && which awk 2> /dev/null > /dev/null && ln -sf `which awk` /usr/bin/gawk
142
143LogIt "Exiting install-additional-tools"
144exit 0
145
146# exit $res
147
Note: See TracBrowser for help on using the repository browser.