2014-07-01 05:43:00 +00:00
|
|
|
#!/bin/bash
|
2014-06-04 18:13:59 +00:00
|
|
|
|
|
|
|
#
|
2014-07-06 04:25:00 +00:00
|
|
|
# Initialize the EasyRSA PKI
|
2014-06-04 18:13:59 +00:00
|
|
|
#
|
|
|
|
|
2015-02-28 10:45:31 +00:00
|
|
|
if [ "$DEBUG" == "1" ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
2014-06-04 18:13:59 +00:00
|
|
|
|
2014-07-06 01:51:58 +00:00
|
|
|
source "$OPENVPN/ovpn_env.sh"
|
2014-07-01 05:43:00 +00:00
|
|
|
|
2014-07-06 04:25:00 +00:00
|
|
|
# Specify "nopass" as arg[2] to make the CA insecure (not recommended!)
|
|
|
|
nopass=$1
|
2014-06-05 00:07:07 +00:00
|
|
|
|
2023-08-09 17:49:38 +00:00
|
|
|
/usr/share/easy-rsa/easyrsa init-pki
|
|
|
|
/usr/share/easy-rsa/easyrsa build-ca $nopass
|
|
|
|
/usr/share/easy-rsa/easyrsa gen-dh
|
2016-06-23 10:20:13 +00:00
|
|
|
openvpn --genkey --secret $EASYRSA_PKI/ta.key
|
2014-06-04 18:13:59 +00:00
|
|
|
|
2014-06-04 18:15:43 +00:00
|
|
|
# Was nice to autoset, but probably a bad idea in practice, users should
|
|
|
|
# have to explicitly specify the common name of their server
|
|
|
|
#if [ -z "$cn"]; then
|
|
|
|
# #TODO: Handle IPv6 (when I get a VPS with IPv6)...
|
|
|
|
# ip4=$(dig +short myip.opendns.com @resolver1.opendns.com)
|
|
|
|
# ptr=$(dig +short -x $ip4 | sed -e 's:\.$::')
|
|
|
|
#
|
|
|
|
# [ -n "$ptr" ] && cn=$ptr || cn=$ip4
|
|
|
|
#fi
|
2014-06-04 18:13:59 +00:00
|
|
|
|
2014-06-05 00:07:07 +00:00
|
|
|
# For a server key with a password, manually init; this is autopilot
|
2023-08-09 17:49:38 +00:00
|
|
|
/usr/share/easy-rsa/easyrsa build-server-full "$OVPN_CN" nopass
|
2017-05-02 14:42:39 +00:00
|
|
|
|
|
|
|
# Generate the CRL for client/server certificates revocation.
|
2023-08-09 17:49:38 +00:00
|
|
|
/usr/share/easy-rsa/easyrsa gen-crl
|