1
0
mirror of https://github.com/vimagick/dockerfiles.git synced 2025-01-18 04:59:16 +02:00
dockerfiles/openvpn/setup.sh

38 lines
969 B
Bash
Raw Normal View History

2015-07-06 08:35:53 +08:00
#!/bin/bash
#
2016-09-19 13:04:07 +08:00
# setup script for kylemanna/openvpn
2015-07-06 08:35:53 +08:00
#
2015-07-16 17:55:42 +08:00
OVPN_DIR=./ovpn
2016-09-02 12:23:56 +08:00
OVPN_SERVER=tcp://openvpn.easypi.info
2015-07-06 08:35:53 +08:00
2015-07-16 17:55:42 +08:00
mkdir -p $OVPN_DIR
2016-09-02 12:23:56 +08:00
select opt in server client revoke quit
2015-07-06 08:35:53 +08:00
do
if [[ $opt == "server" ]]
then
echo "setup server ..."
2016-09-02 12:23:56 +08:00
docker-compose run --rm openvpn ovpn_genconfig -u $OVPN_SERVER
docker-compose run --rm openvpn ovpn_initpki
2015-07-06 08:35:53 +08:00
elif [[ $opt == "client" ]]
then
echo "setup client ..."
2015-07-16 17:55:42 +08:00
read -p '>>> ' OVPN_CLIENT
2016-09-02 12:23:56 +08:00
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
2015-09-01 11:00:28 +08:00
elif [[ $opt == "revoke" ]]
then
2016-09-02 12:23:56 +08:00
echo "revoke client ..."
2015-09-01 11:00:28 +08:00
read -p '>>> ' OVPN_CLIENT
2016-09-02 12:23:56 +08:00
docker-compose run --rm openvpn easyrsa revoke ${OVPN_CLIENT:?client is empty}
docker-compose run --rm openvpn easyrsa gen-crl
2015-07-06 08:35:53 +08:00
elif [[ $opt == "quit" ]]
then
echo "bye"
exit
else
echo "invalid"
fi
done