Update openvpn-install.sh

This commit is contained in:
hadish777 2020-08-13 16:32:00 +04:30 committed by GitHub
parent 423419de74
commit ae6e832873
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -703,12 +703,12 @@ function installOpenVPN() {
esac
# Generate a random, alphanumeric identifier of 16 characters for CN and one for server name
SERVER_CN="cn_$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)"
echo "$SERVER_CN" >SERVER_CN_GENERATED
SERVER_CON="con_$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)"
echo "$SERVER_CON" >SERVER_CON_GENERATED
SERVER_NAME="server_$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)"
echo "$SERVER_NAME" >SERVER_NAME_GENERATED
echo "set_var EASYRSA_REQ_CN $SERVER_CN" >>vars
echo "set_var EASYRSA_REQ_CON $SERVER_CON" >>vars
# Create the PKI, set up the CA, the DH params and the server certificate
./easyrsa init-pki
@ -1061,7 +1061,7 @@ function newClient() {
read -rp "Select an option [1-2]: " -e -i 1 PASS
done
CLIENTEXISTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c -E "/CN=$CLIENT\$")
CLIENTEXISTS=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep -c -E "/CON=$CLIENT\$")
if [[ $CLIENTEXISTS == '1' ]]; then
echo ""
echo "The specified client CN was already found in easy-rsa, please choose another name."