~ampelbein/ubuntu/oneiric/heartbeat/lp-770743

« back to all changes in this revision

Viewing changes to tools/ha_cf_support.sh

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2009-08-10 19:29:25 UTC
  • mfrom: (5.2.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090810192925-9zy2llcbgavbskf7
Tags: 2.99.2+sles11r9-5ubuntu1
* New upstream snapshot
* Adjusted heartbeat.install and rules for documentation path

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 # Copyright (C) 2007 Dejan Muhamedagic <dmuhamedagic@suse.de>
 
2
 # 
 
3
 # This program is free software; you can redistribute it and/or
 
4
 # modify it under the terms of the GNU General Public
 
5
 # License as published by the Free Software Foundation; either
 
6
 # version 2.1 of the License, or (at your option) any later version.
 
7
 # 
 
8
 # This software is distributed in the hope that it will be useful,
 
9
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 # General Public License for more details.
 
12
 # 
 
13
 # You should have received a copy of the GNU General Public
 
14
 # License along with this library; if not, write to the Free Software
 
15
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 #
 
17
 
 
18
# NB: This is not going to work unless you source /etc/ha.d/shellfuncs!
 
19
 
 
20
#
 
21
# Stack specific part (heartbeat)
 
22
# ha.cf/logd.cf parsing
 
23
#
 
24
getcfvar() {
 
25
        [ -f "$CONF" ] || return
 
26
        sed 's/#.*//' < $CONF |
 
27
                grep -w "^$1" |
 
28
                sed 's/^[^[:space:]]*[[:space:]]*//'
 
29
}
 
30
iscfvarset() {
 
31
        test "`getcfvar $1`"
 
32
}
 
33
iscfvartrue() {
 
34
        getcfvar "$1" |
 
35
                egrep -qsi "^(true|y|yes|on|1)"
 
36
}
 
37
uselogd() {
 
38
        iscfvartrue use_logd &&
 
39
                return 0  # if use_logd true
 
40
        iscfvarset logfacility ||
 
41
        iscfvarset logfile ||
 
42
        iscfvarset debugfile ||
 
43
                return 0  # or none of the log options set
 
44
        false
 
45
}
 
46
get_hb_logvars() {
 
47
        # unless logfacility is set to none, heartbeat/ha_logd are
 
48
        # going to log through syslog
 
49
        HA_LOGFACILITY=`getcfvar logfacility`
 
50
        [ "" = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=$DEFAULT_HA_LOGFACILITY
 
51
        [ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=""
 
52
        HA_LOGFILE=`getcfvar logfile`
 
53
        HA_DEBUGFILE=`getcfvar debugfile`
 
54
}
 
55
getlogvars() {
 
56
        HA_LOGFACILITY=${HA_LOGFACILITY:-$DEFAULT_HA_LOGFACILITY}
 
57
        HA_LOGLEVEL="info"
 
58
        cfdebug=`getcfvar debug` # prefer debug level if set
 
59
        isnumber $cfdebug || cfdebug=""
 
60
        [ "$cfdebug" ] && [ $cfdebug -gt 0 ] &&
 
61
                HA_LOGLEVEL="debug"
 
62
        if uselogd; then
 
63
                [ -f "$LOGD_CF" ] ||
 
64
                        return  # no configuration: use defaults
 
65
                get_logd_logvars
 
66
        else
 
67
                get_hb_logvars
 
68
        fi
 
69
}
 
70
cluster_info() {
 
71
        echo "heartbeat version: `$HA_BIN/heartbeat -V`"
 
72
}
 
73
essential_files() {
 
74
        cat<<EOF
 
75
d $HA_VARLIB 0755 root root
 
76
d $HA_VARLIB/ccm 0750 hacluster haclient
 
77
d $HA_VARLIB/pengine 0750 hacluster haclient
 
78
d $HA_VARLIB/crm 0750 hacluster haclient
 
79
EOF
 
80
}