Merge pull request #126 from mediatemple/add_ovpn_listclients

adding ovpn_listclients script
This commit is contained in:
Kyle Manna 2016-05-11 21:43:42 -07:00
commit df63db02a0
3 changed files with 53 additions and 0 deletions

45
bin/ovpn_listclients Executable file
View File

@ -0,0 +1,45 @@
#!/bin/bash
if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
if ! source "$OPENVPN/ovpn_env.sh"; then
echo "Could not source $OPENVPN/ovpn_env.sh."
exit 1
fi
if [ -z "$EASYRSA_PKI" ]; then
export EASYRSA_PKI="$OPENVPN/pki"
fi
cd "$EASYRSA_PKI"
if [ -e crl.pem ]; then
cat ca.crt crl.pem > cacheck.pem
fi
echo "name,begin,end,status"
for name in issued/*.crt; do
path=$name
begin=$(openssl x509 -noout -startdate -in $path | awk -F= '{ print $2 }')
end=$(openssl x509 -noout -enddate -in $path | awk -F= '{ print $2 }')
name=${name%.crt}
name=${name#issued/}
if [ "$name" != "$OVPN_CN" ]; then
if [ -e crl.pem ]; then
if openssl verify -crl_check -CAfile cacheck.pem $path &> /dev/null; then
status="VALID"
else
status="REVOKED"
fi
else
status="VALID"
fi
echo "$name,$begin,$end,$status"
fi
done
if [ -e crl.pem ]; then
rm cacheck.pem
fi

View File

@ -9,6 +9,12 @@ The [`ovpn_getclient`](/bin/ovpn_getclient) can produce two different versions o
Note that some client software might be picky about which configuration format it accepts.
## Client List
See an overview of the configured clients, including revokation status:
docker run --rm -it --volumes-from $OVPN_DATA kylemanna/openvpn ovpn_listclients
## Batch Mode
If you have more than a few clients, you will want to generate and update your client configuration in batch. For this task the script [`ovpn_getclient_all`](/bin/ovpn_getclient_all) was written, which writes out the configuration for each client to a separate directory called `clients/$cn`.

View File

@ -20,6 +20,8 @@ docker run --volumes-from $OVPN_DATA --rm -it $IMG easyrsa build-client-full $CL
docker run --volumes-from $OVPN_DATA --rm $IMG ovpn_getclient $CLIENT | tee client/config.ovpn
docker run --volumes-from $OVPN_DATA --rm $IMG ovpn_listclients | grep $CLIENT
#
# Fire up the server
#