1 | #!/bin/sh
|
---|
2 |
|
---|
3 | LogIt "unmount-subroutine-me --- starting"
|
---|
4 | if [ "$#" -ne "0" ] ; then
|
---|
5 | LogIt "unmount-subroutine-me < mountlist" 1
|
---|
6 | exit 1
|
---|
7 | fi
|
---|
8 |
|
---|
9 |
|
---|
10 | # ---------------- remount restored partitions R/O -----------
|
---|
11 |
|
---|
12 |
|
---|
13 | failed=""
|
---|
14 | succeeded=""
|
---|
15 | nonexistent=""
|
---|
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 | if [ "$mounttype" = "swap" ] ; then
|
---|
22 | swapoff $partno
|
---|
23 | else
|
---|
24 | umount $partno &> /tmp/unmount.log
|
---|
25 | if [ "$?" -ne "0" ] ; then
|
---|
26 | if [ "`mount | grep $partno`" = "" ] ; then
|
---|
27 | nonexistent="$nonexistent $partno"
|
---|
28 | else
|
---|
29 | failed="$failed $partno"
|
---|
30 | # echo "Failed to unmount $partno"
|
---|
31 | fi
|
---|
32 | else
|
---|
33 | succeeded="$succeeded $partno"
|
---|
34 | # echo "$partno unmounted ok."
|
---|
35 | fi
|
---|
36 | fi
|
---|
37 | read incoming
|
---|
38 | done
|
---|
39 | still_failed=""
|
---|
40 | retval=0
|
---|
41 | for i in $failed ; do
|
---|
42 | umount $i
|
---|
43 | if [ "$?" -ne "0" ] ; then
|
---|
44 | still_failed="$still_failed $i"
|
---|
45 | else
|
---|
46 | succeeded="$succeeded $i"
|
---|
47 | LogIt "$i unmounted ok on the 2nd attempt." 2
|
---|
48 | fi
|
---|
49 | done
|
---|
50 | if [ "$still_failed" != "" ]; then
|
---|
51 | if [ "$succeeded" != "" ] ; then
|
---|
52 | LogIt "Warning:$succeeded unmounted ok" 1
|
---|
53 | LogIt "but$still_failed could not be unmounted," 1
|
---|
54 | LogIt "even after 2 attempts." 1
|
---|
55 | retval=1
|
---|
56 | else
|
---|
57 | LogIt "No partitions were unmounted. :-/" 1
|
---|
58 | retval=1
|
---|
59 | fi
|
---|
60 | elif [ "$succeeded" != "" ] ; then
|
---|
61 | LogIt "All partitions now unmounted." 3
|
---|
62 | retval=0
|
---|
63 | else
|
---|
64 | LogIt "All partitions unmounted. <-- before you called me. ;-)" 3
|
---|
65 | retval=0
|
---|
66 | fi
|
---|
67 |
|
---|
68 | LogIt "unmount-subroutine-me --- leaving (retval=$retval)"
|
---|
69 | exit $retval
|
---|
70 |
|
---|