#!/bin/bash
# First argument: Client identifier
CONFIG_NAME=$1
BASE_CONFIG=template_client_config.ovpn
OUTPUT=$CONFIG_NAME.ovpn
if [ -z "$CONFIG_NAME" ]; then
echo "\$CONFIG_NAME is empty"
echo "Please specify client config name. --> exit!"
exit 1
else
echo "Make OpenVPN client config for: $CONFIG_NAME"
fi
if [ -d $CONFIG_NAME ]; then
echo "Generating $OUTPUT"
cat ${BASE_CONFIG} \
<(echo -e '') \
$CONFIG_NAME/ca.crt \
<(echo -e '\n') \
$CONFIG_NAME/$CONFIG_NAME.crt \
<(echo -e '\n') \
$CONFIG_NAME/$CONFIG_NAME.key \
<(echo -e '\n') \
$CONFIG_NAME/tls-auth.key \
<(echo -e '') \
> $CONFIG_NAME/$CONFIG_NAME.ovpn
else
echo "ERROR: Folder for $CONFIG_NAME not found --> exit!"
fi