Bash build step with openvpn hangs build

#1

Hi,

I’m trying to connect to a VPN (due to IP whitelisting requirements of our test server). I couldn’t see a way to get the certificates required for the Bitrise VPN workflow step so instead I’ve modified the bash script for that step to accept the details I do have and used them in a “Script” workflow step.

However, when the step executes the Bitrise bot hangs/loses connection when it’s connecting to the VPN (I suspect it’s possibly successful in connecting to the VPN but that this action breaks the bot somehow?).

The Script step I’m using is:

`
sudo openvpn --client --dev tun --config test.ovpn --auth-user-pass password.txt --resolv-retry infinite --nobind --persist-key --persist-tun --comp-lzo --verb 3 > /dev/null 2>&1 &

sleep 5

if ifconfig -l | grep utun0 > /dev/null
then
echo “VPN connection succeeded”
else
echo “VPN connection failed!”
exit 1
fi
`

If I run the openvpn command locally it successfully connects to the VPN.

Any ideas what I’m doing wrong?

0 Likes

#2

It seems that openvpn client gets killed when script step finishes.
You need to send its process to background eg. by adding --daemon option.

1 Like

#3

Thanks for the suggestion but it doesn’t seem to help. I suspect that establishing the VPN kills the SSH session somehow…?

0 Likes

#4

Check If default route is not changed by received openvpn network configuration.

This is my script step content (working on Linux stack):

openvpn --daemon openvpn --status /run/openvpn.status 10 --config vpn.conf --writepid /run/openvpn.pid
echo -e "nameserver <internal DNS ip>\n$(cat /etc/resolv.conf)" > /etc/resolv.conf

and configuration fragment:

float
dev tun

remote-cert-tls server
resolv-retry infinite
nobind
persist-key
persist-tun
comp-lzo
verb 1
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

There is also openvpn step in the steplib.

0 Likes

closed #5

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

0 Likes