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