~lupin-team/lvpm/devel

« back to all changes in this revision

Viewing changes to lvpm/usr/bin/lvpm-real

  • Committer: geza User
  • Date: 2007-07-10 05:29:12 UTC
  • Revision ID: geza@ubuntu-20070710052912-97uugtaxjrr9kxp9
removed dependency on os-prober

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
exit 0
23
23
fi
24
24
 
25
 
ostitlename=$(os-prober | sed "s/:/\n/g" | head --lines 2 | tail --lines 1)
26
 
fullrawdevstring=$(os-prober | sed "s/:/\n/g" | head --lines 1 | grep /dev/)
27
 
if [ "$fullrawdevstring" != "" ];
28
 
then
29
 
is1os=yes
30
 
rawdevstring=$(echo $fullrawdevstring | tail --bytes 3 | head --bytes 2)
31
 
partno2=$(expr $(echo $rawdevstring | head --bytes 2 | tail --bytes 1) - 1)
32
 
partgtd2=$(echo $rawdevstring | head --bytes 1 | sed -e s/a/0/ -e s/b/1/ -e s/c/2/ -e s/e/4/ -e s/f/5/ -e s/g/6/ -e s/h/7/ -e s/i/8/ -e s/j/9/ -e s/k/10/ -e s/l/11/ -e s/m/12/ -e s/n/13/ -e s/o/14/ -e s/p/15/ -e s/q/16/ -e s/r/17/ -e s/s/18/ -e s/t/19/ -e s/u/20/ -e s/v/21/ -e s/w/22/ -e s/x/23/ -e s/y/24/ -e s/z/25/)
33
 
partgtp2=$(echo $partgtd2,$partno2)
34
 
gtp2="(hd$partgtp2)"
35
 
fi
36
 
 
37
 
sosdevstring=$(os-prober | sed "s/:/\n/g" | head --lines 5 | tail --lines 1 | grep /dev/)
38
 
if [ "$sosdevstring" != "" ];
39
 
then
40
 
is2os=yes
41
 
sostitlename=$(os-prober | sed "s/:/\n/g" | head --lines 6 | tail --lines 1)
42
 
rawdevstring2=$(echo $sosdevstring | tail --bytes 3 | head --bytes 2)
43
 
partno3=$(expr $(echo $rawdevstring2 | head --bytes 2 | tail --bytes 1) - 1)
44
 
partgtd3=$(echo $rawdevstring2 | head --bytes 1 | sed -e s/a/0/ -e s/b/1/ -e s/c/2/ -e s/e/4/ -e s/f/5/ -e s/g/6/ -e s/h/7/ -e s/i/8/ -e s/j/9/ -e s/k/10/ -e s/l/11/ -e s/m/12/ -e s/n/13/ -e s/o/14/ -e s/p/15/ -e s/q/16/ -e s/r/17/ -e s/s/18/ -e s/t/19/ -e s/u/20/ -e s/v/21/ -e s/w/22/ -e s/x/23/ -e s/y/24/ -e s/z/25/)
45
 
partgtp3=$(echo $partgtd3,$partno3)
46
 
gtp3="(hd$partgtp3)"
47
 
else
48
 
is2os=no
49
 
fi
50
 
 
51
 
tosdevstring=$(os-prober | sed "s/:/\n/g" | head --lines 9 | tail --lines 1 | grep /dev/)
52
 
if [ "$tosdevstring" != "" ];
53
 
then
54
 
is3os=yes
55
 
tostitlename=$(os-prober | sed "s/:/\n/g" | head --lines 10 | tail --lines 1)
56
 
rawdevstring3=$(echo $tosdevstring | tail --bytes 3 | head --bytes 2)
57
 
partno4=$(expr $(echo $rawdevstring3 | head --bytes 2 | tail --bytes 1) - 1)
58
 
partgtd4=$(echo $rawdevstring3 | head --bytes 1 | sed -e s/a/0/ -e s/b/1/ -e s/c/2/ -e s/e/4/ -e s/f/5/ -e s/g/6/ -e s/h/7/ -e s/i/8/ -e s/j/9/ -e s/k/10/ -e s/l/11/ -e s/m/12/ -e s/n/13/ -e s/o/14/ -e s/p/15/ -e s/q/16/ -e s/r/17/ -e s/s/18/ -e s/t/19/ -e s/u/20/ -e s/v/21/ -e s/w/22/ -e s/x/23/ -e s/y/24/ -e s/z/25/)
59
 
partgtp4=$(echo $partgtd4,$partno4)
60
 
gtp4="(hd$partgtp4)"
61
 
else
62
 
is3os=no
 
25
hostosroot=$(cat /proc/mounts | grep /media/host | sed "s/\t/\n/g" | sed "s/ /\n/g" | head --lines 1 | grep /dev/)
 
26
hostosdrivenum=$(echo $hostosroot | tail --bytes 3 | head --bytes 1 | sed -e s/a/0/ -e s/b/1/ -e s/c/2/ -e s/e/4/ -e s/f/5/ -e s/g/6/ -e s/h/7/ -e s/i/8/ -e s/j/9/ -e s/k/10/ -e s/l/11/ -e s/m/12/ -e s/n/13/ -e s/o/14/ -e s/p/15/ -e s/q/16/ -e s/r/17/ -e s/s/18/ -e s/t/19/ -e s/u/20/ -e s/v/21/ -e s/w/22/ -e s/x/23/ -e s/y/24/ -e s/z/25/)
 
27
hostospartnum=$(expr $(echo $hostosroot | tail --bytes 2 | head --bytes 1) - 1)
 
28
hostosgrubnum="(hd$(echo $hostosdrivenum),$(echo $hostospartnum))"
 
29
hostosfstype=$(vol_id -t $hostosroot)
 
30
if [ "$hostosfstype" = "ntfs" ]; then
 
31
hostosname="Windows"
 
32
fi
 
33
if [ "$hostosfstype" = "vfat" ]; then
 
34
hostosname="Windows"
 
35
fi
 
36
if [ "$hostosfstype" = "ext3" ]; then
 
37
hostosname="Linux"
 
38
fi
 
39
if [ "$hostosfstype" = "ext3" ]; then
 
40
hostosname="Linux"
 
41
fi
 
42
if [ "$hostosfstype" = "ext2" ]; then
 
43
hostosname="Linux"
 
44
fi
 
45
if [ "$hostosfstype" = "reiserfs" ]; then
 
46
hostosname="Linux"
 
47
fi
 
48
if [ "$hostosfstype" = "jfs" ]; then
 
49
hostosname="Linux"
 
50
fi
 
51
if [ "$hostosfstype" = "xfs" ]; then
 
52
hostosname="Linux"
 
53
fi
 
54
if [ -s $hostosname ]; then
 
55
hostosname="Unknownos"
63
56
fi
64
57
 
65
58
umount $tdp
93
86
rm /media/tdm/boot/grub/menu.lst
94
87
rm /media/tdm/etc/fstab
95
88
touch /media/tdm/etc/fstab
 
89
mkdir /media/tdm/media/host
 
90
mhostosfstype=$(echo $hostosfstype | sed "s/ntfs/ntfs-3g/")
96
91
 
97
92
echo \
98
93
"# <file system> <mount point>   <type>  <options>       <dump>  <pass>
99
94
proc            /proc           proc        defaults    0   0
100
95
$tdp      /               $tpf        defaults    0   1
 
96
$hostosroot       /media/host       $mhostosfstype         defaults      0   0
101
97
" > /media/tdm/etc/fstab
102
98
if [ "$sdp" != "" ];
103
99
then
108
104
" >> /media/tdm/etc/fstab
109
105
fi
110
106
 
111
 
host1uuid=$(vol_id $fullrawdevstring |  grep UUID | sed s/ID_FS_//)
112
 
host1fstype=$(vol_id -t $fullrawdevstring | sed s/ntfs/ntfs-3g/)
113
 
echo \
114
 
"
115
 
$fullrawdevstring      /media/host            $host1fstype        defaults          0   1
116
 
" >> /media/tdm/etc/fstab
117
 
 
118
 
if [ "$is2os" = "yes" ];
119
 
then
120
 
host2fstype=$(vol_id -t $sosdevstring | sed s/ntfs/ntfs-3g/)
121
 
mkdir /media/tdm/media/host2
122
 
host2uuid=$(vol_id $sosdevstring |  grep UUID | sed s/ID_FS_//)
123
 
echo \
124
 
"
125
 
$sosdevstring      /media/host2            $host2fstype        defaults          0   1
126
 
" >> /media/tdm/etc/fstab
127
 
fi
128
 
 
129
 
if [ "$is3os" = "yes" ];
130
 
then
131
 
host3fstype=$(vol_id -t $tosdevstring | sed s/ntfs/ntfs-3g/)
132
 
mkdir /media/tdm/media/host3
133
 
host3uuid=$(vol_id $sosdevstring |  grep UUID | sed s/ID_FS_//)
134
 
echo \
135
 
"
136
 
$tosdevstring      /media/host3            $host3fstype        defaults          0   1
137
 
" >> /media/tdm/etc/fstab
138
 
fi
139
 
 
140
 
 
141
107
chroot /media/tdm <<EOT
142
108
dpkg --force-all --purge lupin-target
143
109
 
180
146
exit
181
147
EOT
182
148
 
183
 
hostosroot=$(cat /proc/mounts | grep /media/host | sed "s/\t/\n/g" | sed "s/ /\n/g" | head --lines 1 | grep /dev/)
184
 
hostosdrivenum=$(echo $hostosroot | tail --bytes 3 | head --bytes 1 | sed -e s/a/0/ -e s/b/1/ -e s/c/2/ -e s/e/4/ -e s/f/5/ -e s/g/6/ -e s/h/7/ -e s/i/8/ -e s/j/9/ -e s/k/10/ -e s/l/11/ -e s/m/12/ -e s/n/13/ -e s/o/14/ -e s/p/15/ -e s/q/16/ -e s/r/17/ -e s/s/18/ -e s/t/19/ -e s/u/20/ -e s/v/21/ -e s/w/22/ -e s/x/23/ -e s/y/24/ -e s/z/25/)
185
 
hostospartnum=$(expr $(echo $hostosroot | tail --bytes 2 | head --bytes 1) - 1)
186
 
hostosgrubnum="(hd$(echo $hostosdrivenum),$(echo $hostospartnum))"
187
 
hostosfstype=$(vol_id -t $hostosroot)
188
 
if [ "$hostosfstype" = "ntfs" ]; then
189
 
hostosname="Windows"
190
 
fi
191
 
if [ "$hostosfstype" = "vfat" ]; then
192
 
hostosname="Windows"
193
 
fi
194
 
if [ "$hostosfstype" = "ext3" ]; then
195
 
hostosname="Linux"
196
 
fi
197
 
if [ "$hostosfstype" = "ext3" ]; then
198
 
hostosname="Linux"
199
 
fi
200
 
if [ "$hostosfstype" = "ext2" ]; then
201
 
hostosname="Linux"
202
 
fi
203
 
if [ "$hostosfstype" = "reiserfs" ]; then
204
 
hostosname="Linux"
205
 
fi
206
 
if [ "$hostosfstype" = "jfs" ]; then
207
 
hostosname="Linux"
208
 
fi
209
 
if [ "$hostosfstype" = "xfs" ]; then
210
 
hostosname="Linux"
211
 
fi
212
 
if [ -s $hostosname ]; then
213
 
hostosname="Unknownos"
214
 
fi
215
 
 
216
149
echo \
217
150
"
218
151
# This is a divider, added to separate the menu items below from the Debian
241
174
" >> /media/tdm/boot/grub/menu.lst
242
175
fi
243
176
 
244
 
if [ "$is1os" = "yes" ];
245
 
then
246
 
echo \
247
 
"
248
 
title $ostitlename
249
 
root $gtp2
250
 
makeactive
251
 
chainloader +1
252
 
boot
253
 
" >> /media/tdm/boot/grub/menu.lst
254
 
fi
255
 
 
256
 
if [ "$is2os" = "yes" ];
257
 
then
258
 
echo \
259
 
"
260
 
title $sostitlename
261
 
root $gtp3
262
 
makeactive
263
 
chainloader +1
264
 
boot
265
 
" >> /media/tdm/boot/grub/menu.lst
266
 
fi
267
 
 
268
 
if [ "$is3os" = "yes" ];
269
 
then
270
 
echo \
271
 
"
272
 
title $tostitlename
273
 
root $gtp4
274
 
makeactive
275
 
chainloader +1
276
 
boot
277
 
" >> /media/tdm/boot/grub/menu.lst
278
 
fi
279
 
 
280
 
sed -i "s/hiddenmenu/#hiddenmenu/g" /media/tdm/boot/grub/menu.lst
281
 
sed -i "s/ #hiddenmenu/ hiddenmenu/" /media/tdm/boot/grub/menu.lst
 
177
if [ "$hostosname" = "Unknownos" ]; then
 
178
echo \
 
179
"
 
180
title Unknownos
 
181
root $hostosgrubnum
 
182
makeactive
 
183
chainloader +1
 
184
boot
 
185
" >> /media/tdm/boot/grub/menu.lst
 
186
fi
 
187
 
 
188
sed -i -e "s/hiddenmenu/#hiddenmenu/g" -e "s/ #hiddenmenu/ hiddenmenu/" /media/tdm/boot/grub/menu.lst
282
189
 
283
190
umount /media/tdm
284
191
rm -r /media/tdm