-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-software.sh
313 lines (256 loc) · 7.58 KB
/
install-software.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
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
306
307
308
309
310
311
312
#!/bin/bash
# This bash file install apache
# Parameter 1 hostname
azure_hostname=$1
astool_configfile=$2
#############################################################################
log()
{
# If you want to enable this logging, uncomment the line below and specify your logging key
#curl -X POST -H "content-type:text/plain" --data-binary "$(date) | ${HOSTNAME} | $1" https://logs-01.loggly.com/inputs/${LOGGING_KEY}/tag/redis-extension,${HOSTNAME}
echo "$1"
echo "$1" >> /astool/log/install.log
}
#############################################################################
check_os() {
grep ubuntu /proc/version > /dev/null 2>&1
isubuntu=${?}
grep centos /proc/version > /dev/null 2>&1
iscentos=${?}
grep redhat /proc/version > /dev/null 2>&1
isredhat=${?}
if [ -f /etc/debian_version ]; then
isdebian=0
else
isdebian=1
fi
if [ $isubuntu -eq 0 ]; then
OS=Ubuntu
VER=$(lsb_release -a | grep Release: | sed 's/Release://'| sed -e 's/^[ \t]*//' | cut -d . -f 1)
elif [ $iscentos -eq 0 ]; then
OS=Centos
VER=$(cat /etc/centos-release)
elif [ $isredhat -eq 0 ]; then
OS=RedHat
VER=$(cat /etc/redhat-release)
elif [ $isdebian -eq 0 ];then
OS=Debian # XXX or Ubuntu??
VER=$(cat /etc/debian_version)
else
OS=$(uname -s)
VER=$(uname -r)
fi
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
log "OS=$OS version $VER Architecture $ARCH"
}
#############################################################################
configure_network(){
# firewall configuration
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
}
#############################################################################
download_astool(){
# Install pre-requisites
apt-get -y install apt-transport-https
apt-get -y update
apt-get -y install libunwind8
apt-get -y install libuuid1
apt-get -y install liblttng-ust0
apt-get -y install libcurl3
apt-get -y install libssl1.0.0
apt-get -y install libkrb5-3
apt-get -y install zlib1g
apt-get -y install libicu52
apt-get -y install libicu55
apt-get -y install libicu57
apt-get -y install libicu60
apt-get -y install libc-bin
# Download config file
cd /astool/config
wget $astool_configfile
# Download astool binary
cd /astool/release
wget https://github.com/flecoqui/ASTool/raw/master/Releases/LatestRelease.ubuntu.tar.gz
tar -xzvf LatestRelease.ubuntu.tar.gz
}
#############################################################################
download_astool_centos(){
# Install pre-requisites
yum -y install libunwind libicu
yum -y install libuuid
yum -y install lttng-ust
yum -y install libcurl
yum -y install openssl-libs
yum -y install krb5-libs
yum -y install libicu
yum -y install zlib
# Download config file
cd /astool/config
wget $astool_configfile
# Download astool binary
cd /astool/release
wget https://github.com/flecoqui/ASTool/raw/master/Releases/LatestRelease.centos.tar.gz
tar -xzvf LatestRelease.centos.tar.gz
}
#############################################################################
download_astool_redhat(){
# Install pre-requisites
yum -y install libunwind libicu
yum -y install libuuid
yum -y install lttng-ust
yum -y install libcurl
yum -y install openssl-libs
yum -y install krb5-libs
yum -y install libicu
yum -y install zlib
# Download config file
cd /astool/config
wget $astool_configfile
# Download astool binary
cd /astool/release
wget https://github.com/flecoqui/ASTool/raw/master/Releases/LatestRelease.rhel.tar.gz
tar -xzvf LatestRelease.rhel.tar.gz
}
#############################################################################
download_astool_debian(){
# Install pre-requisites
apt-get -y install apt-transport-https
apt-get -y update
apt-get -y install libunwind8
apt-get -y install libuuid1
apt-get -y install liblttng-ust0
apt-get -y install libcurl3
apt-get -y install libssl1.0.0
apt-get -y install libkrb5-3
apt-get -y install zlib1g
apt-get -y install libicu52
apt-get -y install libicu55
apt-get -y install libicu57
apt-get -y install libicu60
apt-get -y install libc-bin
# Download config file
cd /astool/config
wget $astool_configfile
# Download astool binary
cd /astool/release
wget https://github.com/flecoqui/ASTool/raw/master/Releases/LatestRelease.debian.tar.gz
tar -xzvf LatestRelease.debian.tar.gz
}
#############################################################################
install_astool(){
cd /astool/release/publish
export PATH=$PATH:/astool/release/publish
echo "export PATH=$PATH:/astool/release/publish" >> /etc/profile
chmod +x /astool/release/publish/ASTool
adduser astool --disabled-login
cat <<EOF > /etc/systemd/system/astool.service
[Unit]
Description=astool Service
After=network.target
[Service]
Type=simple
User=astool
ExecStart=/astool/release/publish/ASTool --import --configfile /astool/config/astool.linux.xml
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOF
}
#############################################################################
install_astool_centos(){
cd /astool/release/publish
export PATH=$PATH:/astool/release/publish
echo "export PATH=$PATH:/astool/release/publish" >> /etc/profile
chmod +x /astool/release/publish/ASTool
adduser astool -s /sbin/nologin
cat <<EOF > /etc/systemd/system/astool.service
[Unit]
Description=astool Service
[Service]
WorkingDirectory=/astool/release/publish
User=astool
ExecStart=/astool/release/publish/ASTool --import --configfile /astool/config/astool.linux.xml'
Restart=always
RestartSec=10
SyslogIdentifier=ASTool
[Install]
WantedBy=multi-user.target
EOF
}
#############################################################################
configure_network_centos(){
# firewall configuration
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
service firewalld start
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload
}
#############################################################################
environ=`env`
# Create folders
mkdir /astool
mkdir /astool/release
mkdir /astool/log
mkdir /astool/config
mkdir /astool/dvr
mkdir /astool/dvr/test1
mkdir /astool/dvr/test2
# Write access in dvr subfolder
chmod -R a+rw /astool/dvr
# Write access in log subfolder
chmod -R a+rw /astool/log
log "Environment before installation: $environ"
log "Installation script start : $(date)"
log "Net Core Installation: $(date)"
log "##### azure_hostname: $azure_hostname"
log "Installation script start : $(date)"
check_os
if [ $iscentos -ne 0 ] && [ $isredhat -ne 0 ] && [ $isubuntu -ne 0 ] && [ $isdebian -ne 0 ];
then
log "unsupported operating system"
exit 1
else
if [ $iscentos -eq 0 ] ; then
log "configure network centos"
configure_network_centos
log "Download ASTool centos"
download_astool_centos
elif [ $isredhat -eq 0 ] ; then
log "configure network redhat"
configure_network_centos
log "Download ASTool redhat"
download_astool_redhat
elif [ $isubuntu -eq 0 ] ; then
log "configure network ubuntu"
configure_network
log "Download ASTool ubuntu"
download_astool
elif [ $isdebian -eq 0 ] ; then
log "configure network"
configure_network
log "Download ASTool debian"
download_astool_debian
fi
log "Download ASTool"
download_astool
if [ $iscentos -eq 0 ] ; then
log "install astool centos"
install_astool_centos
elif [ $isredhat -eq 0 ] ; then
log "install astool redhat"
install_astool_centos
elif [ $isubuntu -eq 0 ] ; then
log "install astool ubuntu"
install_astool
elif [ $isdebian -eq 0 ] ; then
log "install astool debian"
install_astool
fi
log "Start ASTOOL service"
systemctl enable astool
systemctl start astool
fi
exit 0