File: pgsqlms

package info (click to toggle)
resource-agents-paf 2.2.1-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster
  • size: 340 kB
  • sloc: perl: 1,811; sh: 208; makefile: 27
file content (123 lines) | stat: -rw-r--r-- 2,835 bytes parent folder | download | duplicates (2)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#: {PGBIN=/usr/lib/postgresql/9.3/bin}
CONFIG
    Agent pgsqlms
    AgentRoot /usr/lib/ocf/resource.d/heartbeat
    HangTimeout 120

VARIABLE
    PGDATA=${PGDATA=/tmp/pgdata1}
    PGBIN=${PGBIN=/usr/pgsql-9.3/bin}
    PGHOST=${PGHOST=/tmp}
    RESOURCE_NAME=${RESOURCE_NAME=pgsqld}
    NODENAME=$(uname -n)

CASE-BLOCK cleanup
    sudo -iu postgres "$PGBIN"/pg_ctl -D "$PGDATA" -w -m immediate stop  &> /dev/null
    rm -rf ${PGDATA:?}

SETUP-AGENT
    Include cleanup
    echo "PGBIN: $PGBIN" >&2
    sudo -iu postgres mkdir -p "$PGDATA"
    sudo -iu postgres "$PGBIN"/initdb --nosync -D "$PGDATA" &> /dev/null 
    cat <<-EOC>> "$PGDATA"/postgresql.conf
	listen_addresses = '*'
	wal_level = hot_standby
	max_wal_senders = 5
	hot_standby = on
	hot_standby_feedback = on
	wal_receiver_status_interval = 20s
	EOC

    cat <<-EOC > "$PGDATA"/recovery.conf.pcmk
	standby_mode = 'on'
	# Fake master conninfo!
	primary_conninfo = 'user=postgres host=127.0.0.1 port=15432 application_name=$NODENAME'
	recovery_target_timeline = 'latest'
	EOC

    cat <<-EOC>> "$PGDATA"/pg_hba.conf
	host replication postgres 0.0.0.0/0 trust
	EOC

    sudo -iu postgres "$PGBIN"/pg_ctl -D "$PGDATA" -w start &> /dev/null
    sudo -iu postgres "$PGBIN"/pg_ctl -D "$PGDATA" -w -m fast stop &> /dev/null

CLEANUP-AGENT
    Include cleanup

CASE-BLOCK required_args
    Env OCF_RESKEY_bindir=$PGBIN
    Env OCF_RESKEY_pgdata=$PGDATA
    Env OCF_RESKEY_pghost=$PGHOST
    Env OCF_RESOURCE_INSTANCE=$RESOURCE_NAME

CASE-BLOCK prepare
    Include required_args
    AgentRun stop

CASE "check validate-all"
    Include prepare
    AgentRun validate-all OCF_SUCCESS

CASE "check stopped monitor"
    Include prepare
    AgentRun monitor OCF_NOT_RUNNING

CASE "check start"
    Include prepare
    AgentRun start OCF_SUCCESS

CASE "check double start"
    Include prepare
    AgentRun start
    AgentRun start OCF_SUCCESS

CASE "check stop"
    Include prepare
    AgentRun start
    AgentRun stop OCF_SUCCESS

CASE "check double stop"
    Include prepare
    AgentRun start
    AgentRun stop
    AgentRun stop OCF_SUCCESS

CASE "check slave monitor"
    Include prepare
    AgentRun start
    AgentRun monitor OCF_SUCCESS

CASE "check promote"
    Include prepare
    AgentRun start
    AgentRun promote OCF_SUCCESS

CASE "check double promote"
    Include prepare
    AgentRun start
    AgentRun promote
    AgentRun promote OCF_SUCCESS

CASE "check master monitor"
    Include prepare
    AgentRun start
    AgentRun promote
    AgentRun monitor OCF_RUNNING_MASTER

CASE "check demote"
    Include prepare
    AgentRun start
    AgentRun promote
    AgentRun demote
    AgentRun monitor OCF_SUCCESS
    
CASE "check double demote"
    Include prepare
    AgentRun start
    AgentRun promote
    AgentRun demote
    AgentRun demote
    AgentRun monitor OCF_SUCCESS