18
18
# NB: This is not going to work unless you source /etc/ha.d/shellfuncs!
21
# ha.cf/logd.cf parsing
24
[ -f "$HA_CF" ] || return
25
sed 's/#.*//' < $HA_CF |
21
# figure out the cluster type, depending on the process list
22
# and existence of configuration files
25
if ps -ef | grep -qs '[a]isexec' ||
26
[ -f /etc/ais/openais.conf -a ! -f "$HA_CF" ]
34
# find out which membership tool is installed
36
echo_membership_tool() {
37
membership_tools="ccm_tool crm_node"
38
for f in $membership_tools; do
39
which $f 2>/dev/null && break
43
# find nodes for this cluster
47
if [ "$USER_NODES" ]; then
50
elif iscrmrunning; then
53
elif [ -f $HA_VARLIB/hostcache ]; then
54
awk '{print $1}' $HA_VARLIB/hostcache
56
elif [ "$CLUSTER_TYPE" = heartbeat ]; then
62
sed 's/#.*//' < $LOGD_CF |
27
64
sed 's/^[^[:space:]]*[[:space:]]*//'
30
test "`getcfvar \"$1\"`"
34
egrep -qsi "^(true|y|yes|on|1)"
67
# unless logfacility is set to none, heartbeat/ha_logd are
68
# going to log through syslog
69
HA_LOGFACILITY=`logd_getcfvar logfacility`
70
[ "" = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=$DEFAULT_HA_LOGFACILITY
71
[ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=""
72
HA_LOGFILE=`logd_getcfvar logfile`
73
HA_DEBUGFILE=`logd_getcfvar debugfile`
77
`which strings > /dev/null 2>&1 &&
78
strings $HA_BIN/ha_logd | grep 'logd\.cf'` \
79
`for d; do echo $d/logd.cf $d/ha_logd.cf; done`
52
100
# find log destination
55
iscfvartrue use_logd &&
56
return 0 # if use_logd true
57
iscfvarset logfacility ||
59
iscfvarset debugfile ||
60
return 0 # or none of the log options set
65
`which strings > /dev/null 2>&1 &&
66
strings $HA_BIN/ha_logd | grep 'logd\.cf'` \
67
`for d; do echo $d/logd.cf $d/ha_logd.cf; done`
77
HA_LOGFACILITY=${HA_LOGFACILITY:-$DEFAULT_HA_LOGFACILITY}
80
return # no configuration: use defaults
84
# unless logfacility is set to none, heartbeat/ha_logd are
85
# going to log through syslog
86
HA_LOGFACILITY=`getcfvar logfacility`
87
[ "" = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=$DEFAULT_HA_LOGFACILITY
88
[ none = "$HA_LOGFACILITY" ] && HA_LOGFACILITY=""
89
HA_LOGFILE=`getcfvar logfile`
90
HA_DEBUGFILE=`getcfvar debugfile`
94
103
# this is tricky, we try a few directories
95
104
syslogdir="/var/log /var/logs /var/syslog /var/adm /var/log/ha /var/log/cluster"
220
232
trap find_files_clean 0
221
233
if ! from_stamp=`touchfile $from_time`; then
222
warning "sorry, can't create temoary file for find_files"
234
warning "sorry, can't create temporary file for find_files"
225
237
findexp="-newer $from_stamp"
226
238
if isnumber "$to_time" && [ "$to_time" -gt 0 ]; then
227
239
if ! to_stamp=`touchfile $to_time`; then
228
warning "sorry, can't create temoary file for" \
240
warning "sorry, can't create temporary file for" \
233
245
findexp="$findexp ! -newer $to_stamp"
235
find $dir -type f $findexp
247
find $dirs -type f $findexp
253
# check permissions of files/dirs
257
# check permissions and ownership
258
# uid and gid are numeric
259
# everything must match exactly
260
# no error checking! (file should exist, etc)
261
($filename, $perms, $in_uid, $in_gid) = @ARGV;
262
($mode,$uid,$gid) = (stat($filename))[2,4,5];
263
$p=sprintf("%04o", $mode & 07777);
264
$p ne $perms and exit(1);
265
$uid ne $in_uid and exit(1);
266
$gid ne $in_gid and exit(1);
270
getent $1 $2 | awk -F: '{print $3}'
274
echo "$1: id not found"
279
while read type f p uid gid; do
281
echo "$f wrong type or doesn't exist"
284
n_uid=`num_id passwd $uid`
285
chk_id "$uid" "$n_uid" || continue
286
n_gid=`num_id group $gid`
287
chk_id "$gid" "$n_gid" || continue
288
pl_checkperms $f $p $n_uid $n_gid || {
289
echo "wrong permissions or ownership for $f:"
245
300
binary=`gdb $random_binary $1 < /dev/null 2>/dev/null |
246
301
grep 'Core was generated' | awk '{print $5}' |
247
302
sed "s/^.//;s/[.':]*$//"`
303
if [ x = x"$binary" ]; then
304
binary=$(file $1 | awk '/from/{
305
for( i=1; i<=NF; i++ )
311
binary=`echo $binary | tr -d "'"`
312
binary=$(echo $binary | tr -d '`')
313
if [ "$binary" ]; then
314
binary=`which $binary 2>/dev/null`
248
317
[ x = x"$binary" ] && return
249
318
fullpath=`which $binary 2>/dev/null`
250
319
if [ x = x"$fullpath" ]; then
273
342
# heartbeat configuration/status
276
crmadmin -D >/dev/null 2>&1 &
345
ps -ef | grep -qs [c]rmd || return 1
346
#crmadmin -D >/dev/null 2>&1 &
347
crm_mon -1 >/dev/null 2>&1 &
279
350
while kill -0 $pid 2>/dev/null && [ $maxwait -gt 0 ]; do
304
375
cp -p $HA_VARLIB/crm/$CIB_F $1/ 2>/dev/null
307
cp -p $HA_VARLIB/hostcache $1/ 2>/dev/null
379
cp -p $HA_VARLIB/hostcache $1/$HOSTCACHE 2>/dev/null
381
crm_uuid -r > $1/$HB_UUID_F 2>&1
308
382
[ -f "$1/$CIB_F" ] &&
309
383
crm_verify -V -x $1/$CIB_F >$1/$CRM_VERIFY_F 2>&1
384
[ -f "$1/$CIB_F" ] && which crm >/dev/null 2>&1 &&
385
CIB_file=$1/$CIB_F crm configure show >$1/$CIB_TXT_F 2>&1
389
cibadmin -Ql -o nodes |
392
for( i=1; i<=NF; i++ )
394
sub("uname=.","",$i);
410
warning "no lsb_release no /etc/*-release no /etc/debian_version"
501
warning "no lsb_release, no /etc/*-release, no /etc/debian_version: no distro information"
413
504
# for Linux .deb based systems
414
which dpkg > /dev/null 2>&1 && {
415
for pkg in heartbeat heartbeat-2; do
416
dpkg-query -f '${Version}' -W $pkg 2>/dev/null && break
419
debsums -s $pkg 2>/dev/null
422
# for Linux .rpm based systems
423
which rpm > /dev/null 2>&1 && {
424
rpm -q --qf '%{version}-%{release}' heartbeat &&
426
rpm --verify heartbeat
430
which pkg_info > /dev/null 2>&1 && {
431
pkg_info | grep heartbeat | cut -d "-" -f 2- | cut -d " " -f 1
435
which pkginfo > /dev/null 2>&1 && {
436
pkginfo | awk '{print $3}'
506
which dpkg > /dev/null 2>&1 && {
507
dpkg-query -f '${Name} ${Version}' -W $pkg 2>/dev/null && break
509
debsums -s $pkg 2>/dev/null
512
# for Linux .rpm based systems
513
which rpm > /dev/null 2>&1 && {
514
rpm -q --qf '%{name} %{version}-%{release}' $pkg &&
520
which pkg_info > /dev/null 2>&1 && {
525
which pkginfo > /dev/null 2>&1 && {
526
pkginfo | awk '{print $3}' # format?
441
532
$HA_BIN/crmd version 2>&1