source: trunk/mondo/mondo/restore-scripts/mondo/label-partitions-as-necessary @ 729

Last change on this file since 729 was 729, checked in by Bruno Cornec, 14 years ago

merge -r686:728 $SVN_M/branches/stable

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.8 KB
RevLine 
[1]1#!/bin/sh
2#
3# 09/05
4# - replaced 'grep -w' with 'grep " $.. "'
5#
6# 06/11
7# - added support for 5th column, for labels
8#
9# 02/02/2003
10# - something
11#
12# mid-2001
13# - first written
14############################################
15
16
17#LogIt() {
18#    echo "$1" >> /dev/stderr
19#}
20
21 
22read_partition_line() {
23    local tmp label mountpt mountline command format
24    if [ "`echo "$1" | grep "LABEL="`" != "" ] ; then
25    tmp=`echo "$1" | tr -s ' ' '\t' | cut -f1`
26    label=`echo "$tmp" | cut -d'=' -f2`
27    format=`echo "$1" | tr -s ' ' '\t' | cut -f3`
28    mountline=`mount | grep " $label "`
29#   mountpt=`echo "$mountline" | cut -d' ' -f1`
[274]30!   mountpt=`grep " $label " $mountlist | cut -d' ' -f1`
[1]31        if [ ! "$mountpt" ] ; then
32            LogIt "Not labeling anything as $label because $mountpt is not a mountpoint"
33        elif [ ! "$label" ] ; then
34            LogIt "Not labeling $mountpt as anything because $label is not a label"
35        else
36            command="e2label $mountpt $label"
37            if [ "$format" = "ext2" ] || [ "$format" = "ext3" ] ; then
38                LogIt "Running '$command'"
39                $command
40            else
41                LogIt "I am NOT going to run '$command': the partition is format '$format', which doesn't like e2label anyway"
42            fi
43    fi
44    fi
45}
46
47
48
49# ---------------------------------------------
50
51LogIt "Labeling your drives with e2label"
52if [ "$#" -ne "1" ] ; then
53    LogIt "label-partitions-as-necessary /tmp/mountlist.txt < /tmp/fstab.new" 1
54    exit 1
55fi
56mountlist=$1
57noof_blank_lines=0
58read line
59while [ "$line" != "" ] && [ "$noof_blank_lines" -le "5" ] ; do
60    if [ "$line" = "" ] ; then
[729]61        noof_blank_lines=$(($noof_blank_lines+1))
[1]62    else
[729]63        noof_blank_lines=0
64        read_partition_line "$line"
[1]65    fi
66    read line
67done
68LogIt "Labeling complete."
69exit 0
Note: See TracBrowser for help on using the repository browser.