addpptp.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # SL
  3. # ==========================================
  4. # Color
  5. RED='\033[0;31m'
  6. NC='\033[0m'
  7. GREEN='\033[0;32m'
  8. ORANGE='\033[0;33m'
  9. BLUE='\033[0;34m'
  10. PURPLE='\033[0;35m'
  11. CYAN='\033[0;36m'
  12. LIGHT='\033[0;37m'
  13. # ==========================================
  14. # Getting
  15. MYIP=$(wget -qO- ipinfo.io/ip);
  16. echo "Checking VPS"
  17. IZIN=$( curl ipinfo.io/ip | grep $MYIP )
  18. if [ $MYIP = $MYIP ]; then
  19. echo -e "${NC}${GREEN}Permission Accepted...${NC}"
  20. else
  21. echo -e "${NC}${RED}Permission Denied!${NC}";
  22. echo -e "${NC}${LIGHT}Fuck You!!"
  23. exit 0
  24. fi
  25. clear
  26. if [[ "$IP" = "" ]]; then
  27. PUBLIC_IP=$(wget -qO- ipinfo.io/ip);
  28. else
  29. PUBLIC_IP=$IP
  30. fi
  31. source /var/lib/crot/ipvps.conf
  32. if [[ "$IP2" = "" ]]; then
  33. domain=$(cat /etc/xray/domain)
  34. else
  35. domain=$IP2
  36. fi
  37. until [[ $VPN_USER =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
  38. read -rp "Username : " -e VPN_USER
  39. CLIENT_EXISTS=$(grep -w $VPN_USER /var/lib/crot/data-user-pptp | wc -l)
  40. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  41. echo ""
  42. echo -e "Username ${RED}${VPN_USER}${NC} Already On VPS Please Choose Another"
  43. exit 1
  44. fi
  45. done
  46. read -p "Password : " VPN_PASSWORD
  47. read -p "Expired (Days) : " masaaktif
  48. hariini=`date -d "0 days" +"%Y-%m-%d"`
  49. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  50. clear
  51. # Add or update VPN user
  52. cat >> /etc/ppp/chap-secrets <<EOF
  53. "$VPN_USER" pptpd "$VPN_PASSWORD" *
  54. EOF
  55. # Update file attributes
  56. chmod 600 /etc/ppp/chap-secrets*
  57. echo -e "### $VPN_USER $exp">>"/var/lib/crot/data-user-pptp"
  58. cat <<EOF
  59. ============================
  60. PPTP VPN
  61. ============================
  62. IP/Host : $PUBLIC_IP
  63. Domain : $domain
  64. Username : $VPN_USER
  65. Password : $VPN_PASSWORD
  66. Created : $hariini
  67. Expired : $exp
  68. ============================
  69. Script Mod By SL
  70. EOF