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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#!/usr/bin/env bash
#--------------------------------------------------------------------
#
# make_signature
#
# Bash script building module of pgxc_ctl.
#
# Copyright (c) 2012 Postgres-XC Development Group
#
#---------------------------------------------------------------------
#
# This module is used to create signature.h and pgxc_ctl_bash.c files.
#
# pgxc_ctl_bash.c files contains two information,
# 1. Bash script to read pgxc_ctl configuration information and write
# it back to pgxc_ctl. This way, users can use their familiar bash
# script to configure postgres-xc cluster.
# This includes typical (test) configuration so that pgxc_ctl
# can run even with incomplete configuration.
# 2. Template postgres-xc cluster configuration used by pgxc_ctl.
# You can get this template by typing "prepare configu" command.
#
# signature.h contains signature information which is useful in
# checking the bash script and pgxc_ctl binary build.
#
# At present, the bash script is installed each time pgxc_ctl is invoked
# and uninstalled, this has no significant role. In the future,
# when we need to maintain this bash script, it will work to enforce
# the integrity between the two.
#------------------------------------------------------------------------
# make sure we fail if any of the executed commands fails
set -e
sig=`date +%y%m%d_%H%M_%N`
cat > signature.h <<EOF
/*-------------------------------------------------------------------------
*
* signature.h
*
* Signature of module of Postgres-XC configuration and operation tool.
*
* Copyright (c) 2013 Postgres-XC Development Group
*
*-------------------------------------------------------------------------
*/
#ifndef SIGNATURE_H
#define SIGNATURE_H
/* Signature file to identify the make */
EOF
echo '#'define signature \"$sig\" >> signature.h
cat >> signature.h <<EOF
#endif /* SIGNATURE_H */
EOF
sed -e 's/"/\\\"/g; s/^/"/; s/$/",/; s/^"#ifdef XCP",/#ifdef XCP/; s/^"#endif",/#endif/' pgxc_ctl_bash_2 > pgxc_ctl_bash.c.wk
cat > pgxc_ctl_bash.c <<EOF
/*
*-----------------------------------------------------------------------
*
* pgxc_ctl_bash.c
*
* Bash script body for Postrgres-XC configuration and operation tool.
*
* Copyright (c) 2013 Postgres-XC Development Group
*
*------------------------------------------------------------------------
*
* This file was created by make_signature utility when pgxc_ctl was built.
*
* pgxc_ctl uses this bash script to configure postgres-xc and read
* configuration.
*
* This provides users very flexible way to configure their own
* postgres-xc cluster. For example, by using extra variables and script,
* you can save most of your specific hours typing same (or similar)
* variable values again and again.
*/
#include <stddef.h>
/*
* Bash script to read pgxc_ctl configuration parameters and write
* back to itself.
*
* This part is written to pgxc_ctl work directory and reads
* configuration file, which is also written in bash script.
*/
char *pgxc_ctl_bash_script[] = {
EOF
cat pgxc_ctl_bash.c.wk >> pgxc_ctl_bash.c
cat >> pgxc_ctl_bash.c <<EOF
NULL
};
EOF
rm pgxc_ctl_bash.c.wk
sed -e 's/"/\\\"/g; s/^/"/; s/$/",/; s/^"#ifdef XCP",/#ifdef XCP/; s/^"#endif",/#endif/' pgxc_ctl_conf_part_full > pgxc_ctl_conf_part.wk
cat >> pgxc_ctl_bash.c <<EOF
/*
* Prototype of pgxc_ctl configuration file.
*
* It should be self descripting. Can be extracted to your pgxc_ctl
* work directory with 'prepare config' command.
*/
char *pgxc_ctl_conf_prototype[] = {
EOF
cat pgxc_ctl_conf_part.wk >> pgxc_ctl_bash.c
cat >> pgxc_ctl_bash.c <<EOF
NULL
};
EOF
rm pgxc_ctl_conf_part.wk
sed -e 's/"/\\\"/g; s/^/"/; s/$/",/; s/^"#ifdef XCP",/#ifdef XCP/; s/^"#endif",/#endif/' pgxc_ctl_conf_part_minimal > pgxc_ctl_conf_part.wk
cat >> pgxc_ctl_bash.c <<EOF
/*
* Prototype of pgxc_ctl configuration file.
*
* It should be self descripting. Can be extracted to your pgxc_ctl
* work directory with 'prepare config' command.
*/
char *pgxc_ctl_conf_prototype_minimal[] = {
EOF
cat pgxc_ctl_conf_part.wk >> pgxc_ctl_bash.c
cat >> pgxc_ctl_bash.c <<EOF
NULL
};
EOF
rm pgxc_ctl_conf_part.wk
sed -e 's/"/\\\"/g; s/^/"/; s/$/",/; s/^"#ifdef XCP",/#ifdef XCP/; s/^"#endif",/#endif/' pgxc_ctl_conf_part_empty > pgxc_ctl_conf_empty.wk
cat >> pgxc_ctl_bash.c <<EOF
/*
* Prototype of pgxc_ctl configuration file.
*
* It should be self descripting. Can be extracted to your pgxc_ctl
* work directory with 'prepare empty' command.
*/
char *pgxc_ctl_conf_prototype_empty[] = {
EOF
cat pgxc_ctl_conf_empty.wk >> pgxc_ctl_bash.c
cat >> pgxc_ctl_bash.c <<EOF
NULL
};
EOF
rm pgxc_ctl_conf_empty.wk
|