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

Last change on this file since 901 was 901, checked in by Bruno Cornec, 17 years ago

Attempt to fix #87

  • 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 901 2006-10-24 07:31:35Z bruno $
4#
5############################################
6
7
8read_partition_line() {
9 local tmp label mountpt mountline command format
10 if [ "`echo "$1" | grep "LABEL="`" != "" ] ; then
11 tmp=`echo "$1" | tr -s ' ' '\t' | cut -f1`
12 label=`echo "$tmp" | cut -d'=' -f2`
13 format=`echo "$1" | tr -s ' ' '\t' | cut -f3`
14 mountline=`mount | grep " $label "`
15# mountpt=`echo "$mountline" | cut -d' ' -f1`
16! mountpt=`grep " $label " $mountlist | cut -d' ' -f1`
17 if [ ! "$mountpt" ] ; then
18 LogIt "Not labeling anything as $label because $mountpt is not a mountpoint"
19 elif [ ! "$label" ] ; then
20 LogIt "Not labeling $mountpt as anything because $label is not a label"
21 else
22 if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
23 command="e2label $mountpt $label"
24 LogIt "Running $command"
25 $command
26 elif [ "$format" = "swap" ] ; then
27 command="mkswap -L $label $mountpt"
28 LogIt "Running $command"
29 else
30 LogIt "I am NOT going to run e2label: the partition is format '$format', which doesn't like e2label anyway"
31 fi
32 fi
33 fi
34}
35
36
37
38# ---------------------------------------------
39
40LogIt "Labeling your drives with e2label"
41if [ "$#" -ne "1" ] ; then
42 LogIt "label-partitions-as-necessary /tmp/mountlist.txt < /tmp/fstab.new" 1
43 exit 1
44fi
45mountlist=$1
46noof_blank_lines=0
47read line
48while [ "$line" != "" ] && [ "$noof_blank_lines" -le "5" ] ; do
49 if [ "$line" = "" ] ; then
50 noof_blank_lines=$(($noof_blank_lines+1))
51 else
52 noof_blank_lines=0
53 read_partition_line "$line"
54 fi
55 read line
56done
57LogIt "Labeling complete."
58exit 0
Note: See TracBrowser for help on using the repository browser.