source: trunk/mondo/mondo/restore-scripts/mondo/make-me-bootable @ 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: 1.8 KB
Line 
1#!/bin/sh
2
3
4LOGFILE=/tmp/mondo-restore.log
5
6
7
8if [ "$#" -ne "1" ] && [ "$#" -ne "2" ] ; then
9    echo "make-me-bootable <fname> (dummy)"
10    exit 1
11fi
12
13dummy=$2
14boot_drv=""
15boot_part=""
16root_drv=""
17root_part=""
18
19HAVE_ACTIVE="false"
20for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -v "/dev/fd" | grep -v "none" | grep -v "#"` ; do
21    mountpt=`cat $1 | grep "$i " | tr -s '\t' ' ' | cut -d' ' -f2`
22    format=`cat $1 | grep "$i " | tr -s '\t' ' ' | cut -d' ' -f3`
23    drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
24    partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
25
26    if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
27        if [ "$mountpt" = "/" ] ; then
28            root_drv=$drive
29        root_part=$partno
30        elif [ "$mountpt" = "/boot" ] ; then
31            boot_drv=$drive
32            boot_part=$partno
33#       if [ "$mountpt" = "/" ] || [ "$mountpt" = "/boot" ] || [ "$format" = "vfat" ] ; then
34#           LogIt "Making $i bootable (drive=$drive, partno=$partno)"
35#           echo -e -n "a\n$partno\nw\n" | fdisk $drive >> $LOGFILE 2>> $LOGFILE
36#            HAVE_ACTIVE="true"
37        fi
38    fi
39done
40
41if [ "$boot_drv" ] ; then
42    drive=$boot_drv
43    partno=$boot_part
44elif [ "$root_drv" ] ; then
45    drive=$root_drv
46    partno=$root_part
47else
48    driveline=`grep -w /boot $1`
49    [ ! "$driveline" ] && driveline=`grep -w / $1`
50    partno=`echo "$driveline" | cut -d' ' -f1 | awk -F "[a-z]" '{print $NF;}'`
51#    echo "driveline=$driveline --> partno=$partno"
52fi
53
54if [ "$drive" ] ; then
55    if [ "$dummy" != "" ] ; then
56        if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
57        partno="1"
58    fi
59        echo "$partno"
60    else
61        echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
62    fi
63fi
64exit 0
Note: See TracBrowser for help on using the repository browser.