balena-supervisor/tools/dind/vpn-init
Pablo Carranza Velez 0078c299b4 dind: Set DELTA_ENDPOINT, insert variant into os-release, and fix vpn apikeys
Setting DELTA_ENDPOINT as meta-resin does allows the dev dind supervisor to use the correct
delta server.

Inserting a VARIANT_ID into /etc/os-release allows treating this device as a dev build of Resin OS
(and avoids an unhandled exception).

Changing the precedence for device/provisioning apikeys in the vpn-init script allows the device
to connect to the VPN when a key exchange is still pending (as meta-resin does - though this is getting
replaced by watching config.json for changes).

This at least makes the development supervisor functional for now, but I'll work on improving the dind setup soon.

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
2017-06-30 22:59:02 -07:00

17 lines
499 B
Bash
Executable File

#!/bin/bash
source /usr/src/app/resin-vars
sed --expression="s/#{VPN_ENDPOINT}/${VPN_ENDPOINT}/" /etc/openvpn/client.conf.tmpl > /etc/openvpn/client.conf
while true; do
if [ `jq ".uuid | length" $CONFIG_PATH` -eq 0 ]; then
echo "UUID missing from config file, VPN cannot connect"
sleep 2
else
read uuid api_key <<<$(jq -r '.uuid,.apiKey // .deviceApiKey' $CONFIG_PATH)
mkdir -p /var/volatile/
echo $uuid > /var/volatile/vpnfile
echo $api_key >> /var/volatile/vpnfile
break
fi
done