setup.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. clear
  3. RED="\033[31m" # Error message
  4. GREEN="\033[32m" # Success message
  5. YELLOW="\033[33m" # Warning message
  6. BLUE="\033[36m" # Info message
  7. RESET='\033[0m'
  8. if [ "$EUID" -ne 0 ]; then
  9. echo -e "${RED} Anda tiada kebenaran untuk menjalankan skrip ini! ${RESET}"
  10. exit 1
  11. fi
  12. echo
  13. echo -e "${BLUE} Sebelum meneruskan persediaan dan pemasangan di ${RESET}"
  14. echo -e "${BLUE} dalam pelayan anda, kami perlu bertanya anda ${RESET}"
  15. echo -e "${BLUE} beberapa soalan dahulu, maklumat ini diperlukan ${RESET}"
  16. echo -e "${BLUE} untuk pemasangan pakej dalam pelayan anda. ${RESET}"
  17. echo
  18. read -p "Sila masukkan nama domain: " DomainName
  19. read -p "Sila masukkan alamat emel: " EmailAddr
  20. read -p "Sila masukkan nama pengguna: " UserName
  21. read -p "Sila masukkan kata laluan: " UserPass
  22. echo
  23. echo "DOMAIN=$DomainName" >/usr/local/.environment
  24. echo "EMAIL=$EmailAddr" >>/usr/local/.environment
  25. echo "USERNAME=$UserName" >>/usr/local/.environment
  26. echo "PASSWORD=$UserPass" >>/usr/local/.environment
  27. userName=$(cat /usr/local/.environment | grep 'USERNAME' | cut -d '=' -f 2)
  28. userPass=$(cat /usr/local/.environment | grep 'PASSWORD' | cut -d '=' -f 2)
  29. useradd $userName
  30. usermod -s /bin/false $userName
  31. echo -e "$userPass\n$userPass" | passwd $userName &>/dev/null
  32. sleep 10
  33. clear
  34. if [[ -s /etc/selinux/config ]] && grep 'SELINUX=enforcing' /etc/selinux/config; then
  35. sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config
  36. setenforce 0
  37. fi
  38. echo 'deb http://ftp.debian.org/debian buster-backports main' >/etc/apt/sources.list.d/buster-backports.list
  39. apt-get update && apt-get -y upgrade
  40. dependencies=('r-base' 'build-essential' 'cmake' 'automake' 'curl' 'git' 'libnss3' 'socat' 'uuid-runtime' 'jq' 'qrencode')
  41. for dep in "${dependencies[@]}"; do
  42. apt-get install -y $dep
  43. done
  44. timedatectl set-timezone Asia/Kuala_Lumpur
  45. add-shell /bin/false
  46. add-shell /usr/bin/false
  47. add-shell /usr/sbin/nologin
  48. echo "" >/etc/motd
  49. wget -q -O /etc/update-motd.d/10-uname 'https://raw.githubusercontent.com/cybertize/debian/buster/sources/banner'
  50. wget -q -O /etc/issue.net 'https://raw.githubusercontent.com/cybertize/debian/buster/sources/message'
  51. echo '# Configuration file for setting system variables
  52. kernel.printk = 3 4 1 3
  53. net.ipv4.conf.default.rp_filter=1
  54. net.ipv4.conf.all.rp_filter=1
  55. net.ipv6.conf.all.disable_ipv6 = 1
  56. net.ipv6.conf.default.disable_ipv6 = 1
  57. net.ipv6.conf.lo.disable_ipv6 = 1
  58. net.ipv4.ip_forward=1
  59. #net.ipv6.conf.all.forwarding=1
  60. net.ipv4.conf.all.accept_redirects = 0
  61. net.ipv6.conf.all.accept_redirects = 0
  62. fs.file-max = 51200
  63. net.core.rmem_max = 67108864
  64. net.core.wmem_max = 67108864
  65. net.core.netdev_max_backlog = 250000
  66. net.core.somaxconn = 4096
  67. net.ipv4.tcp_syncookies = 1
  68. net.ipv4.tcp_tw_reuse = 1
  69. # net.ipv4.tcp_tw_recycle = 0
  70. net.ipv4.tcp_fin_timeout = 30
  71. net.ipv4.tcp_keepalive_time = 1200
  72. net.ipv4.ip_local_port_range = 10000 65000
  73. net.ipv4.tcp_max_syn_backlog = 8192
  74. net.ipv4.tcp_max_tw_buckets = 5000
  75. net.ipv4.tcp_fastopen = 3
  76. net.ipv4.tcp_mem = 25600 51200 102400
  77. net.ipv4.tcp_rmem = 4096 87380 67108864
  78. net.ipv4.tcp_wmem = 4096 65536 67108864
  79. net.ipv4.tcp_mtu_probing = 1
  80. net.ipv4.tcp_congestion_control = hybla' >/etc/sysctl.conf
  81. sysctl -p &>/dev/null
  82. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/nginx.sh' | bash
  83. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/dropbear.sh' | bash
  84. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/openvpn.sh' | bash
  85. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/shadowsocks.sh' | bash
  86. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/v2ray.sh' | bash
  87. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/xray.sh' | bash
  88. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/wireguard.sh' | bash
  89. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/ohpserver.sh' | bash
  90. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/websocket.sh' | bash
  91. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/stunnel.sh' | bash
  92. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/squid.sh' | bash
  93. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/naiveproxy.sh' | bash
  94. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/haproxy.sh' | bash
  95. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/privoxy.sh' | bash
  96. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/badvpn.sh' | bash
  97. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/webmin.sh' | bash
  98. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/packages/security.sh' | bash
  99. wget -q -O - 'https://raw.githubusercontent.com/cybertize/debian/buster/plugins/plugins.sh' | bash
  100. # cleanup files
  101. [[ -f /root/setup.sh ]] && rm -f setup.sh
  102. [[ -d /root/v2ray.sh ]] && rm -f v2ray.sh
  103. [[ -d /root/xray.sh ]] && rm -f xray.sh
  104. [[ -f /root/1.999.130.tar.gz ]] && rm -f 1.999.130.tar.gz
  105. [[ -d /root/badvpn-1.999.130 ]] && rm -r -f badvpn-1.999.130
  106. [[ -d /root/ddos-deflate-master ]] && rm -r -f ddos-deflate-master
  107. apt-get -qq update
  108. apt-get -qq -y upgrade
  109. apt-get -qq -y autoremove
  110. apt-get -qq -y autoclean
  111. clear
  112. echo
  113. echo -e "${GREEN} Tahniah, kami telah selesai dengan pemasangan ${RESET}"
  114. echo -e "${GREEN} pada pelayan anda. Jangan lupa untuk reboot ${RESET}"
  115. echo -e "${GREEN} sistem pelayan anda terlebih dahuulu. ${RESET}"
  116. echo -e "${GREEN} Langkah terakhir adalah dengan check status ${RESET}"
  117. echo -e "${GREEN} services pakej pelayan anda. ${RESET}"
  118. echo