blob: b53a939df0cd350335bcc4ee1e289d29ddae527c [file] [log] [blame]
Zack Williamsba5c9d32022-06-05 21:49:18 -07001#!/usr/bin/env bash
2
3set -xeu -o pipefail
4
5VPN_USER=$1
6
7VPN_SITE=${VPN_SITE:-example}
8
Zack Williams003658b2022-10-25 11:13:06 -07009# where PKI is generated are kept, same variable as Makefile
10export BASE_DIR=${BASE_DIR:-onf_pki}
11
Zack Williamsba5c9d32022-06-05 21:49:18 -070012export IM_CA_NAME=openvpn_ca
13export LEAF_PURPOSE=client_cert_ext
14
15export LEAF_KEYPAIR=${VPN_USER}
16export LEAF_EMAIL=${LEAF_EMAIL:-"${VPN_USER}@opennetworking.org"}
17export LEAF_SAN="email:${LEAF_EMAIL}"
18
Zack Williams003658b2022-10-25 11:13:06 -070019make ${BASE_DIR}/certout/${VPN_USER}.pem
Zack Williamsba5c9d32022-06-05 21:49:18 -070020
21# build config
22VPN_CONFIG=openvpn/${VPN_USER}_${VPN_SITE}.ovpn
23cat openvpn/generic_${VPN_SITE}.ovpn > $VPN_CONFIG
24
25cat << EOKEY >> $VPN_CONFIG
26
27# client key
28<key>
29EOKEY
30
31# add key
Zack Williams003658b2022-10-25 11:13:06 -070032cat ${BASE_DIR}/certout/${VPN_USER}.key >> $VPN_CONFIG
Zack Williamsba5c9d32022-06-05 21:49:18 -070033
34cat << EOCERT >> $VPN_CONFIG
35</key>
36
37# client cert
38<cert>
39EOCERT
40
41# add pem
Zack Williams003658b2022-10-25 11:13:06 -070042cat ${BASE_DIR}/certout/${VPN_USER}.pem >> $VPN_CONFIG
Zack Williamsba5c9d32022-06-05 21:49:18 -070043
44cat << EOF >> $VPN_CONFIG
45</cert>
46EOF