source: gpfs_3.1_ker2.6.20/lpp/mmfs/samples/nfscluster/uninstall_ha-nfs.sh @ 148

Last change on this file since 148 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 3.5 KB
Line 
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)
7prereq() {
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
16unconfig() {
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
81defs=/var/mmfs/etc/nfsdefs
82funcs=/var/mmfs/etc/nfsfuncs
83uninstall_script=/var/mmfs/etc/uninstall_ha-nfs.sh
84
85prereq $defs $funcs $uninstall_script
86
87. $defs
88. $funcs
89. /etc/rc.status
90
91if [ -n "$GPFS_RSH" ]; then
92    GPFS_rshPath=$(which $GPFS_RSH)
93else
94    GPFS_rshPath=$(which rsh)
95fi
96if [ -n "$GPFS_RCP" ]; then
97    GPFS_rcpPath=$(which $GPFS_RCP)
98else
99    GPFS_rcpPath=$(which rcp)
100fi
101
102LOGFILE=/tmp/uninstall-ha-nfs.log
103> $LOGFILE
104
105allflag=""
106case $1 in
107    -a)
108        allflag=yes
109  ;;
110    -u)
111        unconfig
112        exit $?
113  ;;
114    *)
115  ;;
116esac
117 
118if [ -z "$allflag" ]; then
119    unconfig
120else
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
133fi
134
135RC=$?
136grep "Error:" $LOGFILE
137[ -s $LOGFILE ] && echo -n "See $LOGFILE for details."
138echo ""
139exit $RC
Note: See TracBrowser for help on using the repository browser.