Skip to content

Commit

Permalink
Merge pull request #1 from titel-media/get-it-installed
Browse files Browse the repository at this point in the history
Get it installed and connecting
  • Loading branch information
duksis authored Feb 11, 2020
2 parents 7c30634 + d7a6f8e commit 56a89f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ The following environment variables need to be set in CircleCI either directly o

- VPN_CONFIG

Variable has to contain a Base64 encoded OpenVPN config file
Variable has to contain a Base64 encoded OpenVPN config file eg. `.ovpn` format

- VPN_LOGIN

Variable has to contain a Base64 encoded username and password separated with a newline


See [CircleCI Documentation](https://circleci.com/docs/2.0/env-vars) for instructions on how you would set this up.
Expand Down
18 changes: 14 additions & 4 deletions orb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,35 @@ commands:
steps:
- run:
name: Install OpenVPN
command: sudo apt-get install --upgrade openvpn
command: |
# There seems to be a bug with the openvpn aptrepo sources
sudo apt-get update # for apt-get to recognise openvpn
sudo apt-get remove openvpn # remove ubuntu aptrepo source
sudo apt-get update
sudo apt-get install openvpn -y
connect:
description: "Connect to OpenVPN"
parameters:
config:
description: |
"ENV var name containing OpenVPN client config file content base64 encoded"
"ENV var name containing OpenVPN client .ovpn config file content base64 encoded"
type: env_var_name
default: VPN_CONFIG
login:
description: |
"ENV var name containing OpenVPN newline separated username and password base64 encoded"
type: env_var_name
default: VPN_LOGIN
steps:
- run:
name: Init VPN
command: |
echo ${<<parameters.config>>:?} | base64 --decode >> config.ovpn
echo ${<<parameters.login>>:?} | base64 --decode >> vpn.login
- run:
name: Connect to VPN
command: |
sudo openvpn --config config.ovpn > openvpn.log 2>&1 &
sudo /bin/bash -c 'echo "nameserver 10.255.0.2" > /run/resolvconf/resolv.conf'
sudo openvpn --config config.ovpn --auth-user-pass vpn.login > openvpn.log 2>&1 &
while [ -n "$(ip addr show tun0 2>&1 > /dev/null)" ]; do
sleep 0.1;
done
Expand Down

0 comments on commit 56a89f4

Please sign in to comment.