source: MondoRescue/branches/3.0/mondo/src/restore-scripts/mondo/make-me-bootable@ 3071

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

r5064@localhost: bruno | 2012-11-15 01:16:49 +0100

  • Adds more drivers in mindi to better support iscsi env
  • Fix again the bootable flag by calling the script with an action (was noaction !!) and having a better debug log in case of noaction
  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.9 KB
RevLine 
[1]1#!/bin/sh
2
3
[3057]4if [ "$#" -ne "2" ] && [ "$#" -ne "3" ] ; then
5 echo "make-me-bootable <fname> <drive> [noaction]"
[1]6 exit 1
7fi
8
[3057]9drivetouse=$2
[1]10boot_drv=""
11boot_part=""
12root_drv=""
13root_part=""
[3057]14if [ ! "$LOGFILE" ]; then
15 LOGFILE="/tmp/mondorestore2.log"
16fi
17dummy="$3"
[1]18
[3057]19activepart=`parted2fdisk -l $drivetouse | tr -s '\t' ' ' | grep "$drivetouse" | grep '*' | cut -d' ' -f1`
20
[680]21for i in `cat $1 | tr -s '\t' ' ' | cut -d' ' -f1 | grep -vE "/dev/fd|none|#"` ; do
[2196]22 # Warning wrong if LVM !
[1]23 drive=`echo $i | sed -e 's/[0-9]*$//' -e 's/\([0-9]\)p$/\1/'`
[3057]24 if [ "$drivetouse" = "$drive" ]; then
25 # We can continue as this is the drive we ned to work on
26 partno=`echo $i | sed -e 's/^.*[^0-9]\([0-9]*\)$/\1/'`
27 mountpt=`grep "$i " $1 | tr -s '\t' ' ' | cut -d' ' -f2`
[1]28
29 if [ "$mountpt" = "/" ] ; then
30 root_drv=$drive
[3057]31 root_part=$partno
[1]32 elif [ "$mountpt" = "/boot" ] ; then
33 boot_drv=$drive
34 boot_part=$partno
35 fi
36 fi
37done
38
39if [ "$boot_drv" ] ; then
40 drive=$boot_drv
41 partno=$boot_part
42elif [ "$root_drv" ] ; then
43 drive=$root_drv
44 partno=$root_part
45else
[911]46 driveline=`grep -E '[ ]/boot[ ]' $1`
47 [ ! "$driveline" ] && driveline=`grep -E '[ ]/[ ]' $1`
[1]48 partno=`echo "$driveline" | cut -d' ' -f1 | awk -F "[a-z]" '{print $NF;}'`
49# echo "driveline=$driveline --> partno=$partno"
50fi
51
52if [ "$drive" ] ; then
[3057]53 if [ "$partno" = "0" ] || [ ! "$partno" ] ; then
54 partno="1"
55 fi
56 cmd=""
57 for p in "$activepart"; do
58 # First desactivate active partitions (coming from previous usage)
59 cmd="${cmd}a\n$p\n"
60 if [ "$dummy" != "" ] ; then
61 echo "Will desactivate $p on $drive" >> $LOGFILE
62 fi
63 done
64 # Then activate the one which should
[1]65 if [ "$dummy" != "" ] ; then
[3071]66 echo "Would activate $partno on $drive" >> $LOGFILE
[3057]67 else
68 echo -en "${cmd}a\n$partno\np\nw\n" | parted2fdisk $drive >> $LOGFILE 2>> $LOGFILE
69 fi
[1]70fi
71exit 0
Note: See TracBrowser for help on using the repository browser.