File: shellfuncs.in

package info (click to toggle)
resource-agents 1%3A4.0.0~rc1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,644 kB
  • ctags: 2,191
  • sloc: sh: 47,713; ansic: 4,074; perl: 3,457; makefile: 663; xml: 89
file content (96 lines) | stat: -rw-r--r-- 2,049 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Author:       Alan Robertson
# Support:      linux-ha-dev@lists.tummy.com
# License:      GNU Lesser General Public License (LGPL)
#
#	Set these variables if they're not already set...
#

: ${HA_SBIN_DIR:=@sbindir@}
: ${HA_NOARCHBIN:=@datadir@/heartbeat}
: ${OCF_AGENTS:=@OCF_RA_DIR@/heartbeat/}

export HA_DIR HA_RCDIR HA_FIFO HA_BIN 
export HA_DEBUGLOG HA_LOGFILE HA_LOGFACILITY
export HA_DATEFMT HA_RESOURCEDIR HA_DOCDIR
export OCF_AGENTS

PATH=$HA_BIN:${HA_SBIN_DIR}:${HA_NOARCHBIN}:$PATH
PATH=`echo $PATH | sed -e 's%::%%' -e 's%:\.:%:%' -e 's%^:%%' -e 's%^\.:%%'`
export PATH

#	A suitable echo command
Echo() {
  echo "$@"
}

# copy stdin (text) to FIFO, with surrounding ">>>" and "<<<" marker lines.
# no args.; no result
# Notes:
#	o Using "cat -" rather than "cat" simply for clarity.
#	o The trailing "| cat -" tries to hold things together as a single
#	  write (which is probably preferable behaviour in this context).
ha_clustermsg() {
	(echo ">>>"; cat -; echo "<<<")	| cat - >> $HA_FIFO
}

ha_parameter() {
  VALUE=`sed -e 's%[ 	][ 	]*% %' -e 's%^ %%' -e 's%#.*%%'   $HA_CF |
  grep -i "^$1 " | sed 's%[^ ]* %%'`
  if
    [ "X$VALUE" = X ]
  then
    
    case $1 in
      keepalive)	VALUE=2;;
      deadtime)
			ka=`ha_parameter keepalive`
			VALUE=`expr $ka '*' 2 '+' 1`;;
    esac
  fi
  Echo $VALUE
}

BSD_Status() {
  local base=${1##*/}
  local pid

  ret_status=`/bin/ps -ao pid,command | grep $base | sed 's/ .*//'`

  if 
    [ "$ret_status" != "" ]
  then
    echo "${base} is running..."
  return 0
  fi

  if 
    [ -f $HA_VARRUN/${base}.pid ] 
  then
    echo "${base} dead but pid file exists"
    return 1
  fi

  if 
    [ -f /var/run/${base}.pid ] 
  then
    echo "${base} dead but pid file exists"
    return 1
  fi

  if 
    [ -f $HA_VARLOCK/${base}.pid ] 
  then
    echo "${base} dead but lock file exists"
    return 2
  fi

  if 
    [ -f /var/spool/lock/${base} ] 
  then
    echo "${base} dead but lock file exists"
    return 2
  fi
}

# Now get the good stuff
. @OCF_LIB_DIR@/heartbeat/ocf-shellfuncs