VnOdef.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. #!/bin/bash
  2. #
  3. # Original script by fornesia, rzengineer and fawzya
  4. # Mod by Janda Baper Group for Adding OCS Panel
  5. #
  6. # ==================================================
  7. if [ $USER != 'root' ]; then
  8. echo "You must run this as root"
  9. exit
  10. fi
  11. # initialisasi var
  12. export DEBIAN_FRONTEND=noninteractive
  13. OS=`uname -m`;
  14. if [[ -e /etc/debian_version ]]; then
  15. #OS=debian
  16. RCLOCAL='/etc/rc.local'
  17. else
  18. echo "You are not running this script on Debian OS"
  19. exit
  20. fi
  21. vps="vps";
  22. if [[ $vps = "vps" ]]; then
  23. source="https://raw.githubusercontent.com/thirdza056/OCS/master"
  24. else
  25. source="https://raw.githubusercontent.com/thirdza056/OCS/master"
  26. fi
  27. # go to root
  28. cd
  29. MYIP=$(wget -qO- ipv4.icanhazip.com);
  30. # check registered ip
  31. wget -q -O daftarip http://167.99.74.4:85/ocs/ip.txt
  32. if ! grep -w -q $MYIP daftarip; then
  33. echo "Sorry, only registered IPs can use this script!"
  34. if [[ $vps = "vps" ]]; then
  35. echo "Powered by Clrkz"
  36. else
  37. echo "Powered by Clrkz"
  38. fi
  39. rm -f /root/daftarip
  40. exit
  41. fi
  42. #https://github.com/adenvt/OcsPanels/wiki/tutor-debian
  43. clear
  44. echo ""
  45. echo "I need to ask some questions before starting setup"
  46. echo "You can leave the default option and just hit enter if you agree with the option"
  47. echo ""
  48. echo "First I need to know the new password of MySQL root user:"
  49. read -p "Password baru: " -e -i clrkz DatabasePass
  50. echo ""
  51. echo "Finally, name the Database Name for OCS Panels"
  52. echo " Please, use one word only, no special characters other than Underscore (_)"
  53. read -p " Database Name: " -e -i OCS_PANEL DatabaseName
  54. echo ""
  55. echo "Okay, that's all I need. We are ready to setup your OCS Panels now"
  56. read -n1 -r -p "Press any key to continue..."
  57. # initialisasi var
  58. export DEBIAN_FRONTEND=noninteractive
  59. OS=`uname -m`;
  60. MYIP=$(wget -qO- ipv4.icanhazip.com);
  61. MYIP2="s/xxxxxxxxx/$MYIP/g";
  62. #detail nama perusahaan
  63. country=ID
  64. state=Manila
  65. locality=Manila
  66. organization=ByteHAX
  67. organizationalunit=IT
  68. commonname=bytehax.blogspot.com
  69. email=143Clarkz@gmail.com
  70. # go to root
  71. cd
  72. # disable ipv6
  73. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  74. sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
  75. # install wget and curl
  76. apt-get update;apt-get -y install wget curl;
  77. # set time GMT +7
  78. ln -fs /usr/share/zoneinfo/Asia/Manila /etc/localtime
  79. # set locale
  80. sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
  81. service ssh restart
  82. # set repo
  83. wget -O /etc/apt/sources.list "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/sources.list.debian7"
  84. wget "http://www.dotdeb.org/dotdeb.gpg"
  85. cat dotdeb.gpg | apt-key add -;rm dotdeb.gpg
  86. sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
  87. wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
  88. # update
  89. apt-get update
  90. # install webserver
  91. apt-get -y install nginx
  92. # install essential package
  93. apt-get -y install nano iptables dnsutils openvpn screen whois ngrep unzip unrar
  94. echo "clear" >> .bashrc
  95. echo 'echo -e " # ### ### /"' >> .bashrc
  96. echo 'echo -e " / /### / ### #/"' >> .bashrc
  97. echo 'echo -e " / / ###/ ## ##"' >> .bashrc
  98. echo 'echo -e " / ## ## ## ##"' >> .bashrc
  99. echo 'echo -e " / ### ## ##"' >> .bashrc
  100. echo 'echo -e "## ## ## ### /### ## /## ######"' >> .bashrc
  101. echo 'echo -e "## ## ## ###/ #### / ## / ### /#######"' >> .bashrc
  102. echo 'echo -e "## ## ## ## ###/ ##/ / / ##"' >> .bashrc
  103. echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
  104. echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
  105. echo 'echo -e " ## ## ## ## ## ## ###"' >> .bashrc
  106. echo 'echo -e " ## # / ## ## ###### ###"' >> .bashrc
  107. echo 'echo -e " ### / ## ## ## ### ###"' >> .bashrc
  108. echo 'echo -e " ######/ ### / ### ## ### / ##"' >> .bashrc
  109. echo 'echo -e " ### ##/ ### ## ##/ ##"' >> .bashrc
  110. echo 'echo -e " /"' >> .bashrc
  111. echo 'echo -e " /"' >> .bashrc
  112. echo 'echo -e "welcome to the server $HOSTNAME" | lolcat' >> .bashrc
  113. echo 'echo -e "Script mod by Clrkz"' >> .bashrc
  114. echo 'echo -e "Type menu to display a list of commands"' >> .bashrc
  115. echo 'echo -e ""' >> .bashrc
  116. # install webserver
  117. cd
  118. rm /etc/nginx/sites-enabled/default
  119. rm /etc/nginx/sites-available/default
  120. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/nginx.conf"
  121. mkdir -p /home/vps/public_html
  122. echo "<pre>Setup by Clrkz</pre>" > /home/vps/public_html/index.html
  123. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/vps.conf"
  124. service nginx restart
  125. # install openvpn
  126. wget -O /etc/openvpn/openvpn.tar "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/openvpn-debian.tar"
  127. cd /etc/openvpn/
  128. tar xf openvpn.tar
  129. wget -O /etc/openvpn/1194.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/1194.conf"
  130. service openvpn restart
  131. sysctl -w net.ipv4.ip_forward=1
  132. sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
  133. iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
  134. iptables-save > /etc/iptables_yg_baru_dibikin.conf
  135. wget -O /etc/network/if-up.d/iptables "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/iptables"
  136. chmod +x /etc/network/if-up.d/iptables
  137. service openvpn restart
  138. # konfigurasi openvpn
  139. cd /etc/openvpn/
  140. wget -O /etc/openvpn/client.ovpn "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/client-1194.conf"
  141. sed -i $MYIP2 /etc/openvpn/client.ovpn;
  142. cp client.ovpn /home/vps/public_html/
  143. # install badvpn
  144. cd
  145. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw"
  146. if [ "$OS" == "x86_64" ]; then
  147. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw64"
  148. fi
  149. sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.local
  150. chmod +x /usr/bin/badvpn-udpgw
  151. screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300
  152. # setting port ssh
  153. cd
  154. sed -i 's/Port 22/Port 22/g' /etc/ssh/sshd_config
  155. sed -i '/Port 22/a Port 444' /etc/ssh/sshd_config
  156. service ssh restart
  157. # install dropbear
  158. apt-get -y install dropbear
  159. sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
  160. sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=3128/g' /etc/default/dropbear
  161. sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 143"/g' /etc/default/dropbear
  162. echo "/bin/false" >> /etc/shells
  163. echo "/usr/sbin/nologin" >> /etc/shells
  164. service ssh restart
  165. service dropbear restart
  166. # install squid3
  167. cd
  168. apt-get -y install squid3
  169. wget -O /etc/squid3/squid.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/squid3.conf"
  170. sed -i $MYIP2 /etc/squid3/squid.conf;
  171. service squid3 restart
  172. # install webmin
  173. cd
  174. apt-get -y install webmin
  175. sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  176. service webmin restart
  177. # install stunnel
  178. apt-get install stunnel4 -y
  179. cat > /etc/stunnel/stunnel.conf <<-END
  180. cert = /etc/stunnel/stunnel.pem
  181. client = no
  182. socket = a:SO_REUSEADDR=1
  183. socket = l:TCP_NODELAY=1
  184. socket = r:TCP_NODELAY=1
  185. [dropbear]
  186. accept = 443
  187. connect = 127.0.0.1:3128
  188. END
  189. #membuat sertifikat
  190. openssl genrsa -out key.pem 2048
  191. openssl req -new -x509 -key key.pem -out cert.pem -days 1095 \
  192. -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
  193. cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
  194. #konfigurasi stunnel
  195. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  196. /etc/init.d/stunnel4 restart
  197. # teks berwarna
  198. apt-get -y install ruby
  199. gem install lolcat
  200. # install fail2ban
  201. apt-get -y install fail2ban;
  202. service fail2ban restart
  203. # install ddos deflate
  204. cd
  205. apt-get -y install dnsutils dsniff
  206. wget https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/ddos-deflate-master.zip
  207. unzip ddos-deflate-master.zip
  208. cd ddos-deflate-master
  209. ./install.sh
  210. rm -rf /root/ddos-deflate-master.zip
  211. # bannerrm /etc/issue.net
  212. wget -O /etc/issue.net "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/issue.net"
  213. sed -i 's@#Banner@Banner@g' /etc/ssh/sshd_config
  214. sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
  215. service ssh restart
  216. service dropbear restart
  217. # download script
  218. cd /usr/bin
  219. wget -O menu "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/menu.sh"
  220. wget -O usernew "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/usernew.sh"
  221. wget -O trial "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/trial.sh"
  222. wget -O delete "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/hapus.sh"
  223. wget -O check "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-login.sh"
  224. wget -O member "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-list.sh"
  225. wget -O restart "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/resvis.sh"
  226. wget -O speedtest "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/speedtest_cli.py"
  227. wget -O info "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/info.sh"
  228. wget -O about "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/about.sh"
  229. echo "0 0 * * * root /sbin/reboot" > /etc/cron.d/reboot
  230. chmod +x menu
  231. chmod +x usernew
  232. chmod +x trial
  233. chmod +x delete
  234. chmod +x check
  235. chmod +x member
  236. chmod +x restart
  237. chmod +x speedtest
  238. chmod +x info
  239. chmod +x about
  240. # finishing
  241. cd
  242. chown -R www-data:www-data /home/vps/public_html
  243. service nginx start
  244. service openvpn restart
  245. service cron restart
  246. service ssh restart
  247. service dropbear restart
  248. service squid3 restart
  249. service webmin restart
  250. rm -rf ~/.bash_history && history -c
  251. echo "unset HISTFILE" >> /etc/profile
  252. # install neofetch
  253. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  254. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  255. apt-get update
  256. apt-get install neofetch
  257. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  258. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  259. apt-get update
  260. apt-get install neofetch
  261. #apt-get update
  262. apt-get update -y
  263. apt-get install build-essential expect -y
  264. apt-get install -y mysql-server
  265. #mysql_secure_installation
  266. so1=$(expect -c "
  267. spawn mysql_secure_installation; sleep 3
  268. expect \"\"; sleep 3; send \"\r\"
  269. expect \"\"; sleep 3; send \"Y\r\"
  270. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  271. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  272. expect \"\"; sleep 3; send \"Y\r\"
  273. expect \"\"; sleep 3; send \"Y\r\"
  274. expect \"\"; sleep 3; send \"Y\r\"
  275. expect \"\"; sleep 3; send \"Y\r\"
  276. expect eof; ")
  277. echo "$so1"
  278. #\r
  279. #Y
  280. #pass
  281. #pass
  282. #Y
  283. #Y
  284. #Y
  285. #Y
  286. cd
  287. chown -R mysql:mysql /var/lib/mysql/
  288. chmod -R 755 /var/lib/mysql/
  289. apt-get -y install nginx php5 php5-fpm php5-cli php5-mysql php5-mcrypt
  290. rm /etc/nginx/sites-enabled/default
  291. rm /etc/nginx/sites-available/default
  292. mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
  293. mv /etc/nginx/conf.d/vps.conf /etc/nginx/conf.d/vps.conf.backup
  294. wget -O /etc/nginx/nginx.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-debian7/nginx.conf"
  295. wget -O /etc/nginx/conf.d/vps.conf "http://script.hostingtermurah.net/repo/blog/ocspanel-debian7/vps.conf"
  296. sed -i 's/cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini
  297. sed -i 's/listen = \/var\/run\/php5-fpm.sock/listen = 127.0.0.1:9000/g' /etc/php5/fpm/pool.d/www.conf
  298. useradd -m vps
  299. mkdir -p /home/vps/public_html
  300. rm /home/vps/public_html/index.html
  301. rm /home/vps/public_html/index.php
  302. echo "<?php phpinfo() ?>" > /home/vps/public_html/info.php
  303. chown -R www-data:www-data /home/vps/public_html
  304. chmod -R g+rw /home/vps/public_html service php5-fpm restart
  305. service php5-fpm restart
  306. service nginx restart
  307. apt-get -y install zip unzip
  308. cd /home/vps/public_html
  309. wget $source/LTEOCS.zip
  310. unzip LTEOCS.zip
  311. rm -f LTEOCS.zip
  312. chown -R www-data:www-data /home/vps/public_html
  313. chmod -R g+rw /home/vps/public_html
  314. #mysql -u root -p
  315. so2=$(expect -c "
  316. spawn mysql -u root -p; sleep 3
  317. expect \"\"; sleep 3; send \"$DatabasePass\r\"
  318. expect \"\"; sleep 3; send \"CREATE DATABASE IF NOT EXISTS $DatabaseName;EXIT;\r\"
  319. expect eof; ")
  320. echo "$so2"
  321. #pass
  322. #CREATE DATABASE IF NOT EXISTS OCS_PANEL;EXIT;
  323. chmod 777 /home/vps/public_html/config
  324. chmod 777 /home/vps/public_html/config/inc.php
  325. chmod 777 /home/vps/public_html/config/route.php
  326. apt-get -y --force-yes -f install libxml-parser-perl
  327. clear
  328. echo "Open Browser, access http://$MYIP:85/ and complete the data as below!"
  329. echo "Database:"
  330. echo "- Database Host: localhost"
  331. echo "- Database Name: $DatabaseName"
  332. echo "- Database User: root"
  333. echo "- Database Pass: $DatabasePass"
  334. echo ""
  335. echo "Admin Login:"
  336. echo "- Username: anything you want"
  337. echo "- Password Baru: anything you want"
  338. echo "- Re-enter New Password: as desired"
  339. echo ""
  340. echo "Click Install and wait for the process to finish, go back to terminal and then press [ENTER key]!"
  341. sleep 3
  342. echo ""
  343. read -p "If the above step has been done, please Press [Enter] key to continue...."
  344. echo ""
  345. read -p "If you really believe the above step has been done, please Press [Enter] key to continue..."
  346. echo ""
  347. cd /root
  348. #wget http://www.webmin.com/jcameron-key.asc
  349. #apt-key add jcameron-key.asc
  350. #sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  351. #service webmin restart
  352. #rm -f /root/jcameron-key.asc
  353. #rm -R /home/vps/public_html/installation
  354. cd
  355. rm -f /root/.bash_history && history -c
  356. echo "unset HISTFILE" >> /etc/profile
  357. chmod 755 /home/vps/public_html/config
  358. chmod 644 /home/vps/public_html/config/inc.php
  359. chmod 644 /home/vps/public_html/config/route.php
  360. # info
  361. clear
  362. # info
  363. echo "Autoscript Include:" | tee log-install.txt
  364. echo "=======================================================" | tee -a log-install.txt
  365. echo "" | tee -a log-install.txt
  366. echo "Service" | tee -a log-install.txt
  367. echo "-------" | tee -a log-install.txt
  368. echo "OpenSSH : 22, 444" | tee -a log-install.txt
  369. echo "Dropbear : 143, 3128" | tee -a log-install.txt
  370. echo "SSL : 443" | tee -a log-install.txt
  371. echo "Squid3 : 8000, 8080 (limit to IP SSH)" | tee -a log-install.txt
  372. echo "OpenVPN : TCP 1194 (client config : http://$MYIP:81/client.ovpn)" | tee -a log-install.txt
  373. echo "badvpn : badvpn-udpgw port 7300" | tee -a log-install.txt
  374. echo "nginx : 81" | tee -a log-install.txt
  375. echo "" | tee -a log-install.txt
  376. echo "Script" | tee -a log-install.txt
  377. echo "------" | tee -a log-install.txt
  378. echo "menu (Displays a list of available commands)" | tee -a log-install.txt
  379. echo "usernew (Creating an SSH Account)" | tee -a log-install.txt
  380. echo "trial (Create a Trial Account)" | tee -a log-install.txt
  381. echo "delete (Clearing SSH Account)" | tee -a log-install.txt
  382. echo "check (Check User Login)" | tee -a log-install.txt
  383. echo "member (Check Member SSH)" | tee -a log-install.txt
  384. echo "restart (Restart Service dropbear, webmin, squid3, openvpn and ssh)" | tee -a log-install.txt
  385. echo "reboot (Reboot VPS)" | tee -a log-install.txt
  386. echo "speedtest (Speedtest VPS)" | tee -a log-install.txt
  387. echo "info (System Information)" | tee -a log-install.txt
  388. echo "about (Information about auto install script)" | tee -a log-install.txt
  389. echo "" | tee -a log-install.txt
  390. echo "Other features" | tee -a log-install.txt
  391. echo "----------" | tee -a log-install.txt
  392. echo "Webmin : http://$MYIP:10000/" | tee -a log-install.txt
  393. echo "Timezone : Asia/Manila (GMT +7)" | tee -a log-install.txt
  394. echo "IPv6 : [off]" | tee -a log-install.txt
  395. echo "" | tee -a log-install.txt
  396. echo "Original Script by Fornesia, Rzengineer & Fawzya" | tee -a log-install.txt
  397. echo "Modified by Clrkz" | tee -a log-install.txt
  398. echo "" | tee -a log-install.txt
  399. echo "VPS AUTO REBOOT TIME HOURS 12 NIGHT" | tee -a log-install.txt
  400. echo "" | tee -a log-install.txt
  401. echo "=======================================================" | tee -a log-install.txt
  402. echo "=======================================================" | tee -a log-install.txt
  403. echo "Please login Reseller Panel at http://$MYIP:85" | tee -a log-install.txt
  404. echo "" | tee -a log-install.txt
  405. echo "Auto Script Installer OCS Panels Mod by Clrkz" | tee -a log-install.txt
  406. echo " (http://bytehax.blogspot.com/ - fb.com/143Clarkz) " | tee -a log-install.txt
  407. echo "" | tee -a log-install.txt
  408. echo "Thanks " | tee -a log-install.txt
  409. echo "" | tee -a log-install.txt
  410. echo "Installation Log --> /root/log-install.txt" | tee -a log-install.txt
  411. echo "=======================================================" | tee -a log-install.txt
  412. cd ~/
  413. rm -f /root/VPSnOCScrptZ.sh
  414. #rm -f /root/ocspanel.sh