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

Last change on this file was 3542, checked in by Bruno Cornec, 8 years ago
  • Rename all mondorestore scripts with the mr- prefix and adapt callers
  • Place these scripts in /usr/bin on the restore media
  • Fix a mindi bug where these scripts were not copied anymore with previous modifications around removal of cd
  • Property svn:keywords set to Id
  • Property svn:unix-mode set to 755
File size: 1.6 KB
Line 
1#!/bin/sh
2#
3# $Id: mr-unmount-subroutine-me 3542 2016-03-24 16:48:03Z bruno $
4#
5
6LogIt "mr-unmount-subroutine-me --- starting"
7if [ "$#" -ne "0" ] ; then
8 LogIt "mr-unmount-subroutine-me < mountlist" 1
9 exit 1
10fi
11
12
13# ---------------- remount restored partitions R/O -----------
14
15
16failed=""
17succeeded=""
18nonexistent=""
19read incoming
20while [ "$incoming" != "" ] ; do
21 partno=`echo $incoming | cut -d' ' -f1`
22 mountpt=`echo $incoming | cut -d' ' -f2`
23 mounttype=`echo $incoming | cut -d' ' -f3`
24 if [ "$mounttype" = "swap" ] ; then
25 swapoff $partno
26 else
27 umount $partno &> /tmp/unmount.log
28 if [ "$?" -ne "0" ] ; then
29 if [ "`mount | grep $partno`" = "" ] ; then
30 nonexistent="$nonexistent $partno"
31 else
32 failed="$failed $partno"
33# echo "Failed to unmount $partno"
34 fi
35 else
36 succeeded="$succeeded $partno"
37# echo "$partno unmounted ok."
38 fi
39 fi
40 read incoming
41done
42still_failed=""
43retval=0
44for i in $failed ; do
45 umount $i
46 if [ "$?" -ne "0" ] ; then
47 still_failed="$still_failed $i"
48 else
49 succeeded="$succeeded $i"
50 LogIt "$i unmounted ok on the 2nd attempt." 2
51 fi
52done
53if [ "$still_failed" != "" ]; then
54 if [ "$succeeded" != "" ] ; then
55 LogIt "Warning:$succeeded unmounted ok" 1
56 LogIt "but$still_failed could not be unmounted," 1
57 LogIt "even after 2 attempts." 1
58 retval=1
59 else
60 LogIt "No partitions were unmounted. :-/" 1
61 retval=1
62 fi
63elif [ "$succeeded" != "" ] ; then
64 LogIt "All partitions now unmounted." 3
65 retval=0
66else
67 LogIt "All partitions unmounted. <-- before you called me. ;-)" 3
68 retval=0
69fi
70
71LogIt "mr-unmount-subroutine-me --- leaving (retval=$retval)"
72exit $retval
73
Note: See TracBrowser for help on using the repository browser.