-
Notifications
You must be signed in to change notification settings - Fork 6
/
make_package.sh
executable file
·149 lines (115 loc) · 3.51 KB
/
make_package.sh
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
#!/bin/sh
# ---------------------------------------------------------------------
# configuration
# ---------------------------------------------------------------------
CENTOS_VERSION_ARR=(6)
ARCHITECTURE_ARR=(x86_64)
MAJOR_VERSION=3.4
P_VERSION=3.4.2
P_RELEASE=1
P_RPM_VERSION=${P_VERSION}-${P_RELEASE}
A_VERSION=3.4.1
A_RELEASE=2
A_RPM_VERSION=${A_VERSION}-${A_RELEASE}
PG_MAJOR_VERSION_ARR=(9.3 9.4)
FILES_ARR=(
COPYING
README.md
install.sh
installer.conf.sample
lib/
templates/
uninstall.sh
)
# ---------------------------------------------------------------------
# function
# ---------------------------------------------------------------------
function package()
{
local _CENTOS_VERSION=$1
local _ARCHITECTURE=$2
local _PG_MAJOR_VERSION=$3
local _PG_MAJOR_VERSION_WO_DOT=${_PG_MAJOR_VERSION/./}
local _BASE_URL="http://www.pgpool.net/yum/rpms/${MAJOR_VERSION}/redhat/rhel-${_CENTOS_VERSION}-${_ARCHITECTURE}"
local _PGPOOL_PG=pgpool-II-pg${_PG_MAJOR_VERSION_WO_DOT}
local _INSTALLER_DIR="installer2-pg${_PG_MAJOR_VERSION_WO_DOT}-${P_VERSION}_rhel-${CENTOS_VERSION}-${ARCHITECTURE}"
echo
echo "================================================================================"
echo "CentOS ${_CENTOS_VERSION} (${_ARCHITECTURE}) / PostgreSQL ${_PG_MAJOR_VERSION}"
echo "================================================================================"
echo
mkdir ${_INSTALLER_DIR}
cd ${_INSTALLER_DIR}
echo
echo "----"
echo "put files"
echo "----"
echo
for _FILE in ${FILES_ARR[@]}; do
echo "- ${_FILE}"
cp -rf ../../${_FILE} .
done
case ${MAJOR_VERSION} in
3.4 )
cp ../pgpool-II-${P_VERSION}/src/sample/pgpool.conf.sample templates/
;;
* )
cp ../pgpool-II-${P_VERSION}/pgpool.conf.sample templates/
;;
esac
echo
echo "----"
echo "download RPM"
echo "----"
echo
wget ${_BASE_URL}/${_PGPOOL_PG}-${P_RPM_VERSION}pgdg.rhel${_CENTOS_VERSION}.${_ARCHITECTURE}.rpm
wget ${_BASE_URL}/${_PGPOOL_PG}-extensions-${P_RPM_VERSION}pgdg.rhel${_CENTOS_VERSION}.${_ARCHITECTURE}.rpm
wget ${_BASE_URL}/pgpoolAdmin-${A_RPM_VERSION}pgdg.rhel${_CENTOS_VERSION}.noarch.rpm
echo
echo
echo "----"
echo "create lib/version.sh "
echo "----"
echo
# scripts
cat > lib/version.sh <<EOT
#!/bin/sh
# CentOS
CENTOS_VERSION=${_CENTOS_VERSION}
# PostgreSQL
PG_MAJOR_VERSION=${PG_MAJOR_VERSION}
# pgpool-II
MAJOR_VERSION=${MAJOR_VERSION}
P_VERSION=${P_VERSION}
P_RELEASE=${P_RELEASE}
# pgpoolAdmin
A_VERSION=${A_VERSION}
A_RELEASE=${A_RELEASE}
EOT
cat lib/version.sh
# ---------------------------------------------------------------------
# tar cfz
# ---------------------------------------------------------------------
cd ../
tar cfz ${_INSTALLER_DIR}.tar.gz ${_INSTALLER_DIR}
echo
}
# ---------------------------------------------------------------------
# body
# ---------------------------------------------------------------------
rm -rf work
mkdir work
cd work
TAR="pgpool-II-${P_VERSION}.tar.gz"
wget http://www.pgpool.net/download.php?f=${TAR} -O ${TAR}
tar xfz ${TAR}
rm ${TAR}
for CENTOS_VERSION in ${CENTOS_VERSION_ARR[@]}; do
for ARCHITECTURE in ${ARCHITECTURE_ARR[@]}; do
for PG_MAJOR_VERSION in ${PG_MAJOR_VERSION_ARR[@]}; do
package ${CENTOS_VERSION} ${ARCHITECTURE} ${PG_MAJOR_VERSION}
done
done
done
rm -rf pgpool-II-${P_VERSION}
ls *.tar.gz