-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
298 lines (216 loc) · 7.76 KB
/
install.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
#!/usr/bin/env bash
# -------------------------------------------------------------------------
# WO-INSTALL-PACK - automated WordOps server setup script
# -------------------------------------------------------------------------
# Website: https://virtubox.net
# FORKED
# GitHub: https://github.com/VirtuBox/ee-nginx-setup
# This script is licensed under M.I.T
# -------------------------------------------------------------------------
# Version 1.0 - 2019-02-19
# -------------------------------------------------------------------------
CSI='\033['
CEND="${CSI}0m"
CGREEN="${CSI}1;32m"
CRED="${CSI}1;31m"
###Variaveis
###Checando usuario root
[ "$(id -u)" != "0" ] && {
echo "Error: You must be root to run this script, please use the root user to install the software."
echo ""
echo "Use 'sudo su - root' to login as root"
exit 1
}
### Make Sure Sudo available ###
apt-get -y install sudo curl >>/dev/null 2>&1
##################################
# Welcome
##################################
echo -e "${CGREEN}
--------------------------------------------------------------------------
Bem Vindo ao script Wo-instal-pack
-------------------------------------------------------------------------
WO-INSTALL-PACK - Script de Instalação do WordOps
-------------------------------------------------------------------------
FORKED Este script é um fork do:
GitHub: https://github.com/VirtuBox/wo-nginx-setup
Licença M.I.T
-------------------------------------------------------------------------
Github: https://github.com/juanpvh/wo-install
Script: WO-INSTALL
Atualização: 16-11-2019
-------------------------------------------------------------------------
${CEND}"
sleep 3
clear
##################################
# INSTALAÇÃO
##################################
###Pacotes do Sistemas Atualizados
apt-get update -y
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y --purge
apt-get autoclean -y
###
###Instalação de Serviços Adicionais
apt-get install haveged jpegoptim optipng webp curl mutt git zip unzip htop nload jq nmon tar gzip ntp ntpdate gnupg gnupg2 wget pigz tree ccze mycli screen -y
ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
dpkg-reconfigure --frontend noninteractive tzdata
###
### ntp time
systemctl enable ntp
###
### increase history size
export HISTSIZE=10000
###
###Clonando repositorio
git clone https://github.com/juanpvh/wo-install.git $HOME/wo-install || git -C $HOME/wo-install pull origin master
###
### Redis transparent_hugepage
echo never >/sys/kernel/mm/transparent_hugepage/enabled
###
### Instalando Rclone e wo-cli
bash <(curl https://raw.githubusercontent.com/juanpvh/wo-cli/master/setup.sh)
################################################
###Instalação do WordOps
###############################################
{
if [ -e /usr/local/bin/wo ]; then
echo "WordOps Instalado"
else
wget -qO wo wops.cc && sudo bash wo
bash -l
rm -rf wo
fi
}
###
###Instalando Pack adicional do WordOps
if [ -e /usr/local/bin/wo ]; then
/usr/local/bin/wo stack install
/usr/local/bin/wo stack install --php74
/usr/local/bin/wo stack upgrade --phpmyadmin
sed -i 's/version = .*/version = 7.4/' /etc/wo/wo.conf
fi
###
###Compilando a Pilha Nginx-ee
if [ -f /usr/sbin/nginx ]; then
cp -f $HOME/wo-install/etc/nginx/conf.d/upstream.conf /etc/nginx/conf.d/upstream.conf
cp -f $HOME/wo-install/etc/nginx/sites-available/22222 /etc/nginx/sites-available/22222
fi
###
###Configuração adicional fail2ban...
# Add fail2ban configurations
cp -rf $HOME/wo-install/etc/fail2ban/filter.d/* /etc/fail2ban/filter.d/
cp -rf $HOME/wo-install/etc/fail2ban/jail.d/* /etc/fail2ban/jail.d/
fail2ban-client reload
fail2ban-client restart
cp $HOME/wo-install/etc/monit/monitreload.sh /usr/local/bin/monitreload
cp $HOME/wo-install/etc/monit/monit2telegram/sendtelegram.sh /usr/local/bin/sendtelegram
chmod +x /usr/local/bin/sendtelegram
cp $HOME/wo-install/etc/monit/monit2telegram/monit2telegram.sh /usr/local/bin/monit2telegram
chmod +x /usr/local/bin/monit2telegram
cp $HOME/wo-install/etc/monit/monit2telegram/telegramrc /etc/
(crontab -l; echo "0 0 * * * bash /usr/local/bin/monitreload >> /var/log/monitreload.log /dev/null 2>&1") | crontab -
###Instalando Monit...
if [ -f /usr/local/bin/monit ]; then
echo "Monit Instalando"
else
apt-get -y autoremove monit --purge
rm -rf /etc/monit/
apt-get install -y git build-essential libtool openssl automake byacc flex zlib1g-dev libssl-dev autoconf bison libpam0g-dev
cd ~
wget https://mmonit.com/monit/dist/monit-5.25.2.tar.gz
tar zxvf monit-*.tar.gz
rm -rf monit-5.25.2.tar.gz
cd monit-*
./bootstrap
./configure
make && make install
mkdir /etc/monit/
mkdir /etc/monit/monit.d/
mkdir /etc/monit/conf-enable/
cd ~
cp -rf $HOME/wo-install/etc/monitrc /etc/
chmod 0600 /etc/monitrc
ln -s /etc/monitrc /etc/monit/monitrc
#regras
cp -rf $HOME/wo-install/etc/monit/monit.d/* /etc/monit/monit.d/
cp -rf $PWD/wo-install/etc/monit.service /lib/systemd/system/monit.service
systemctl enable monit
#linkar
ln -s /etc/monit/monit.d/* /etc/monit/conf-enable/
#mysql -e "CREATE USER 'monit'@'localhost' IDENTIFIED BY 'mysecretpassword';" > /dev/null 2>&1
#mysql -e "FLUSH PRIVILEGES"
#systemctl restart mysql
monit
monit reload
fi
###
### Install Rkhunter
if [ -z "$(command -v rkhunter)" ]; then
apt-get install rkhunter -y
sed -i 's/UPDATE_MIRRORS=0/UPDATE_MIRRORS=1/' /etc/rkhunter.conf
sed -i 's/MIRRORS_MODE=1/UPDATE_MIRRORS=0/' /etc/rkhunter.conf
sed -i 's/WEB_CMD="\/bin\/false"/WEB_CMD=""/' /etc/rkhunter.conf
sed -i 's/CRON_DAILY_RUN=""/CRON_DAILY_RUN="true"/' /etc/default/rkhunter
sed -i 's/CRON_DB_UPDATE=""/CRON_DB_UPDATE="true"/' /etc/default/rkhunter
sed -i 's/APT_AUTOGEN="false"/APT_AUTOGEN="true"/' /etc/default/rkhunter
rkhunter -C
rkhunter --update
rkhunter --versioncheck
rkhunter --propupd
rkhunter --check --sk
fi
# download secure sshd_config
sudo cp -f $HOME/wo-install/etc/sshd_config /etc/ssh/sshd_config
# restart ssh service
sudo service ssh restart
###Difinindo regras do firewall - ufw
ufw logging low
ufw default allow outgoing
ufw default deny incoming
#ssh
ufw allow 4444
ufw allow 25
ufw allow 53
ufw allow http
ufw allow https
ufw allow 123
ufw allow 68
ufw allow 546
ufw allow 587
ufw allow 873
ufw allow 22222
ufw allow 1137
#ufw allow 2812
ufw allow 49000:50000/tcp
###
#ATIVANDO FIREWALL
ufw reload
echo "y" | ufw enable
#adicionar swap
dd if=/dev/zero of=/swap bs=1k count=2048k
mkswap /swap
swapon /swap
echo '/swap swap swap defaults 0 0' | sudo tee -a /etc/fstab
free -m
###
###Limpando Instalação...
apt-get -y autoremove php5.6-fpm php5.6-common --purge
apt-get -y autoremove php7.0-fpm php7.0-common --purge
apt-get -y autoremove php7.1-fpm php7.1-common --purge
apt-get -y autoremove php7.2-fpm php7.2-common --purge
apt-get -y autoremove php7.3-fpm php7.3-common --purge
cd ~
rm -rf wo-install nginx-build.sh wo-install-pack.sh
###
clear
[ -f /usr/local/bin/wo ] && echo -e "${CGREEN}WordOps Instalado${CEND} [${CGREEN}OK${CEND}]"
echo -e "${CGREEN}Finalizando...${CEND} [${CGREEN}OK${CEND}]"
###
ADDRESS=$(hostname -I | awk '{ print $1}')
echo " "
echo " Optimized Wordops was setup successfully! "
echo " Painel Principal: https://$ADDRESS:22222"
echo " Para Configurar o Rclone digite: rclone config"