source: MondoRescue/branches/stable/mondo/src/restore-scripts/mondo/label-partitions-as-necessary@ 1297

Last change on this file since 1297 was 1297, checked in by Bruno Cornec, 17 years ago
  • evaluate_drive_within_mountlist is a private function
  • support UUID in mondorestore (Fix for #103)
  • Fix a bug in size computation for cciss and similar devices needing a p before their partition name
  • Fix 2 references to grep -x which are not working during a restore process due to busybox limits of grep command (Fix for #96)
  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.7 KB
Line 
1#!/bin/sh
2#
3# $Id: label-partitions-as-necessary 1297 2007-04-11 23:56:35Z bruno $
4#
5############################################
6
7
8read_partition_line() {
9 local tmp label mountpt command format
10
11 if [ "`echo "$1" | grep -E 'LABEL='`" != "" ] ; then
12 opttun="-L"
13 elif [ "`echo "$1" | grep -E 'UUID='`" != "" ] ; then
14 opttun="-U"
15 else
16 # Nothing to do
17 return
18 fi
19
20 tmp=`echo "$1" | tr -s ' ' '\t' | cut -f1`
21 label=`echo "$tmp" | cut -d'=' -f2`
22 format=`echo "$1" | tr -s ' ' '\t' | cut -f3`
23 mountpt=`grep -w " $label" $mountlist | cut -d' ' -f1`
24 if [ ! "$mountpt" ] ; then
25 LogIt "Not labeling anything as $label because $mountpt is not a mountpoint"
26 elif [ ! "$label" ] ; then
27 LogIt "Not labeling $mountpt as anything because $label is not a label"
28 else
29 if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
30 command="tune2fs $opttun $label $mountpt"
31 LogIt "Running $command"
32 $command
33 elif [ "$format" = "swap" ] ; then
34 if [ "$opttun" = "-U" ]; then
35 echo "Unable yet to identify swap with UUID"
36 else
37 command="mkswap $opttun $label $mountpt"
38 LogIt "Running $command"
39 $command
40 fi
41 else
42 LogIt "I am NOT going to run tune2fs: the partition is format '$format', which doesn't like tune2fs anyway"
43 fi
44 fi
45}
46
47
48# ---------------------------------------------
49
50LogIt "Identifying your drives with tune2fs"
51if [ "$#" -ne "1" ] ; then
52 LogIt "label-partitions-as-necessary /tmp/mountlist.txt < /tmp/fstab.new" 1
53 exit 1
54fi
55mountlist=$1
56noof_blank_lines=0
57read line
58while [ "$line" != "" ] && [ "$noof_blank_lines" -le "5" ] ; do
59 if [ "$line" = "" ] ; then
60 noof_blank_lines=$(($noof_blank_lines+1))
61 else
62 noof_blank_lines=0
63 read_partition_line "$line"
64 fi
65 read line
66done
67LogIt "Labeling complete."
68exit 0
Note: See TracBrowser for help on using the repository browser.