forked from Clrkz/VPSAutoScrptz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VPSnOCScrptZ.sh
478 lines (415 loc) · 16.6 KB
/
VPSnOCScrptZ.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#!/bin/bash
#
# Original script by fornesia, rzengineer and fawzya
# Mod by Clrkz for Adding OCS Panel
#
# ==================================================
if [ $USER != 'root' ]; then
echo "You must run this as root"
exit
fi
# initialisasi var
export DEBIAN_FRONTEND=noninteractive
OS=`uname -m`;
if [[ -e /etc/debian_version ]]; then
#OS=debian
RCLOCAL='/etc/rc.local'
else
echo "You are not running this script on Debian OS"
exit
fi
vps="vps";
if [[ $vps = "vps" ]]; then
source="https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master"
else
source="https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master"
fi
# go to root
cd
MYIP=$(wget -qO- ipv4.icanhazip.com);
# check registered ip
wget -q -O daftarip http://188.166.215.119:85/ocs/ip.txt
if ! grep -w -q $MYIP daftarip; then
echo "Sorry, only registered IPs can use this script!"
if [[ $vps = "vps" ]]; then
echo "Powered by Clrkz"
else
echo "Powered by Clrkz"
fi
rm -f /root/daftarip
exit
fi
#https://github.com/adenvt/OcsPanels/wiki/tutor-debian
clear
echo ""
echo "I need to ask some questions before starting setup"
echo "You can leave the default option and just hit enter if you agree with the option"
echo ""
echo "First I need to know the new password of MySQL root user:"
read -p "Password baru: " -e -i clrkz DatabasePass
echo ""
echo "Finally, name the Database Name for OCS Panels"
echo " Please, use one word only, no special characters other than Underscore (_)"
read -p " Database Name: " -e -i OCS_PANEL DatabaseName
echo ""
echo "Okay, that's all I need. We are ready to setup your OCS Panels now"
read -n1 -r -p "Press any key to continue..."
# initialisasi var
export DEBIAN_FRONTEND=noninteractive
OS=`uname -m`;
MYIP=$(wget -qO- ipv4.icanhazip.com);
MYIP2="s/xxxxxxxxx/$MYIP/g";
#detail nama perusahaan
country=ID
state=Manila
locality=Manila
organization=ByteHAX
organizationalunit=IT
commonname=bytehax.blogspot.com
# go to root
cd
# disable ipv6
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
# install wget and curl
apt-get update;apt-get -y install wget curl;
# set time GMT +7
ln -fs /usr/share/zoneinfo/Asia/Manila /etc/localtime
# set locale
sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
service ssh restart
# set repo
wget -O /etc/apt/sources.list "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/sources.list.debian7"
wget "http://www.dotdeb.org/dotdeb.gpg"
cat dotdeb.gpg | apt-key add -;rm dotdeb.gpg
sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
# update
apt-get update
# install webserver
apt-get -y install nginx
# install essential package
apt-get -y install nano iptables dnsutils openvpn screen whois ngrep unzip unrar
echo "clear" >> .bashrc
echo 'echo -e " # ### ### /"' >> .bashrc
echo 'echo -e " / /### / ### #/"' >> .bashrc
echo 'echo -e " / / ###/ ## ##"' >> .bashrc
echo 'echo -e " / ## ## ## ##"' >> .bashrc
echo 'echo -e " / ### ## ##"' >> .bashrc
echo 'echo -e "## ## ## ### /### ## /## ######"' >> .bashrc
echo 'echo -e "## ## ## ###/ #### / ## / ### /#######"' >> .bashrc
echo 'echo -e "## ## ## ## ###/ ##/ / / ##"' >> .bashrc
echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
echo 'echo -e " ## ## ## ## ## ## ###"' >> .bashrc
echo 'echo -e " ## # / ## ## ###### ###"' >> .bashrc
echo 'echo -e " ### / ## ## ## ### ###"' >> .bashrc
echo 'echo -e " ######/ ### / ### ## ### / ##"' >> .bashrc
echo 'echo -e " ### ##/ ### ## ##/ ##"' >> .bashrc
echo 'echo -e " /"' >> .bashrc
echo 'echo -e " /"' >> .bashrc
echo 'echo -e " /"' >> .bashrc
echo 'echo -e " /"' >> .bashrc
echo 'echo -e "welcome to the server $HOSTNAME" | lolcat' >> .bashrc
echo 'echo -e "Script mod by Clrkz"' >> .bashrc
echo 'echo -e "Type menu to display a list of commands"' >> .bashrc
echo 'echo -e ""' >> .bashrc
# install webserver
cd
rm /etc/nginx/sites-enabled/default
rm /etc/nginx/sites-available/default
wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/nginx.conf"
mkdir -p /home/vps/public_html
echo "<pre>Setup by Clrkz</pre>" > /home/vps/public_html/index.html
wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/vps.conf"
service nginx restart
# install openvpn
wget -O /etc/openvpn/openvpn.tar "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/openvpn-debian.tar"
cd /etc/openvpn/
tar xf openvpn.tar
wget -O /etc/openvpn/1194.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/1194.conf"
service openvpn restart
sysctl -w net.ipv4.ip_forward=1
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
iptables-save > /etc/iptables_yg_baru_dibikin.conf
wget -O /etc/network/if-up.d/iptables "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/iptables"
chmod +x /etc/network/if-up.d/iptables
service openvpn restart
# konfigurasi openvpn
cd /etc/openvpn/
wget -O /etc/openvpn/client.ovpn "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/client-1194.conf"
sed -i $MYIP2 /etc/openvpn/client.ovpn;
cp client.ovpn /home/vps/public_html/
# install badvpn
cd
wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw"
if [ "$OS" == "x86_64" ]; then
wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw64"
fi
sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.local
chmod +x /usr/bin/badvpn-udpgw
screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300
# setting port ssh
cd
sed -i 's/Port 22/Port 22/g' /etc/ssh/sshd_config
sed -i '/Port 22/a Port 444' /etc/ssh/sshd_config
service ssh restart
# install dropbear
apt-get -y install dropbear
sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=3128/g' /etc/default/dropbear
sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 143"/g' /etc/default/dropbear
echo "/bin/false" >> /etc/shells
echo "/usr/sbin/nologin" >> /etc/shells
service ssh restart
service dropbear restart
# install squid3
cd
apt-get -y install squid3
wget -O /etc/squid3/squid.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/squid3.conf"
sed -i $MYIP2 /etc/squid3/squid.conf;
service squid3 restart
# install webmin
cd
apt-get -y install webmin
sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
service webmin restart
# install stunnel
apt-get install stunnel4 -y
cat > /etc/stunnel/stunnel.conf <<-END
cert = /etc/stunnel/stunnel.pem
client = no
socket = a:SO_REUSEADDR=1
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
[dropbear]
accept = 443
connect = 127.0.0.1:3128
END
#membuat sertifikat
openssl genrsa -out key.pem 2048
openssl req -new -x509 -key key.pem -out cert.pem -days 1095 \
-subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
#konfigurasi stunnel
sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
/etc/init.d/stunnel4 restart
# teks berwarna
apt-get -y install ruby
gem install lolcat
# install fail2banapt-get -y install fail2ban;
service fail2ban restart
# install ddos deflate
cd
apt-get -y install dnsutils dsniff
wget https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/ddos-deflate-master.zip
unzip ddos-deflate-master.zip
cd ddos-deflate-master
./install.sh
rm -rf /root/ddos-deflate-master.zip
# bannerrm /etc/issue.net
wget -O /etc/issue.net "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/issue.net"
sed -i 's@#Banner@Banner@g' /etc/ssh/sshd_config
sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
service ssh restart
service dropbear restart
# download script
cd /usr/bin
wget -O menu "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/menu.sh"
wget -O usernew "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/usernew.sh"
wget -O trial "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/trial.sh"
wget -O delete "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/hapus.sh"
wget -O check "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-login.sh"
wget -O member "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-list.sh"
wget -O restart "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/resvis.sh"
wget -O speedtest "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/speedtest_cli.py"
wget -O info "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/info.sh"
wget -O about "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/about.sh"
echo "0 0 * * * root /sbin/reboot" > /etc/cron.d/reboot
chmod +x menu
chmod +x usernew
chmod +x trial
chmod +x delete
chmod +x check
chmod +x member
chmod +x restart
chmod +x speedtest
chmod +x info
chmod +x about
# finishing
cd
chown -R www-data:www-data /home/vps/public_html
service nginx start
service openvpn restart
service cron restart
service ssh restart
service dropbear restart
service squid3 restart
service webmin restart
rm -rf ~/.bash_history && history -c
echo "unset HISTFILE" >> /etc/profile
# install neofetch
echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
apt-get update
apt-get install neofetch
echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
apt-get update
apt-get install neofetch
#apt-get update
apt-get update -y
apt-get install build-essential expect -y
apt-get install -y mysql-server
#mysql_secure_installation
so1=$(expect -c "
spawn mysql_secure_installation; sleep 3
expect \"\"; sleep 3; send \"\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"$DatabasePass\r\"
expect \"\"; sleep 3; send \"$DatabasePass\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect \"\"; sleep 3; send \"Y\r\"
expect eof; ")
echo "$so1"
#\r
#Y
#pass
#pass
#Y
#Y
#Y
#Y
cd
chown -R mysql:mysql /var/lib/mysql/
chmod -R 755 /var/lib/mysql/
apt-get -y install nginx php5 php5-fpm php5-cli php5-mysql php5-mcrypt
rm /etc/nginx/sites-enabled/default
rm /etc/nginx/sites-available/default
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
mv /etc/nginx/conf.d/vps.conf /etc/nginx/conf.d/vps.conf.backup
wget -O /etc/nginx/nginx.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-debian7/nginx.conf"
wget -O /etc/nginx/conf.d/vps.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-debian7/vps.conf"
sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
sed -i 's/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g' /etc/php5/fpm/pool.d/www.conf
useradd -m vps
mkdir -p /home/vps/public_html
rm /home/vps/public_html/index.html
rm /home/vps/public_html/index.php
echo "<?php phpinfo() ?>" > /home/vps/public_html/info.php
chown -R www-data:www-data /home/vps/public_html
chmod -R g+rw /home/vps/public_html service php5-fpm restart
service php5-fpm restart
service nginx restart
apt-get -y install zip unzip
cd /home/vps/public_html
wget $source/OCS.zip
unzip OCS.zip
rm -f OCS.zip
chown -R www-data:www-data /home/vps/public_html
chmod -R g+rw /home/vps/public_html
#mysql -u root -p
so2=$(expect -c "
spawn mysql -u root -p; sleep 3
expect \"\"; sleep 3; send \"$DatabasePass\r\"
expect \"\"; sleep 3; send \"CREATE DATABASE IF NOT EXISTS $DatabaseName;EXIT;\r\"
expect eof; ")
echo "$so2"
#pass
#CREATE DATABASE IF NOT EXISTS OCS_PANEL;EXIT;
chmod 777 /home/vps/public_html/config
chmod 777 /home/vps/public_html/config/inc.php
chmod 777 /home/vps/public_html/config/route.php
apt-get -y --force-yes -f install libxml-parser-perl
clear
echo "Open Browser, access http://$MYIP:85/ and complete the data as below!"
echo "Database:"
echo "- Database Host: localhost"
echo "- Database Name: $DatabaseName"
echo "- Database User: root"
echo "- Database Pass: $DatabasePass"
echo ""
echo "Admin Login:"
echo "- Username: anything you want"
echo "- Password Baru: anything you want"
echo "- Re-enter New Password: as desired"
echo ""
echo "Click Install and wait for the process to finish, go back to terminal and then press [ENTER key]!"
sleep 3
echo ""
read -p "If the above step has been done, please Press [Enter] key to continue...."
echo ""
read -p "If you really believe the above step has been done, please Press [Enter] key to continue..."
echo ""
cd /root
#wget http://www.webmin.com/jcameron-key.asc
#apt-key add jcameron-key.asc
#sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
#service webmin restart
#rm -f /root/jcameron-key.asc
#rm -R /home/vps/public_html/installation
cd
rm -f /root/.bash_history && history -c
echo "unset HISTFILE" >> /etc/profile
chmod 755 /home/vps/public_html/config
chmod 644 /home/vps/public_html/config/inc.php
chmod 644 /home/vps/public_html/config/route.php
# info
clear
# info
echo "Autoscript Include:" | tee log-install.txt
echo "=======================================================" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Service" | tee -a log-install.txt
echo "-------" | tee -a log-install.txt
echo "OpenSSH : 22, 444" | tee -a log-install.txt
echo "Dropbear : 143, 3128" | tee -a log-install.txt
echo "SSL : 443" | tee -a log-install.txt
echo "Squid3 : 8000, 8080 (limit to IP SSH)" | tee -a log-install.txt
echo "OpenVPN : TCP 1194 (client config : http://$MYIP:81/client.ovpn)" | tee -a log-install.txt
echo "badvpn : badvpn-udpgw port 7300" | tee -a log-install.txt
echo "nginx : 81" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Script" | tee -a log-install.txt
echo "------" | tee -a log-install.txt
echo "menu (Displays a list of available commands)" | tee -a log-install.txt
echo "usernew (Creating an SSH Account)" | tee -a log-install.txt
echo "trial (Create a Trial Account)" | tee -a log-install.txt
echo "delete (Clearing SSH Account)" | tee -a log-install.txt
echo "check (Check User Login)" | tee -a log-install.txt
echo "member (Check Member SSH)" | tee -a log-install.txt
echo "restart (Restart Service dropbear, webmin, squid3, openvpn and ssh)" | tee -a log-install.txt
echo "reboot (Reboot VPS)" | tee -a log-install.txt
echo "speedtest (Speedtest VPS)" | tee -a log-install.txt
echo "info (System Information)" | tee -a log-install.txt
echo "about (Information about auto install script)" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Other features" | tee -a log-install.txt
echo "----------" | tee -a log-install.txt
echo "Webmin : http://$MYIP:10000/" | tee -a log-install.txt
echo "Timezone : Asia/Manila (GMT +7)" | tee -a log-install.txt
echo "IPv6 : [off]" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Original Script by Fornesia, Rzengineer & Fawzya" | tee -a log-install.txt
echo "Modified by Clrkz" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "VPS AUTO REBOOT TIME HOURS 12 NIGHT" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "=======================================================" | tee -a log-install.txt
echo "=======================================================" | tee -a log-install.txt
echo "Please login Reseller Panel at http://$MYIP:85" | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Auto Script Installer OCS Panels Mod by Clrkz" | tee -a log-install.txt
echo " (http://bytehax.blogspot.com/ - fb.com/143Clarkz) " | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Thanks " | tee -a log-install.txt
echo "" | tee -a log-install.txt
echo "Installation Log --> /root/log-install.txt" | tee -a log-install.txt
echo "=======================================================" | tee -a log-install.txt
cd ~/
rm -f /root/VPSnOCScrptZ.sh
#rm -f /root/ocspanel.sh