-
Notifications
You must be signed in to change notification settings - Fork 1
/
cudos-noded.spec
279 lines (236 loc) · 10.7 KB
/
cudos-noded.spec
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#
# Copyright 2022 Andrew Meredith <[email protected]>
# Copyright 2022 Cudo Ventures - All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Runs the Cudos Node Daemon
#
Name: cudos-noded
Version: %{_versiontag}
Release: %{_releasetag}%{?dist}
Summary: Cosmovisor Node Client Files - cudos
License: GPL3
URL: https://github.com/CudoVentures/cudos-node
Source1: etc_default_cosmovisor-cudos
Source3: etc_default_cudos-noded
Source4: etc_profiled_cudos-noded.sh
Source5: cudos-init-node.sh
Source6: cudos-noded-ctl.sh
Source7: cudos-is-node-ready.sh
Source8: docker-migrate.sh
Source9: icn-park-node.sh
Source10: icn-switch-nodes.sh
Source40: check_cudos_block_age.sh
Source41: check_cudos_block_data.sh
Source42: check_cudos_catching_up.sh
Source43: check_cudos_block_age_docker.sh
Source44: check_cudos_block_data_docker.sh
Source45: check_cudos_catching_up_docker.sh
Source46: check_cudos_consensus.sh
Source47: check_cudos_p2p
Source51: env.sh-tmpl
Source52: config.yml-tmpl
Source53: chronocollector-init.sh
Source54: chronocollector-linux-amd64.gz
Source55: cudos-chronocollector.service
Requires: cosmovisor
%description
Cosmovisor client files for - cudos
%pre
if getent group cudos >/dev/null
then
echo " Group cudos OK"
else
echo " Create Group cudos"
groupadd -r cudos
fi
if getent passwd cudos >/dev/null
then
echo " User cudos OK"
else
echo " Create User cudos"
useradd -c "Cudos User" -g cudos -s /bin/bash -r -m -d /var/lib/cudos cudos
fi
%package -n cudos-gex
Summary: Gex - Cosmos Node Monitor App
%description -n cudos-gex
Gex console app
%package -n cudos-p2p-scan
Summary: cudos-p2p-scan
Requires: jq
%description -n cudos-p2p-scan
Stand alone probe for examining PEX ports
%package -n cudos-monitoring
Summary: Cudos Node Monitoring Agents
Requires: bc jq cudos-p2p-scan
%description -n cudos-monitoring
CheckMK and ChronoSphere monitoring agents for Cudos Nodes
%pre -n cudos-monitoring
getent group chronoc >/dev/null || echo " Create Group chronoc" || groupadd -r chronoc || :
getent passwd chronoc >/dev/null || echo " Create User chronoc" || useradd -c "Cudos User" -g chronoc -s /bin/bash -r -m -d /var/lib/chronoc chronoc 2> /dev/null || :
%package -n cudos-monitoring-docker
Summary: Cudos Node Monitoring Agents
Requires: bc jq cudos-p2p-scan
%description -n cudos-monitoring-docker
CheckMK and ChronoSphere monitoring agents for Cudos Nodes Using the Docker containers
%pre -n cudos-monitoring-docker
getent group chronoc >/dev/null || groupadd -r chronoc || :
getent passwd chronoc >/dev/null || useradd -c "Cudos User" -g chronoc -s /bin/bash -r -m -d /var/lib/chronoc chronoc 2> /dev/null || :
%prep
echo -e "\n\n=== prep section ===\n\n"
%build
echo -e "\n\n=== build section ===\n\n"
export GOPATH="${RPM_BUILD_DIR}/go"
echo -e "\n\n=== Build and install gex ===\n\n"
go install -v github.com/cosmos/gex@latest
echo -e "\n\n=== Build and install cudos-p2p-scan ===\n\n"
go install -v github.com/CudoVentures/cudos-p2p-scan@latest
%install
echo -e "\n\n=== install section ===\n\n"
# Make the fixed directory structure
mkdir -p ${RPM_BUILD_ROOT}/var/lib/cudos/cudos-data/config
mkdir -p ${RPM_BUILD_ROOT}/var/lib/cudos/cudos-data/cosmovisor
mkdir -p ${RPM_BUILD_ROOT}/etc/default/
mkdir -p ${RPM_BUILD_ROOT}/etc/profile.d/
mkdir -p ${RPM_BUILD_ROOT}/usr/bin/
mkdir -p ${RPM_BUILD_ROOT}/usr/lib/systemd/system
mkdir -p ${RPM_BUILD_ROOT}/lib
mkdir -p ${RPM_BUILD_ROOT}/lib64
mkdir -p ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local
mkdir -p ${RPM_BUILD_ROOT}/var/lib/chronoc/bin
mkdir -p ${RPM_BUILD_ROOT}/usr/lib64/nagios/plugins/
# Install the newly built binaries
cp -v ${RPM_BUILD_DIR}/go/bin/gex ${RPM_BUILD_ROOT}/usr/bin/cosmos-gex
ln -s cosmos-gex ${RPM_BUILD_ROOT}/usr/bin/cudos-gex
cp -v ${RPM_BUILD_DIR}/go/bin/cudos-p2p-scan ${RPM_BUILD_ROOT}/usr/bin/cosmos-p2p-scan
ln -s cosmos-p2p-scan ${RPM_BUILD_ROOT}/usr/bin/cudos-p2p-scan
# Install scripts
cp ${RPM_SOURCE_DIR}/cudos-init-node.sh ${RPM_BUILD_ROOT}/usr/bin/
cp ${RPM_SOURCE_DIR}/cudos-is-node-ready.sh ${RPM_BUILD_ROOT}/usr/bin/
chmod 755 ${RPM_BUILD_ROOT}/usr/bin/*
# Install the files for /usr/lib64/nagios/plugins/
cp ${RPM_SOURCE_DIR}/check_cudos_p2p ${RPM_BUILD_ROOT}/usr/lib64/nagios/plugins/
chmod 755 ${RPM_BUILD_ROOT}/usr/lib64/nagios/plugins/*
# Install environment setup files
# NB The name change to a cosmovisor is deliberate
# It ensures only one of the client packages can be installed at any one time
#
cp ${RPM_SOURCE_DIR}/etc_default_cosmovisor-cudos ${RPM_BUILD_ROOT}/etc/default/cosmovisor@cudos
cp ${RPM_SOURCE_DIR}/etc_default_cudos-noded ${RPM_BUILD_ROOT}/etc/default/cudos-noded
cp ${RPM_SOURCE_DIR}/etc_profiled_cudos-noded.sh ${RPM_BUILD_ROOT}/etc/profile.d/cudos-noded.sh
# Install systemd service files
cp ${RPM_SOURCE_DIR}/cudos-chronocollector.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/
# Install /usr/bin scripts
cp ${RPM_SOURCE_DIR}/cudos-noded-ctl.sh ${RPM_BUILD_ROOT}/usr/bin/cudos-noded-ctl
chmod 755 ${RPM_BUILD_ROOT}/usr/bin/cudos-noded-ctl
cp ${RPM_SOURCE_DIR}/docker-migrate.sh ${RPM_BUILD_ROOT}/usr/bin/docker-migrate
chmod 755 ${RPM_BUILD_ROOT}/usr/bin/docker-migrate
cp ${RPM_SOURCE_DIR}/icn-park-node.sh ${RPM_BUILD_ROOT}/usr/bin/icn-park-node
chmod 755 ${RPM_BUILD_ROOT}/usr/bin/icn-park-node
cp ${RPM_SOURCE_DIR}/icn-switch-nodes.sh ${RPM_BUILD_ROOT}/usr/bin/icn-switch-nodes
chmod 755 ${RPM_BUILD_ROOT}/usr/bin/icn-switch-nodes
# Install chronocollector files
cp ${RPM_SOURCE_DIR}/chronocollector-linux-amd64.gz ${RPM_BUILD_ROOT}/var/lib/chronoc/bin
gunzip ${RPM_BUILD_ROOT}/var/lib/chronoc/bin/chronocollector-linux-amd64.gz
cp ${RPM_SOURCE_DIR}/chronocollector-init.sh ${RPM_BUILD_ROOT}/var/lib/chronoc/bin
cp ${RPM_SOURCE_DIR}/config.yml-tmpl ${RPM_BUILD_ROOT}/var/lib/chronoc/
cp ${RPM_SOURCE_DIR}/env.sh-tmpl ${RPM_BUILD_ROOT}/var/lib/chronoc/
chmod 755 ${RPM_BUILD_ROOT}/var/lib/chronoc/bin/*
chmod 755 ${RPM_BUILD_ROOT}/var/lib/chronoc/env.sh-tmpl
# Install check_mk files
cp ${RPM_SOURCE_DIR}/check_cudos_block_age.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_block_data.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_catching_up.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_block_age_docker.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_block_data_docker.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_catching_up_docker.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
cp ${RPM_SOURCE_DIR}/check_cudos_consensus.sh ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/
chmod 755 ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/*
# This script is only needed when there's a chain halt .. so make it 444 until needed
chmod 444 ${RPM_BUILD_ROOT}/usr/lib/check_mk_agent/local/check_cudos_consensus.sh
%clean
rm -rf $RPM_BUILD_ROOT
%post
if [ $1 = "1" ]
then
echo " Install: Setting up links"
else
echo " Upgrade: Setting up links"
fi
echo " Refreshing /usr/bin, /lib and /lib64 links"
rm -f /usr/bin/cudos-noded /lib64/libwasmvm.so /lib/libwasmvm.so || true
ln -s /var/lib/cudos/cudos-data/cosmovisor/current/bin/cudos-noded /usr/bin/cudos-noded
ln -s /var/lib/cudos/cudos-data/cosmovisor/current/lib/libwasmvm.so /lib64/libwasmvm.so
ln -s /var/lib/cudos/cudos-data/cosmovisor/current/lib/libwasmvm.so /lib/libwasmvm.so
if [ -d /var/lib/cudos/.cudosd/. ]
then
echo " Cosmovisor '.cudosd' to'cudos-data' link in place already"
else
echo " Setting Cosmovisor link '.cudosd' to 'cudos-data'"
ln -s /var/lib/cudos/cudos-data /var/lib/cudos/.cudosd
fi
if [ -d /var/lib/cudos/cudos-data/cosmovisor/current ]
then
echo " Cosmovisor 'current' link in place already"
else
echo " Setting Cosmovisor 'current' link to genesis"
ln -s /var/lib/cudos/cudos-data/cosmovisor/genesis /var/lib/cudos/cudos-data/cosmovisor/current
fi
echo " Chowning the home dir"
chown -R cudos:cudos /var/lib/cudos
# find /var/lib/cudos -ls
echo " Reloading systemd config"
systemctl daemon-reload
echo " Done"
%files
%defattr(-,root,root,-)
%config(noreplace) /etc/default/cosmovisor@cudos
%config(noreplace) /etc/default/cudos-noded
%config(noreplace) /etc/profile.d/cudos-noded.sh
/usr/bin/cudos-noded-ctl
/usr/bin/docker-migrate
/usr/bin/icn-park-node
/usr/bin/icn-switch-nodes
/usr/bin/cudos-init-node.sh
%defattr(-,cudos,cudos,-)
%dir /var/lib/cudos/cudos-data/cosmovisor
%doc
%files -n cudos-gex
%defattr(-,root,root,-)
/usr/bin/cosmos-gex
/usr/bin/cudos-gex
%files -n cudos-p2p-scan
%defattr(-,root,root,-)
/usr/bin/cosmos-p2p-scan
/usr/bin/cudos-p2p-scan
/usr/lib64/nagios/plugins/check_cudos_p2p
%files -n cudos-monitoring
%defattr(-,root,root,-)
/usr/bin/cudos-is-node-ready.sh
/var/lib/chronoc
/usr/lib/systemd/system/cudos-chronocollector.service
/usr/lib/check_mk_agent/local/check_cudos_block_age.sh
/usr/lib/check_mk_agent/local/check_cudos_block_data.sh
/usr/lib/check_mk_agent/local/check_cudos_catching_up.sh
/usr/lib/check_mk_agent/local/check_cudos_consensus.sh
%files -n cudos-monitoring-docker
%defattr(-,root,root,-)
/usr/bin/cudos-is-node-ready.sh
/var/lib/chronoc
/usr/lib/systemd/system/cudos-chronocollector.service
/usr/lib/check_mk_agent/local/check_cudos_block_age_docker.sh
/usr/lib/check_mk_agent/local/check_cudos_block_data_docker.sh
/usr/lib/check_mk_agent/local/check_cudos_catching_up_docker.sh
%changelog