VPSnOCSJanda.sh 15 KB

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