2015-06-02 12:47:33 +00:00
|
|
|
#!/bin/bash
|
2015-09-07 19:51:00 +00:00
|
|
|
source /usr/src/app/resin-vars
|
2015-08-28 14:06:27 +00:00
|
|
|
sed --expression="s/#{VPN_ENDPOINT}/${VPN_ENDPOINT}/" /etc/openvpn/client.conf.tmpl > /etc/openvpn/client.conf
|
|
|
|
|
2015-06-02 12:47:33 +00:00
|
|
|
while true; do
|
|
|
|
if [ `jq ".uuid | length" $CONFIG_PATH` -eq 0 ]; then
|
|
|
|
echo "UUID missing from config file, VPN cannot connect"
|
|
|
|
sleep 2
|
|
|
|
else
|
2016-07-30 00:46:10 +00:00
|
|
|
read uuid api_key <<<$(jq -r '.uuid,.deviceApiKey // .apiKey' $CONFIG_PATH)
|
2015-06-02 12:47:33 +00:00
|
|
|
mkdir -p /var/volatile/
|
|
|
|
echo $uuid > /var/volatile/vpnfile
|
|
|
|
echo $api_key >> /var/volatile/vpnfile
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|