~ubuntu-branches/ubuntu/vivid/ctdb/vivid-proposed

« back to all changes in this revision

Viewing changes to config/events.d/60.nfs

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Parent
  • Date: 2008-04-26 15:21:27 UTC
  • Revision ID: james.westby@ubuntu.com-20080426152127-58mv5ojv5q362ise
Tags: upstream-1.0.34+git200804242206
ImportĀ upstreamĀ versionĀ 1.0.34+git200804242206

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# script to manage nfs in a clustered environment
 
3
 
 
4
. $CTDB_BASE/functions
 
5
loadconfig nfs
 
6
 
 
7
[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
 
8
[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
 
9
 
 
10
cmd="$1"
 
11
shift
 
12
 
 
13
PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
 
14
 
 
15
 
 
16
 
 
17
case $cmd in 
 
18
     startup)
 
19
        /bin/mkdir -p $CTDB_BASE/state/nfs
 
20
        /bin/mkdir -p $CTDB_BASE/state/statd/ip
 
21
        /bin/mkdir -p $STATD_SHARED_DIRECTORY
 
22
 
 
23
        /bin/rm -f $CTDB_BASE/state/statd/statd.restart >/dev/null 2>/dev/null
 
24
 
 
25
        # make sure nfs is stopped before we start it, or it may get a bind error
 
26
        startstop_nfs stop
 
27
        startstop_nfs start
 
28
        ;;
 
29
 
 
30
     shutdown)
 
31
        startstop_nfs stop
 
32
        exit 0
 
33
        ;;
 
34
 
 
35
     takeip)
 
36
        ip=$2
 
37
 
 
38
        echo $ip >> $CTDB_BASE/state/statd/restart
 
39
 
 
40
        # having a list of what IPs we have allows statd to do the right 
 
41
        # thing via $CTDB_BASE/statd-callout
 
42
        touch $CTDB_BASE/state/statd/ip/$ip
 
43
        exit 0
 
44
        ;;
 
45
 
 
46
     releaseip)
 
47
        iface=$1
 
48
        ip=$2
 
49
        maskbits=$3
 
50
 
 
51
        echo $ip >> $CTDB_BASE/state/statd/restart
 
52
        /bin/rm -f $CTDB_BASE/state/statd/ip/$ip
 
53
        exit 0
 
54
        ;;
 
55
 
 
56
     recovered)
 
57
        # if no IPs have changed then don't need to restart statd 
 
58
        [ -f $CTDB_BASE/state/statd/restart ] || exit 0;
 
59
 
 
60
        # always restart the lockmanager so that we start with a clusterwide
 
61
        # graceperiod when ip addresses has changed
 
62
        [ -x $CTDB_BASE/statd-callout ] && {
 
63
                $CTDB_BASE/statd-callout notify &
 
64
        } >/dev/null 2>&1
 
65
 
 
66
        /bin/rm -f $CTDB_BASE/state/statd/restart
 
67
        ;;
 
68
 
 
69
      monitor)
 
70
        # check that statd responds to rpc requests
 
71
        # if statd is not running we try to restart it once and wait
 
72
        # for the next monitoring event to verify if it is running or not
 
73
        # if it still fails we fail and mark the node as UNHEALTHY
 
74
        if [ -f $CTDB_BASE/state/statd/statd.restart ]; then
 
75
                # statd was restarted, see if it came up ok
 
76
                rpcinfo -u localhost 100024 1 > /dev/null || {
 
77
                        echo "ERROR: Failed to restart STATD"
 
78
                        exit 1
 
79
                }
 
80
                echo "STATD successfully restarted."
 
81
                /bin/rm -f $CTDB_BASE/state/statd/statd.restart
 
82
        else
 
83
                rpcinfo -u localhost 100024 1 > /dev/null || {
 
84
                        RPCSTATDOPTS=""
 
85
                        [ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
 
86
                        [ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
 
87
                        [ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
 
88
                        rpc.statd $RPCSTATDOPTS 
 
89
                        echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
 
90
                        touch $CTDB_BASE/state/statd/statd.restart
 
91
                }
 
92
        fi
 
93
 
 
94
 
 
95
        # check that NFS responds to rpc requests
 
96
        ctdb_check_rpc "NFS" 100003 3
 
97
 
 
98
        # and that its directories are available
 
99
        nfs_dirs=$(grep -v '^#' < /etc/exports | awk {'print $1;'})
 
100
        ctdb_check_directories "nfs" $nfs_dirs
 
101
 
 
102
        # check that lockd responds to rpc requests
 
103
        ctdb_check_rpc "lockd" 100021 1
 
104
        ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
 
105
 
 
106
        # mount needs special handling since it is sometimes not started
 
107
        # correctly on RHEL5
 
108
        rpcinfo -u localhost 100005 1 > /dev/null || {
 
109
                echo "ERROR: MOUNTD is not running. Trying to restart it."
 
110
                RPCMOUNTDOPTS=""
 
111
                [ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
 
112
                killall -q -9 rpc.mountd
 
113
                rpc.mountd $RPCMOUNTDOPTS &
 
114
                exit 1
 
115
        }
 
116
        ;;
 
117
 
 
118
esac
 
119
 
 
120
exit 0