[1] | 1 | #!/bin/sh
|
---|
[3542] | 2 | #
|
---|
| 3 | # $Id: mr-mount-subroutine-me 3542 2016-03-24 16:48:03Z bruno $
|
---|
| 4 | #
|
---|
[1] | 5 |
|
---|
[3542] | 6 | LogIt "mr-mount-subroutine-me --- starting"
|
---|
[1] | 7 | if [ "$#" -ne "0" ] ; then
|
---|
[3542] | 8 | LogIt "mr-mount-subroutine-me < mountlist" 1
|
---|
[1] | 9 | exit 1
|
---|
| 10 | fi
|
---|
| 11 |
|
---|
| 12 | # ----------- mount partitions to be restored to --------------
|
---|
| 13 |
|
---|
| 14 | errors=0
|
---|
| 15 |
|
---|
| 16 | read incoming
|
---|
| 17 | while [ "$incoming" != "" ] ; do
|
---|
| 18 | partno=`echo $incoming | cut -d' ' -f1`
|
---|
| 19 | mountpt=`echo $incoming | cut -d' ' -f2`
|
---|
| 20 | mounttype=`echo $incoming | cut -d' ' -f3`
|
---|
| 21 | mountdir="/mnt/RESTORING$mountpt"
|
---|
| 22 | if [ "$mounttype" = "swap" ] ; then
|
---|
[2130] | 23 | swapon $partno
|
---|
[1] | 24 | else
|
---|
| 25 | if [ -e "$mountdir" ] && [ ! -d "$mountdir" ] ; then
|
---|
| 26 | LogIt "$mountdir exists (but not a dir). Deleting..." 2
|
---|
[1999] | 27 | rm -f "$mountdir"
|
---|
[1] | 28 | mkdir -p "$mountdir"
|
---|
| 29 | else
|
---|
| 30 | LogIt "Making dir $mountdir..." 2
|
---|
| 31 | mkdir -p "$mountdir"
|
---|
| 32 | fi
|
---|
| 33 | if [ "$?" -ne "0" ] ; then
|
---|
| 34 | LogIt "Failed to mkdir $mountdir" 3
|
---|
| 35 | errors=$(($errors+1))
|
---|
| 36 | else
|
---|
| 37 | LogIt "$mountdir mounted ok." 2
|
---|
| 38 | fi
|
---|
| 39 | LogIt "Mounting $partno..." 2
|
---|
[2130] | 40 | if [ -e "/tmp/MOUNT-READONLY" ] ; then
|
---|
[1] | 41 | mount $partno -t $mounttype -o ro $mountdir
|
---|
| 42 | else
|
---|
| 43 | mount $partno -t $mounttype $mountdir
|
---|
| 44 | fi
|
---|
| 45 | if [ "$?" -ne "0" ] ; then
|
---|
| 46 | LogIt "Failed to mount $partno" 3
|
---|
| 47 | errors=$(($errors+1))
|
---|
[2130] | 48 | fi
|
---|
| 49 | res=`mount | grep "$partno"`
|
---|
| 50 | if [ "$res" = "" ] ; then
|
---|
| 51 | LogIt "I think I failed to mount $partno" 3
|
---|
| 52 | errors=$(($errors+1))
|
---|
| 53 | else
|
---|
[1] | 54 | LogIt "$partno mounted ok." 2
|
---|
| 55 | fi
|
---|
| 56 | fi
|
---|
| 57 | read incoming
|
---|
| 58 | [ "$incoming" != "" ] || read incoming
|
---|
| 59 | done
|
---|
| 60 |
|
---|
| 61 | if [ "$errors" = "0" ] ; then
|
---|
| 62 | LogIt "All partitions mounted ok." 3
|
---|
| 63 | else
|
---|
| 64 | LogIt "$errors errors occurred during mounting process." 3
|
---|
| 65 | fi
|
---|
| 66 |
|
---|
[3542] | 67 | LogIt "mr-mount-subroutine-me --- leaving"
|
---|
[1] | 68 | exit $errors
|
---|