Add ansible role to configure openvpn
[infra/tools.git] / infra / configure_openvpn_client / playbooks / roles / vpn-client / files / make_config.sh
1 #!/bin/bash
2
3 # First argument: Client identifier
4 if [ -z "$1" ]
5   then
6     echo "Please provide the client identifier."
7     echo "   example: $0 <USER_NAME>.<ZONE_NAME>"
8     echo "   example: $0 jsmith.onap"
9     exit 1
10 fi
11
12 KEY_DIR="/root/openvpn-ca/client_configs/keys"
13 OUTPUT_DIR="/root/openvpn-ca/client_configs/files"
14 BASE_CONFIG="/root/openvpn-ca/client_configs/base.conf"
15
16 cat ${BASE_CONFIG} \
17     <(echo -e '<ca>') \
18     ${KEY_DIR}/ca.crt \
19     <(echo -e '</ca>\n<cert>') \
20     ${KEY_DIR}/"${1}".crt \
21     <(echo -e '</cert>\n<key>') \
22     ${KEY_DIR}/"${1}".key \
23     <(echo -e '</key>\n<tls-auth>') \
24     ${KEY_DIR}/ta.key \
25     <(echo -e '</tls-auth>') \
26     > ${OUTPUT_DIR}/"${1}".ovpn