VPSJanda.sh 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. MYIP=$(wget -qO- ipv4.icanhazip.com);
  8. : '
  9. # check registered ip
  10. wget -q -O daftarip http://188.166.215.119:85/ocs/ip.txt
  11. if ! grep -w -q $MYIP daftarip; then
  12. echo "Sorry, only registered IPs can use this script!"
  13. if [[ $vps = "vps" ]]; then
  14. echo "Powered by Clrkz"
  15. else
  16. echo "Powered by Clrkz"
  17. fi
  18. rm -f /root/daftarip
  19. exit
  20. fi
  21. '
  22. # initialisasi var
  23. export DEBIAN_FRONTEND=noninteractive
  24. OS=`uname -m`;
  25. MYIP=$(wget -qO- ipv4.icanhazip.com);
  26. MYIP2="s/xxxxxxxxx/$MYIP/g";
  27. #detail nama perusahaan
  28. country=ID
  29. state=Manila
  30. locality=Manila
  31. organization=ByteHAX
  32. organizationalunit=IT
  33. commonname=bytehax.blogspot.com
  34. email=143Clarkz@gmail.com
  35. # go to root
  36. cd
  37. # disable ipv6
  38. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  39. sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
  40. # install wget and curl
  41. apt-get update;apt-get -y install wget curl;
  42. # set time GMT +7
  43. ln -fs /usr/share/zoneinfo/Asia/Manila /etc/localtime
  44. # set locale
  45. sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
  46. service ssh restart
  47. # set repo
  48. wget -O /etc/apt/sources.list "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/sources.list.debian7"
  49. wget "http://www.dotdeb.org/dotdeb.gpg"
  50. cat dotdeb.gpg | apt-key add -;rm dotdeb.gpg
  51. sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
  52. wget -qO - http://www.webmin.com/jcameron-key.asc | apt-key add -
  53. # update
  54. apt-get update
  55. # install webserver
  56. apt-get -y install nginx
  57. # install essential package
  58. apt-get -y install nano iptables dnsutils openvpn screen whois ngrep unzip unrar
  59. echo "clear" >> .bashrc
  60. echo 'echo -e " # ### ### /"' >> .bashrc
  61. echo 'echo -e " / /### / ### #/"' >> .bashrc
  62. echo 'echo -e " / / ###/ ## ##"' >> .bashrc
  63. echo 'echo -e " / ## ## ## ##"' >> .bashrc
  64. echo 'echo -e " / ### ## ##"' >> .bashrc
  65. echo 'echo -e "## ## ## ### /### ## /## ######"' >> .bashrc
  66. echo 'echo -e "## ## ## ###/ #### / ## / ### /#######"' >> .bashrc
  67. echo 'echo -e "## ## ## ## ###/ ##/ / / ##"' >> .bashrc
  68. echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
  69. echo 'echo -e "## ## ## ## ## / /"' >> .bashrc
  70. echo 'echo -e " ## ## ## ## ## ## ###"' >> .bashrc
  71. echo 'echo -e " ## # / ## ## ###### ###"' >> .bashrc
  72. echo 'echo -e " ### / ## ## ## ### ###"' >> .bashrc
  73. echo 'echo -e " ######/ ### / ### ## ### / ##"' >> .bashrc
  74. echo 'echo -e " ### ##/ ### ## ##/ ##"' >> .bashrc
  75. echo 'echo -e " /"' >> .bashrc
  76. echo 'echo -e " /"' >> .bashrc
  77. echo 'echo -e " /"' >> .bashrc
  78. echo 'echo -e " /"' >> .bashrc
  79. echo 'echo -e "welcome to the server $HOSTNAME" | lolcat' >> .bashrc
  80. echo 'echo -e "Script mod by Clrkz"' >> .bashrc
  81. echo 'echo -e "Type menu to display a list of commands"' >> .bashrc
  82. echo 'echo -e ""' >> .bashrc
  83. # install webserver
  84. cd
  85. rm /etc/nginx/sites-enabled/default
  86. rm /etc/nginx/sites-available/default
  87. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/nginx.conf"
  88. mkdir -p /home/vps/public_html
  89. echo "<pre>Setup by Clrkz</pre>" > /home/vps/public_html/index.html
  90. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/vps.conf"
  91. service nginx restart
  92. # install openvpn
  93. wget -O /etc/openvpn/openvpn.tar "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/openvpn-debian.tar"
  94. cd /etc/openvpn/
  95. tar xf openvpn.tar
  96. wget -O /etc/openvpn/1194.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/1194.conf"
  97. service openvpn restart
  98. sysctl -w net.ipv4.ip_forward=1
  99. sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
  100. iptables -t nat -I POSTROUTING -s 192.168.100.0/24 -o eth0 -j MASQUERADE
  101. iptables-save > /etc/iptables_yg_baru_dibikin.conf
  102. wget -O /etc/network/if-up.d/iptables "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/iptables"
  103. chmod +x /etc/network/if-up.d/iptables
  104. service openvpn restart
  105. # konfigurasi openvpn
  106. cd /etc/openvpn/
  107. wget -O /etc/openvpn/client.ovpn "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/client-1194.conf"
  108. sed -i $MYIP2 /etc/openvpn/client.ovpn;
  109. cp client.ovpn /home/vps/public_html/
  110. # install badvpn
  111. cd
  112. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw"
  113. if [ "$OS" == "x86_64" ]; then
  114. wget -O /usr/bin/badvpn-udpgw "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/badvpn-udpgw64"
  115. fi
  116. sed -i '$ i\screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300' /etc/rc.local
  117. chmod +x /usr/bin/badvpn-udpgw
  118. screen -AmdS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300
  119. # setting port ssh
  120. cd
  121. sed -i 's/Port 22/Port 22/g' /etc/ssh/sshd_config
  122. sed -i '/Port 22/a Port 444' /etc/ssh/sshd_config
  123. service ssh restart
  124. # install dropbear
  125. apt-get -y install dropbear
  126. sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
  127. sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=3128/g' /etc/default/dropbear
  128. sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-p 143"/g' /etc/default/dropbear
  129. echo "/bin/false" >> /etc/shells
  130. echo "/usr/sbin/nologin" >> /etc/shells
  131. service ssh restart
  132. service dropbear restart
  133. # install squid3
  134. cd
  135. apt-get -y install squid3
  136. wget -O /etc/squid3/squid.conf "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/squid3.conf"
  137. sed -i $MYIP2 /etc/squid3/squid.conf;
  138. service squid3 restart
  139. # install webmin
  140. cd
  141. apt-get -y install webmin
  142. sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  143. service webmin restart
  144. # install stunnel
  145. apt-get install stunnel4 -y
  146. cat > /etc/stunnel/stunnel.conf <<-END
  147. cert = /etc/stunnel/stunnel.pem
  148. client = no
  149. socket = a:SO_REUSEADDR=1
  150. socket = l:TCP_NODELAY=1
  151. socket = r:TCP_NODELAY=1
  152. [dropbear]
  153. accept = 443
  154. connect = 127.0.0.1:3128
  155. END
  156. #membuat sertifikat
  157. openssl genrsa -out key.pem 2048
  158. openssl req -new -x509 -key key.pem -out cert.pem -days 1095 \
  159. -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
  160. cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
  161. #konfigurasi stunnel
  162. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  163. /etc/init.d/stunnel4 restart
  164. # teks berwarna
  165. apt-get -y install ruby
  166. gem install lolcat
  167. # install fail2banapt-get -y install fail2ban;
  168. service fail2ban restart
  169. # install ddos deflate
  170. cd
  171. apt-get -y install dnsutils dsniff
  172. wget https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/ddos-deflate-master.zip
  173. unzip ddos-deflate-master.zip
  174. cd ddos-deflate-master
  175. ./install.sh
  176. rm -rf /root/ddos-deflate-master.zip
  177. # bannerrm /etc/issue.net
  178. wget -O /etc/issue.net "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/issue.net"
  179. sed -i 's@#Banner@Banner@g' /etc/ssh/sshd_config
  180. sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
  181. service ssh restart
  182. service dropbear restart
  183. #xml parser
  184. cd
  185. apt-get -y --force-yes -f install libxml-parser-perl
  186. # download script
  187. cd /usr/bin
  188. wget -O menu "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/menu.sh"
  189. wget -O usernew "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/usernew.sh"
  190. wget -O trial "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/trial.sh"
  191. wget -O delete "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/hapus.sh"
  192. wget -O check "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-login.sh"
  193. wget -O member "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/user-list.sh"
  194. wget -O restart "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/resvis.sh"
  195. wget -O speedtest "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/speedtest_cli.py"
  196. wget -O info "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/info.sh"
  197. wget -O about "https://raw.githubusercontent.com/Clrkz/VPSAutoScrptz/master/about.sh"
  198. echo "0 0 * * * root /sbin/reboot" > /etc/cron.d/reboot
  199. chmod +x menu
  200. chmod +x usernew
  201. chmod +x trial
  202. chmod +x delete
  203. chmod +x check
  204. chmod +x member
  205. chmod +x restart
  206. chmod +x speedtest
  207. chmod +x info
  208. chmod +x about
  209. # finishing
  210. cd
  211. chown -R www-data:www-data /home/vps/public_html
  212. service nginx start
  213. service openvpn restart
  214. service cron restart
  215. service ssh restart
  216. service dropbear restart
  217. service squid3 restart
  218. service webmin restart
  219. rm -rf ~/.bash_history && history -c
  220. echo "unset HISTFILE" >> /etc/profile
  221. # install neofetch
  222. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  223. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  224. apt-get update
  225. apt-get install neofetch
  226. echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | tee -a /etc/apt/sources.list
  227. curl "https://bintray.com/user/downloadSubjectPublicKey?username=bintray"| apt-key add -
  228. apt-get update
  229. apt-get install neofetch
  230. # info
  231. clear
  232. echo "Autoscript Include:" | tee log-install.txt
  233. echo "===========================================" | tee -a log-install.txt
  234. echo "" | tee -a log-install.txt
  235. echo "Service" | tee -a log-install.txt
  236. echo "-------" | tee -a log-install.txt
  237. echo "OpenSSH : 22, 444" | tee -a log-install.txt
  238. echo "Dropbear : 143, 3128" | tee -a log-install.txt
  239. echo "SSL : 443" | tee -a log-install.txt
  240. echo "Squid3 : 8000, 8080 (limit to IP SSH)" | tee -a log-install.txt
  241. echo "OpenVPN : TCP 1194 (client config : http://$MYIP:81/client.ovpn)" | tee -a log-install.txt
  242. echo "badvpn : badvpn-udpgw port 7300" | tee -a log-install.txt
  243. echo "nginx : 81" | tee -a log-install.txt
  244. echo "" | tee -a log-install.txt
  245. echo "Script" | tee -a log-install.txt
  246. echo "------" | tee -a log-install.txt
  247. echo "menu (Displays a list of available commands)" | tee -a log-install.txt
  248. echo "usernew (Creating an SSH Account)" | tee -a log-install.txt
  249. echo "trial (Create a Trial Account)" | tee -a log-install.txt
  250. echo "delete (Clearing SSH Account)" | tee -a log-install.txt
  251. echo "check (Check User Login)" | tee -a log-install.txt
  252. echo "member (Check Member SSH)" | tee -a log-install.txt
  253. echo "restart (Restart Service dropbear, webmin, squid3, openvpn and ssh)" | tee -a log-install.txt
  254. echo "reboot (Reboot VPS)" | tee -a log-install.txt
  255. echo "speedtest (Speedtest VPS)" | tee -a log-install.txt
  256. echo "info (System Information)" | tee -a log-install.txt
  257. echo "about (Information about auto install script)" | tee -a log-install.txt
  258. echo "" | tee -a log-install.txt
  259. echo "Other features" | tee -a log-install.txt
  260. echo "----------" | tee -a log-install.txt
  261. echo "Webmin : http://$MYIP:10000/" | tee -a log-install.txt
  262. echo "Timezone : Asia/Manila (GMT +7)" | tee -a log-install.txt
  263. echo "IPv6 : [off]" | tee -a log-install.txt
  264. echo "" | tee -a log-install.txt
  265. echo "Original Script by Fornesia, Rzengineer & Fawzya" | tee -a log-install.txt
  266. echo "Modified by Clrkz" | tee -a log-install.txt
  267. echo "" | tee -a log-install.txt
  268. echo "Installation Log --> /root/log-install.txt" | tee -a log-install.txt
  269. echo "" | tee -a log-install.txt
  270. echo "VPS AUTO REBOOT TIME HOURS 12 NIGHT" | tee -a log-install.txt
  271. echo "" | tee -a log-install.txt
  272. echo "===========================================" | tee -a log-install.txt
  273. cd
  274. rm -f /root/debian7.sh