1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2024-11-30 09:16:41 +02:00
dockerfiles/openvpn/setup.sh
2016-09-19 13:04:07 +08:00

38 lines
969 B
Bash
Executable File

#!/bin/bash
#
# setup script for kylemanna/openvpn
#
OVPN_DIR=./ovpn
OVPN_SERVER=tcp://openvpn.easypi.info
mkdir -p $OVPN_DIR
select opt in server client revoke quit
do
if [[ $opt == "server" ]]
then
echo "setup server ..."
docker-compose run --rm openvpn ovpn_genconfig -u $OVPN_SERVER
docker-compose run --rm openvpn ovpn_initpki
elif [[ $opt == "client" ]]
then
echo "setup client ..."
read -p '>>> ' OVPN_CLIENT
docker-compose run --rm openvpn easyrsa build-client-full ${OVPN_CLIENT:?client is empty} nopass
docker-compose run --rm openvpn ovpn_getclient $OVPN_CLIENT > $OVPN_DIR/$OVPN_CLIENT.ovpn
elif [[ $opt == "revoke" ]]
then
echo "revoke client ..."
read -p '>>> ' OVPN_CLIENT
docker-compose run --rm openvpn easyrsa revoke ${OVPN_CLIENT:?client is empty}
docker-compose run --rm openvpn easyrsa gen-crl
elif [[ $opt == "quit" ]]
then
echo "bye"
exit
else
echo "invalid"
fi
done