source: MondoRescue/branches/3.2/mondo/src/restore-scripts/mondo/unmount-subroutine-me@ 3510

Last change on this file since 3510 was 567, checked in by bcornec, 18 years ago

Same for mondo: setup modes correctly in SVN and get rid of %attr an %defattr in spec files to get correct packages

  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.6 KB
Line 
1#!/bin/sh
2
3LogIt "unmount-subroutine-me --- starting"
4if [ "$#" -ne "0" ] ; then
5 LogIt "unmount-subroutine-me < mountlist" 1
6 exit 1
7fi
8
9
10# ---------------- remount restored partitions R/O -----------
11
12
13failed=""
14succeeded=""
15nonexistent=""
16read incoming
17while [ "$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
38done
39still_failed=""
40retval=0
41for 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
49done
50if [ "$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
60elif [ "$succeeded" != "" ] ; then
61 LogIt "All partitions now unmounted." 3
62 retval=0
63else
64 LogIt "All partitions unmounted. <-- before you called me. ;-)" 3
65 retval=0
66fi
67
68LogIt "unmount-subroutine-me --- leaving (retval=$retval)"
69exit $retval
70
Note: See TracBrowser for help on using the repository browser.