source: branches/stable/mondo/src/restore-scripts/mondo/hack-lilo @ 1341

Last change on this file since 1341 was 1341, checked in by Bruno Cornec, 13 years ago
  • Remove compare-me
  • Update Logfiles for mondo scripts
  • label-partitions-as-necessary is now correct
  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 3.3 KB
Line 
1#!/bin/sh
2#
3# $Id: hack-lilo 1341 2007-04-24 22:27:26Z bruno $
4#
5
6
7GetDevFromLine() {
8    echo "$1" | cut -d'=' -f2 | sed s/' '//
9}
10
11
12GetOldFstabMountpoint() {
13    local res
14    res=`tr -s '\t' ' ' < $old_fstab | grep "$1" | cut -d' ' -f2`
15#    echo "old_fstab = $old_fstab" >> /dev/stderr
16    if [ "$res" = "" ] ; then
17#   echo "OK, resB" >> /dev/stderr
18    res=`tr -s '\t' ' ' < $old_mountlist | grep " $1 " | cut -d' ' -f1`
19    fi
20    echo "$res"
21}
22
23
24GetNewFstabMountpoint() {
25    for i in fd0 fd0u1722 fd0h1440 fd0H1440 cdrom cdrw cdrom2 ; do
26    if [ "$1" = "/dev/$i" ] ; then
27        echo "/dev/$i"
28        return
29    fi
30    done
31    old_mountpoint=`GetOldFstabMountpoint $1`
32#    echo "old_mountpoint = $old_mountpoint" >> /dev/stderr
33    new_mountpoint=`tr -s '\t' ' ' < $new_mountlist | grep " $old_mountpoint" | cut -d' ' -f1`
34    if [ "$new_mountpoint" = "" ] ; then
35    mtpt=`tr -s '\t' ' ' < $new_mountlist | grep " $old_mountpoint " | cut -d' ' -f2`
36    dev=`tr -s '\t' ' ' < $new_mountlist | grep " $mtpt " | cut -d' ' -f1`
37#   echo "NEW_MP (A) = $dev" >> /dev/stderr
38#    else
39#   echo "NEW_MP (B) = $new_mountpoint" >> /dev/stderr
40    fi
41}
42
43
44
45ProcessBigHack() {
46    local incoming dev newdev col2 col1_new
47    incoming="$1"
48#    echo "incoming = $1" >> /dev/stderr
49    dev=`GetDevFromLine "$incoming"`
50#    GetOldFstabMountpoint $dev
51    newdev=`GetNewFstabMountpoint $dev`
52    if [ ! "$newdev" ] ; then
53    col2=`grep "$dev " $old_mountlist | cut -d' ' -f2`
54    col1_new=`grep " $col2 " $new_mountlist | cut -d' ' -f1`
55    newdev="$col1_new"
56    if [ ! "$newdev" ] ; then
57        newdev=$dev
58    fi
59    fi
60#    old_fstab_line=`grep "$dev" $new_fstab`
61    [ "$2" = "other" ] || echo -e -n "\t"
62    echo -e "$2=$newdev"
63    echo "$newdev" >> $bootlistfile
64}
65
66ProcessOther() {
67    ProcessBigHack "$1" "other"
68}
69
70
71ProcessRoot() {
72    ProcessBigHack "$1" "root"
73}
74
75
76
77ProcessLilo() {
78    local incoming bonks blanklines
79    read incoming
80    bonks=0
81    blanklines=0
82    while [ "$blanklines" -lt "5" ] ; do
83    if [ "$incoming" = "" ] ; then
84        blanklines=$(($blanklines+1))
85            read incoming
86            continue
87        fi
88        blanklines=0
89        if [ "`echo "$incoming" | grep "#"`" != "" ] ; then
90            echo "$incoming"
91    elif [ "`echo "$incoming" | grep "other.*="`" != "" ] ; then
92        ProcessOther "$incoming"
93        bonks=$(($bonks+1))
94    elif [ "`echo "$incoming" | grep "root.*="`" != "" ] ; then
95        ProcessRoot "$incoming"
96        bonks=$(($bonks+1))
97    elif [ "`echo "$incoming" | grep "image.*="`" != "" ] ; then
98        bonks=$(($bonks+1))
99        echo "$incoming"
100    else
101        if [ "$bonks" -gt "0" ] && [ "`echo "$incoming" | grep "image"`" = "" ]  ; then
102        echo -e -n "\t"
103        fi
104        echo "$incoming"
105    fi
106    read incoming
107    done
108}
109
110
111# ------------------ main ------------------
112
113LogIt "hack-lilo --- starting"
114
115bootlistfile=/tmp/partitions-to-make-bootable.txt
116> $bootlistfile
117
118if [ "$#" -ne "6" ] ; then
119    LogIt "hack-lilo <old mountlist> <old fstab> <old lilo> <new mountlist> <new fstab> <new lilo>" 1
120    LogIt "NB: the new lilo file is outgoing; all others are incoming." 1
121    exit 1
122fi
123
124old_mountlist=$1
125old_fstab=$2
126old_lilo=$3
127new_mountlist=$4
128new_fstab=$5
129outfile=$6
130
131> $outfile
132ProcessLilo < $old_lilo >> $outfile
133chmod 600 $outfile
134sort -u $bootlistfile -o $bootlistfile
135
136#------ disabled 12/10/01 (doesn't do anything anyway *g*)
137#make-me-bootable $bootlistfile > /tmp/make-me-bootable.log 2> /tmp/make-me-bootable.log
138
139LogIt "hack-lilo --- leaving"
140exit 0
Note: See TracBrowser for help on using the repository browser.