add-pptp.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. source /var/lib/premium-script/ipvps.conf
  3. if [[ "$IP" = "" ]]; then
  4. PUBLIC_IP=$(wget -qO- ipinfo.io/ip);
  5. else
  6. PUBLIC_IP=$IP
  7. fi
  8. until [[ $VPN_USER =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
  9. read -rp "Username: " -e VPN_USER
  10. CLIENT_EXISTS=$(grep -w $VPN_USER /var/lib/premium-script/data-user-pptp | wc -l)
  11. if [[ ${CLIENT_EXISTS} == '1' ]]; then
  12. echo ""
  13. echo "A client with the specified name was already created, please choose another name."
  14. exit 1
  15. fi
  16. done
  17. read -p "Password: " VPN_PASSWORD
  18. read -p "Expired (days): " masaaktif
  19. exp=`date -d "$masaaktif days" +"%Y-%m-%d"`
  20. clear
  21. # Add or update VPN user
  22. cat >> /etc/ppp/chap-secrets <<EOF
  23. "$VPN_USER" pptpd "$VPN_PASSWORD" *
  24. EOF
  25. # Update file attributes
  26. chmod 600 /etc/ppp/chap-secrets*
  27. echo -e "### $VPN_USER $exp">>"/var/lib/premium-script/data-user-pptp"
  28. cat <<EOF
  29. ================================
  30. PPTP VPN
  31. Server IP : $PUBLIC_IP
  32. Username : $VPN_USER
  33. Password : $VPN_PASSWORD
  34. Expired On : $exp
  35. =================================
  36. EOF