12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #!/bin/bash
- red='\e[1;31m'
- green='\e[0;32m'
- NC='\e[0m'
- MYIP=$(wget -qO- icanhazip.com);
- echo "Script By geo"
- clear
- source /var/lib/premium-script/ipvps.conf
- if [[ "$IP" = "" ]]; then
- PUBLIC_IP=$(wget -qO- icanhazip.com);
- else
- PUBLIC_IP=$IP
- fi
- until [[ $VPN_USER =~ ^[a-zA-Z0-9_]+$ && ${CLIENT_EXISTS} == '0' ]]; do
- read -rp "Username: " -e VPN_USER
- CLIENT_EXISTS=$(grep -w $VPN_USER /var/lib/premium-script/data-user-pptp | wc -l)
- if [[ ${CLIENT_EXISTS} == '1' ]]; then
- echo ""
- echo "A client with the specified name was already created, please choose another name."
- exit 1
- fi
- done
- read -p "Password: " VPN_PASSWORD
- read -p "Expired (days): " masaaktif
- exp=`date -d "$masaaktif days" +"%d-%m-%Y"`
- created=`date -d "0 days" +"%d-%m-%Y"`
- clear
- # Add or update VPN user
- cat >> /etc/ppp/chap-secrets <<EOF
- "$VPN_USER" pptpd "$VPN_PASSWORD" *
- EOF
- # Update file attributes
- chmod 600 /etc/ppp/chap-secrets*
- echo -e "### $VPN_USER $exp">>"/var/lib/premium-script/data-user-pptp"
- cat <<EOF
- ================================
- PPTP VPN
- Server IP : $PUBLIC_IP
- Username : $VPN_USER
- Password : $VPN_PASSWORD
- Created : $created
- Expired : $exp
- =================================
- EOF
|