-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·305 lines (239 loc) · 6.73 KB
/
install
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#
# Package: esync
# File: install
# Summary: install script for esyncd
# Maintainer: David Wicksell
# Last Modified: Sep 5, 2014
#
# Written by David Wicksell <dlw@linux.com>
# Copyright © 2010-2014 Fourth Watch Software, LC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License (AGPL)
# as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details.
#
#
# This script is written to be run in a Red Hat environment
# Tweaks maybe needed for other distributions
#
# Do NOT set -e
#
if [ "${USER}" != "root" ]
then
echo "You must run this script as root."
exit 1
fi
if [ ! -f "/usr/local/bin/esyncd" ]
then
echo ""
echo "You must first make and install the esyncd daemon"
echo "From the esync/ directory:"
echo -e "\t$ make"
echo -e "\t$ sudo make install"
echo ""
echo "After you are finished with that, rerun this script."
echo -e "\t$ sudo ./install"
exit 1
fi
os=`lsb_release -is`
if [ "${os}" != "RedHatEnterpriseServer" -a "${os}" != "CentOS" ]
then
echo "This script is intended for a Red Hat environment."
echo "You may need to tweak it before running it in this environment."
exit 1
fi
unset os
prog=esyncd
instances=""
cnt=0
# Look for VistA instances
for user in `ls /home/`
do
if [ -f /home/${user}/g/default.dat ]
then
instances[${cnt}]=${user}
cnt=`expr ${cnt} + 1`
fi
done
unset cnt
if [ "${instances[*]}" == "" ]
then
echo -e "\033[2J\033[H"
echo "I couldn't find any VistA instances."
echo ""
echo -n "Please input the instances you want synced "
echo "on one line separated by spaces."
echo -e "Like this:\t\"vistap vistat dev demo\"\tbut without the quotes."
read instances
# Make instances into an array
instances=("${instances}")
if [ "${instances[*]}" == "" ]
then
echo ""
echo "I give up! If you really want to install ${prog} you"
echo "need to run this script again and actually answer the questions."
exit 1
fi
echo ""
echo "You have chosen these instances to sync: ${instances[*]}"
echo ""
echo "If this is what you want, hit any key. If not, type Control-C to abort."
read x
unset x
else
instance=""
ans=""
sub=0
# Menu of possible VistA instances to keep routines synced in
while [ "${instance}" != "quit" ]
do
echo -e "\033[2J\033[H"
echo -n "Please choose the number of an instance "
echo "that you would like to have synced."
echo ""
echo "You have chosen these instances so far:"
echo "${ans[*]}"
echo ""
select instance in ${instances[*]} quit
do
ans[${sub}]=${instance}
# If user "quit"s, that isn't a valid instance
if [ "${ans[${sub}]}" == "quit" ]
then
unset ans[${sub}]
break
fi
echo ""
echo "You have chosen ${ans[${sub}]}."
echo -n "Is this correct? ([y]/n) "
read yorn
if [ "${yorn:0:1}" == "n" -o "${yorn:0:1}" == "N" ]
then
unset ans[${sub}]
break
else
sub=`expr ${sub} + 1`
fi
cnt=0
# Take the user choice out of the dynamic menu
for choice in ${instances[*]}
do
if [ ${choice} == ${instance} ]
then
unset instances[${cnt}]
fi
cnt=`expr ${cnt} + 1`
done
# Reindex the array
instances=(${instances[*]})
break
done
done
if [ "${ans[*]}" == "" ]
then
echo ""
echo "I give up! If you really want to install ${prog} you"
echo "need to run this script again and actually choose an instance."
exit 1
fi
echo ""
echo "You have chosen these instances to sync: ${ans[*]}"
echo ""
echo "If this is what you want, hit any key. If not, type Control-C to abort."
read x
unset x
# Put their answers into the instance array
instances=(${ans[*]})
fi
install -o root -g root -m 755 esync.init /etc/init.d/esyncd
echo "Installed ${prog} in /etc/init.d"
cd /etc/init.d/
echo "Creating symbolic links in /etc/init.d"
for env in ${instances[*]}
do
# Grab the name of the secondary database instance from the environment
test=`su - ${env} -c 'echo ${gtm_repl_instsecondary}'`
if [ "${test}" == "" ]
then
echo ""
echo "You need to define the environment variable gtm_repl_instsecondary"
echo "in the ${env} instance environment."
echo ""
echo "You could put this line in your ~${env}/.bash_profile, or better"
echo "yet, in your GT.M environment file."
echo -e "\texport gtm_repl_instsecondary=<secondary-hostname>"
echo -e "\t\twhere <secondary-hostname> is the same as your"
echo -e "\t\tsecondary host for database replication."
echo ""
echo "Did not install esync package for ${env}, please run again."
continue
fi
unset test
ln -sf ${prog} ${prog}-${env}
echo "Adding ${prog}-${env} to the appropriate runlevels"
echo ""
/sbin/chkconfig --add ${prog}-${env}
side=`su - ${env} -c 'echo ${REPL_SIDE}'`
# Only want to start esyncd on the primary, not the secondary
if [ "${side}" = "PRIMARY" ]
then
if [ -f /var/run/esyncd-${env}.pid ]
then
echo "Restarting the esync-${env} daemon"
/sbin/service esync-${env} restart
else
echo "Starting the esync-${env} daemon"
/sbin/service esync-${env} start
fi
fi
done
unset side
cd - >/dev/null
if [ ! -d /usr/local/share/man/man8 ]
then
mkdir -p /usr/local/share/man/man8
fi
install -o root -g root -m 644 esyncd.8 /usr/local/share/man/man8
echo ""
echo "Installed esyncd(8) manpage"
if [ -f /etc/syslog.conf ]
then
grep -q 'esyncd.log' /etc/syslog.conf
test=$?
if [ ${test} = 1 ]
then
echo ""
echo "Setting up syslog for esyncd"
echo "" >>/etc/syslog.conf
echo -n "# Save esync messages here " >>/etc/syslog.conf
echo "(local mod for GT.M replication)." >>/etc/syslog.conf
echo -e "local0.*\t\t\t\t\t/var/log/esyncd.log" >>/etc/syslog.conf
fi
unset test
if [ -f /var/run/syslogd.pid ]
then
echo ""
echo "Reloading the syslog configuration files"
/sbin/service syslog reload
else
echo "Starting the syslog logging daemon"
/sbin/service syslog start
fi
fi
if [ ! -d /etc/logrotate.d ]
then
mkdir /etc/logrotate.d
fi
echo ""
echo "Setting up logrotate for esyncd"
install -o root -g root -m 644 \
esync.logrotate /etc/logrotate.d/esync
echo ""
echo "install script has finished."
exit 0