add-ss.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ifconfig.me/ip);
  6. echo "Checking VPS"
  7. clear
  8. IP=$(wget -qO- ifconfig.me/ip);
  9. lastport1=$(grep "port_tls" /etc/shadowsocks-libev/akun.conf | tail -n1 | awk '{print $2}')
  10. lastport2=$(grep "port_http" /etc/shadowsocks-libev/akun.conf | tail -n1 | awk '{print $2}')
  11. if [[ $lastport1 == '' ]]; then
  12. tls=2443
  13. else
  14. tls="$((lastport1+1))"
  15. fi
  16. if [[ $lastport2 == '' ]]; then
  17. http=3443
  18. else
  19. http="$((lastport2+1))"
  20. fi
  21. echo ""
  22. echo "Masukkan password"
  23. until [[ $user =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
  24. echo "Name : Create Shadowsocks Account"
  25. echo "===========================" | lolcat
  26. read -rp "Password: " -e user
  27. CLIENT_EXISTS=$(grep -w $user /etc/shadowsocks-libev/akun.conf | wc -l)
  28. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  29. echo ""
  30. echo "A client with the specified name was already created, please choose another name."
  31. exit 1
  32. fi
  33. done
  34. read -p "Expired (hari): " masaaktif
  35. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  36. cat > /etc/shadowsocks-libev/$user-tls.json<<END
  37. {
  38. "server":"0.0.0.0",
  39. "server_port":$tls,
  40. "password":"$user",
  41. "timeout":60,
  42. "method":"aes-256-cfb",
  43. "fast_open":true,
  44. "no_delay":true,
  45. "nameserver":"8.8.8.8",
  46. "mode":"tcp_and_udp",
  47. "plugin":"obfs-server",
  48. "plugin_opts":"obfs=tls"
  49. }
  50. END
  51. cat > /etc/shadowsocks-libev/$user-http.json <<-END
  52. {
  53. "server":"0.0.0.0",
  54. "server_port":$http,
  55. "password":"$user",
  56. "timeout":60,
  57. "method":"aes-256-cfb",
  58. "fast_open":true,
  59. "no_delay":true,
  60. "nameserver":"8.8.8.8",
  61. "mode":"tcp_and_udp",
  62. "plugin":"obfs-server",
  63. "plugin_opts":"obfs=http"
  64. }
  65. END
  66. chmod +x /etc/shadowsocks-libev/$user-tls.json
  67. chmod +x /etc/shadowsocks-libev/$user-http.json
  68. systemctl start shadowsocks-libev-server@$user-tls.service
  69. systemctl enable shadowsocks-libev-server@$user-tls.service
  70. systemctl start shadowsocks-libev-server@$user-http.service
  71. systemctl enable shadowsocks-libev-server@$user-http.service
  72. tmp1=$(echo -n "aes-256-cfb:${user}@${IP}:$tls" | base64 -w0)
  73. tmp2=$(echo -n "aes-256-cfb:${user}@${IP}:$http" | base64 -w0)
  74. linkss1="ss://${tmp1}?plugin=obfs-local;obfs=tls;obfs-host=bing.com"
  75. linkss2="ss://${tmp2}?plugin=obfs-local;obfs=http;obfs-host=bing.com"
  76. echo -e "### $user $exp
  77. port_tls $tls
  78. port_http $http">>"/etc/shadowsocks-libev/akun.conf"
  79. service cron restart
  80. clear
  81. echo -e ""
  82. echo -e "Shadowsocks"
  83. echo -e "===========================" | lolcat
  84. echo -e "IP/Host : $IP"
  85. echo -e "Port OBFS TLS : $tls"
  86. echo -e "Port OBFS HTTP : $http"
  87. echo -e "Password : $user"
  88. echo -e "Method : aes-256-cfb"
  89. echo -e "Expired On : $exp"
  90. echo -e "===========================" | lolcat
  91. echo -e "Link OBFS TLS : $linkss1"
  92. echo -e "===========================" | lolcat
  93. echo -e "Link OBFS HTTP : $linkss2"
  94. echo -e "===========================" | lolcat