1 | #!/bin/bash |
---|
2 | |
---|
3 | # SLES 9 only |
---|
4 | # This script is written in bash (instead of ksh) because it invokes SLES scripts |
---|
5 | |
---|
6 | # Check for pre-requisites (files) |
---|
7 | prereq() { |
---|
8 | for file in $*; do |
---|
9 | if [ ! -f $file ]; then |
---|
10 | echo "Cannot find $file. See /usr/lpp/mmfs/samples/nfscluster/README for uninstall instructions." |
---|
11 | exit 0 |
---|
12 | fi |
---|
13 | done |
---|
14 | } |
---|
15 | |
---|
16 | unconfig() { |
---|
17 | . /etc/rc.status |
---|
18 | |
---|
19 | rc_reset |
---|
20 | |
---|
21 | # Check for SUSE distribution |
---|
22 | dist=$( cat /etc/issue | grep "SUSE LINUX Enterprise Server 9" ) |
---|
23 | if [ "$dist" == "" ]; then |
---|
24 | die "$0 will work only for SUSE LINUX Enterprise Server 9" |
---|
25 | fi |
---|
26 | |
---|
27 | # Check the GPFS is not running |
---|
28 | gpfsIp=$(myGPFSIP) |
---|
29 | isRunning=$(mmfsadm dump version 2> /dev/null | grep "Current daemon version") |
---|
30 | if [ -n "$isRunning" ]; then |
---|
31 | echo "Error: GPFS has to be shutdown on $gpfsIp before uninstall can continue." |
---|
32 | return 1 |
---|
33 | fi |
---|
34 | |
---|
35 | echo -n "Removing GPFS system init script " |
---|
36 | if [ -f /etc/init.d/gpfs ]; then |
---|
37 | log insserv -d gpfs |
---|
38 | _unlink /etc/init.d/gpfs |
---|
39 | fi |
---|
40 | # Redo GPFS autoload in inittab |
---|
41 | sed -i 's/^# gpfs:\(.*\)# Disabled by HA-NFS/gpfs:\1/g' /etc/inittab |
---|
42 | rc_status -v |
---|
43 | |
---|
44 | # Reset default start mode of interfaces used for HA-NFS |
---|
45 | nfsIPs=$(getNfsIPs $gpfsIp) |
---|
46 | for ip in $nfsIPs; do |
---|
47 | # Find its ifcfg file |
---|
48 | ifcfg=$(getifcfg $ip) |
---|
49 | [ -z "$ifcfg" ] && continue |
---|
50 | iface=$(getifname $ifcfg) |
---|
51 | if grep -q "^STARTMODE.*='manual'" $ifcfg; then |
---|
52 | . $ifcfg |
---|
53 | for ipval in ${!IPADDR*}; do |
---|
54 | index=${ipval#IPADDR} |
---|
55 | ipaddr=${!ipval} |
---|
56 | if [ "$ip" == "$ipaddr" ]; then |
---|
57 | mode=STARTMODE$index |
---|
58 | break |
---|
59 | fi |
---|
60 | done |
---|
61 | # SuSE |
---|
62 | sed -i "s/^$mode='manual' # added for HA-NFS/$mode='onboot'/g" $ifcfg |
---|
63 | echo "Uninstallation has changed the start mode of interface $iface to onboot" |
---|
64 | elif grep -q "^ONBOOT=no" $ifcfg; then |
---|
65 | # RedHat |
---|
66 | sed -i "s/^ONBOOT=no # added for HA-NFS/^ONBOOT=yes/g" $ifcfg |
---|
67 | echo "Uninstallation has changed the start mode of interface $iface to onboot" |
---|
68 | fi |
---|
69 | done |
---|
70 | |
---|
71 | # Restore backup |
---|
72 | [ -d /var/mmfs/etc.bak ] && log rm -rf /var/mmfs/etc && log mv /var/mmfs/etc.bak /var/mmfs/etc |
---|
73 | |
---|
74 | # Reset files in /var/lib/nfs |
---|
75 | [ -L /var/lib/nfs/rmtab ] && _unlink /var/lib/nfs/rmtab && touch /var/lib/nfs/rmtab |
---|
76 | [ -L /var/lib/nfs/sm ] && _unlink /var/lib/nfs/sm && _mkdir /var/lib/nfs/sm |
---|
77 | [ -L /var/lib/nfs/sm.bak ] && _unlink /var/lib/nfs/sm.bak && _mkdir /var/lib/nfs/sm.bak |
---|
78 | rc_reset |
---|
79 | } |
---|
80 | |
---|
81 | defs=/var/mmfs/etc/nfsdefs |
---|
82 | funcs=/var/mmfs/etc/nfsfuncs |
---|
83 | uninstall_script=/var/mmfs/etc/uninstall_ha-nfs.sh |
---|
84 | |
---|
85 | prereq $defs $funcs $uninstall_script |
---|
86 | |
---|
87 | . $defs |
---|
88 | . $funcs |
---|
89 | . /etc/rc.status |
---|
90 | |
---|
91 | if [ -n "$GPFS_RSH" ]; then |
---|
92 | GPFS_rshPath=$(which $GPFS_RSH) |
---|
93 | else |
---|
94 | GPFS_rshPath=$(which rsh) |
---|
95 | fi |
---|
96 | if [ -n "$GPFS_RCP" ]; then |
---|
97 | GPFS_rcpPath=$(which $GPFS_RCP) |
---|
98 | else |
---|
99 | GPFS_rcpPath=$(which rcp) |
---|
100 | fi |
---|
101 | |
---|
102 | LOGFILE=/tmp/uninstall-ha-nfs.log |
---|
103 | > $LOGFILE |
---|
104 | |
---|
105 | allflag="" |
---|
106 | case $1 in |
---|
107 | -a) |
---|
108 | allflag=yes |
---|
109 | ;; |
---|
110 | -u) |
---|
111 | unconfig |
---|
112 | exit $? |
---|
113 | ;; |
---|
114 | *) |
---|
115 | ;; |
---|
116 | esac |
---|
117 | |
---|
118 | if [ -z "$allflag" ]; then |
---|
119 | unconfig |
---|
120 | else |
---|
121 | # Run configuration on all GPFS nodes |
---|
122 | gpfsIPs=$(getAllGPFSIPs) |
---|
123 | |
---|
124 | echo -n "Uninstalling HA-NFS on all nodes in the cluster " |
---|
125 | gpfsIPs=$(echo $gpfsIPs | sed 's/ /,/g') |
---|
126 | log mmdshcmdRC $gpfsIPs $uninstall_script -u |
---|
127 | if [ $? -ne 0 ]; then |
---|
128 | rc_failed 1 |
---|
129 | else |
---|
130 | rc_reset |
---|
131 | fi |
---|
132 | rc_status -v |
---|
133 | fi |
---|
134 | |
---|
135 | RC=$? |
---|
136 | grep "Error:" $LOGFILE |
---|
137 | [ -s $LOGFILE ] && echo -n "See $LOGFILE for details." |
---|
138 | echo "" |
---|
139 | exit $RC |
---|