add-ssr.sh 2.4 KB

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