1: #!/bin/sh
2:
3: # AdvancedCopy Manager
4: # All Rights Reserved, Copyright FUJITSU LIMITED, 2004-2007
5:
6: #
7: # Preprocessing of restoration processing
8: #
9: # Argument: $1 Device or VG name of transaction disk
10: # $2 Reserve
11: #
12: # Error number
13: # 2: Argument error
14: # 10: umount error
15: # 50: varyoff error
16: # 99: Script not customize
17:
18: # Argument check
19: case $# in
20: 1)
21: ;;
22: 2)
23: ;;
24: *)
25: exit 2
26: ;;
27: esac
28:
29: device=$1
30:
31: if [ "$SWSTGNODE" != "" ]
32: then
33: swstg_node="/`echo $SWSTGNODE`"
34: else
35: swstg_node=""
36: fi
37:
38: err_log_path="/var/opt/FJSVswsts"$swstg_node"/log"
39:
40: # Determination of postprocessing file name
41: if [ "`echo $device | /usr/bin/grep "/dev/hdisk"`" != "" ]
42: then
43: dev_type="lvm_pv"
44: # /dev/hdisk? -> hdisk?
45: dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
46:
47: elif [ "`echo $device | /usr/bin/grep "/dev/vx/dmp/"`" != "" ]
48: then
49: dev_type="vxvm_pv"
50: # /dev/vx/dmp/device -> device
51: dev="`echo $device | /usr/bin/awk -F\/ '{ print $5 }'`"
52:
53: elif [ "`echo $device | /usr/bin/grep "/dev/"`" != "" ]
54: then
55: dev_type="lvm_vg"
56: # /dev/VG_Name -> VG_Name
57: dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
58:
59: else
60: # Other Volume
61: exit 0
62: fi
63:
64: post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
65:
66: # When the transaction disk is a volume group #############################
67: if [ "$dev_type" = "lvm_vg" ]
68: then
69:
70: # Devices are volume group and script not customize
71: exit 99
72:
73: # When devices of volume group was mounted
74: # Specify the name of volume group to unmount
75: if [ "$device" = "/dev/vgXX" ]
76: then
77: echo "mount" > $post_file
78:
79: # Unmount all logical volumes of the volume group
80: mount_point="/XX"
81: /usr/sbin/umount $mount_point 2>/dev/null
82: if [ $? != 0 ]
83: then
84: retry_count=3
85: sleep_time=1
86: result_flag=1
87:
88: while [ $retry_count -gt 0 ]
89: do
90: /usr/sbin/umount $mount_point > $err_log_path/$dev.umount 2>&1
91: if [ $? != 0 ]
92: then
93: retry_count=`expr $retry_count - 1`
94: /usr/bin/sleep $sleep_time
95: else
96: /usr/bin/rm -f $err_log_path/$dev.umount
97: result_flag=0
98: break
99: fi
100: done
101:
102: if [ $result_flag != 0 ]
103: then
104: /usr/sbin/fuser -cu $mount_point> $err_log_path/$dev.fuser 2>&1
105: /usr/bin/ps -ef > $err_log_path/$dev.ps 2>&1
106:
107: exit 10
108: fi
109: fi
110:
111: # mount_point="/XX"
112: # /usr/sbin/umount $mount_point 2>/dev/null
113: # if [ $? != 0 ]
114: # then
115: # retry_count=3
116: # sleep_time=1
117: # result_flag=1
118: #
119: # while [ $retry_count -gt 0 ]
120: # do
121: # /usr/sbin/umount $mount_point > $err_log_path/$dev.umount 2>&1
122: # if [ $? != 0 ]
123: # then
124: # retry_count=`expr $retry_count - 1`
125: # sleep $sleep_time
126: # else
127: # rm -f $err_log_path/$dev.umount
128: # result_flag=0
129: # break
130: # fi
131: # done
132: #
133: # if [ $result_flag != 0 ]
134: # then
135: # /usr/sbin/fuser -cu $mount_point> $err_log_path/$dev.fuser 2>&1
136: # /usr/bin/ps -ef > $err_log_path/$dev.ps 2>&1
137: #
138: # exit 10
139: # fi
140: # fi
141: fi
142:
143: # varyoff the transaction volume.
144: ACTIVE_VGS=`/usr/sbin/lsvg -o`
145: for i in $ACTIVE_VGS
146: do
147: if [ "$dev" = "$i" ]
148: then
149: /usr/sbin/varyoffvg $i 2> /dev/null
150: if [ $? != 0 ]
151: then
152: /usr/sbin/varyoffvg $i > $err_log_path/$dev.varyoffvg 2>&1
153: if [ $? != 0 ]
154: then
155: exit 50
156: else
157: /usr/bin/rm -f $err_log_path/$dev.varyoffvg 2>&1
158: fi
159: fi
160: break
161: fi
162: done
163:
164: # When the transaction disk is a VxVM physical volume #########################
165: elif [ "$dev_type" = "vxvm_pv" ]
166: then
167: # Nothing is done to VxVM physical volume.
168: echo "none" > $post_file
169:
170: # When the transaction disk is a LVM physical volume ##########################
171: elif [ "$dev_type" = "lvm_pv" ]
172: then
173: # Nothing is done to LVM physical volume.
174: echo "none" > $post_file
175:
176: fi
177:
178: exit 0 |