balena-supervisor/tools/dind/resin-vars
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

60 lines
1.7 KiB
Bash

#!/bin/bash
help () {
cat << EOF
Script for setting resin shell environment
resin-vars [options]
Options:
-h, --help
Display this help and exit.
-c, --config-path CONFIG_PATH
Use a non default config.json file.
Default: /mnt/conf/config.json
EOF
}
# Parse arguments
while [[ $# > 0 ]]; do
key=$1
case $key in
-h|--help)
help
exit 0
;;
-c|--config-path)
CONFIG_PATH=$2
shift
;;
*)
echo "[WARNING] $0 : Argument '$1' unknown. Ignoring."
;;
esac
shift
done
# Default values
if [ -z "$CONFIG_PATH" ]; then
CONFIG_PATH=/mnt/conf/config.json
fi
# If config.json provides redefinitions for our vars let us rewrite their
# runtime value
if [ -f $CONFIG_PATH ]
then
API_ENDPOINT=$(jq --raw-output ".apiEndpoint" $CONFIG_PATH)
DELTA_ENDPOINT=$(jq --raw-output ".deltaEndpoint" $CONFIG_PATH)
LISTEN_PORT=$(jq --raw-output ".listenPort" $CONFIG_PATH)
MIXPANEL_TOKEN=$(jq --raw-output ".mixpanelToken" $CONFIG_PATH)
PUBNUB_PUBLISH_KEY=$(jq --raw-output ".pubnubPublishKey" $CONFIG_PATH)
PUBNUB_SUBSCRIBE_KEY=$(jq --raw-output ".pubnubSubscribeKey" $CONFIG_PATH)
REGISTRY_ENDPOINT=$(jq --raw-output ".registryEndpoint" $CONFIG_PATH)
VPN_ENDPOINT=$(jq --raw-output ".vpnEndpoint" $CONFIG_PATH)
if [ -z "$API_ENDPOINT" -o -z "$LISTEN_PORT" -o -z "$MIXPANEL_TOKEN" -o -z "$PUBNUB_PUBLISH_KEY" -o -z "$PUBNUB_SUBSCRIBE_KEY" -o -z "$REGISTRY_ENDPOINT" -o -z "$VPN_ENDPOINT" ]; then
echo "[WARNING] $0 : Couldn't read some variables from $CONFIG_PATH"
fi
else
echo "[WARNING] $0 : '$CONFIG_PATH' not found."
fi