source: branches/2.2.9/mondo/src/restore-scripts/mondo/make-me-bootable @ 2196

Last change on this file since 2196 was 2196, checked in by Bruno Cornec, 11 years ago

Add option --add-missing to automake to create missing deps

  • 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    # Warning wrong if LVM !
20    drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
21    partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
22
23    if [ "$HAVE_ACTIVE" = "false" ] && [ "`parted2fdisk -l $drive | tr -s '\t' ' ' | grep "$i " | grep -v "*"`" ] ; then
24        if [ "$mountpt" = "/" ] ; then
25            root_drv=$drive
26        root_part=$partno
27        elif [ "$mountpt" = "/boot" ] ; then
28            boot_drv=$drive
29            boot_part=$partno
30        fi
31    fi
32done
33
34if [ "$boot_drv" ] ; then
35    drive=$boot_drv
36    partno=$boot_part
37elif [ "$root_drv" ] ; then
38    drive=$root_drv
39    partno=$root_part
40else
41    driveline=`grep -E '[   ]/boot[     ]' $1`
42    [ ! "$driveline" ] && driveline=`grep -E '[     ]/[     ]' $1`
43    partno=`echo "$driveline" | cut -d' ' -f1 | awk -F "[a-z]" '{print $NF;}'`
44#    echo "driveline=$driveline --> partno=$partno"
45fi
46
47if [ "$drive" ] ; then
48    if [ "$dummy" != "" ] ; then
49        if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
50            partno="1"
51        fi
52        echo "$partno"
53    else
54        echo -en "a\n$partno\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
55    fi
56fi
57exit 0
Note: See TracBrowser for help on using the repository browser.