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