add-ssr.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- icanhazip.com);
  6. echo "Script By geo"
  7. clear
  8. IP=$(wget -qO- icanhazip.com);
  9. echo "Please enter the username you want to set (do not repeat, does not support Chinese, will be reported incorrect!)"
  10. read -e -p "(Default: ):" ssr_user
  11. CLIENT_EXISTS=$(grep -w $ssr_user /usr/local/shadowsocksr/akun.conf | wc -l)
  12. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  13. echo ""
  14. echo "A client with the specified name was already created, please choose another name."
  15. exit 1
  16. fi
  17. read -p "Expired (days): " masaaktif
  18. exp=`date -d "$masaaktif days" +"%d-%m-%Y"`
  19. created=`date -d "0 days" +"%d-%m-%Y"`
  20. lastport=$(cat /usr/local/shadowsocksr/mudb.json | grep '"port": ' | tail -n1 | awk '{print $2}' | cut -d "," -f 1 | cut -d ":" -f 1 )
  21. if [[ $lastport == '' ]]; then
  22. ssr_port=1443
  23. else
  24. ssr_port=$((lastport+1))
  25. fi
  26. ssr_password="$ssr_user"
  27. ssr_method="aes-256-cfb"
  28. ssr_protocol="origin"
  29. ssr_obfs="tls1.2_ticket_auth_compatible"
  30. ssr_protocol_param="2"
  31. ssr_speed_limit_per_con=0
  32. ssr_speed_limit_per_user=0
  33. ssr_transfer="838868"
  34. ssr_forbid="bittorrent"
  35. cd /usr/local/shadowsocksr
  36. match_add=$(python mujson_mgr.py -a -u "${ssr_user}" -p "${ssr_port}" -k "${ssr_password}" -m "${ssr_method}" -O "${ssr_protocol}" -G "${ssr_protocol_param}" -o "${ssr_obfs}" -s "${ssr_speed_limit_per_con}" -S "${ssr_speed_limit_per_user}" -t "${ssr_transfer}" -f "${ssr_forbid}"|grep -w "add user info")
  37. cd
  38. echo -e "${Info} Penambahan user berhasil [username: ${ssr_user}]"
  39. echo -e "### $ssr_user $exp" >> /usr/local/shadowsocksr/akun.conf
  40. tmp1=$(echo -n "${ssr_password}" | base64 -w0 | sed 's/=//g;s/\//_/g;s/+/-/g')
  41. SSRobfs=$(echo ${ssr_obfs} | sed 's/_compatible//g')
  42. tmp2=$(echo -n "$IP:${ssr_port}:${ssr_protocol}:${ssr_method}:${SSRobfs}:${tmp1}/obfsparam=" | base64 -w0)
  43. ssr_link="ssr://${tmp2}"
  44. /etc/init.d/ssrmu restart
  45. service cron restart
  46. IP=$(wget -qO- ifconfig.co);
  47. clear && echo && echo "===================================================" && echo
  48. echo -e " User [${ssr_user}] configuration info:"
  49. echo -e " IP : ${IP}"
  50. echo -e " Port : ${ssr_port}"
  51. echo -e " Password : ${ssr_password}"
  52. echo -e " Encryption : ${ssr_method}"
  53. echo -e " Protocol : ${Red_font_prefix}${ssr_protocol}"
  54. echo -e " Obfs : ${Red_font_prefix}${ssr_obfs}"
  55. echo -e " Device limit : ${ssr_protocol_param}"
  56. echo -e "Created : $created"
  57. echo -e "Expired : $exp"
  58. echo -e " ==================================================="
  59. echo -e " Link SSR : ${ssr_link}"
  60. echo -e " ==================================================="
  61. echo -e ""
  62. echo -e ""