mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-29 18:18:52 +00:00
59 lines
1.6 KiB
Plaintext
59 lines
1.6 KiB
Plaintext
|
#!/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)
|
||
|
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
|