Open AndreMaz opened 2 years ago
Hello @AndreMaz , I made the following script to solve the problem you describe:
`#!/bin/bash
if [ "$#" -lt 2 ]; then
echo "Uso: $0
FLEET_NAME="$1" ENV_FILE="$2" shift 2 SERVICE_ARRAY=("$@")
for SERVICE_NAME in "${SERVICE_ARRAY[@]}"; do while IFS= read -r line || [ -n "$line" ]; do if [ -n "$line" ]; then IFS='=' read -r var value <<< "$line" echo "balena env add --fleet \"$FLEET_NAME\" $var $value --service \"$SERVICE_NAME\"" balena env add --fleet "$FLEET_NAME" $var $value --service "$SERVICE_NAME" fi done < "$ENV_FILE" done `
How to avoid containers multiple restarts when variables are a lot?
Problem: Currently the only way to add an env. var via CLI is by using
env add
command, which only allows to set a single variable at the time. This approach is not very efficient when there are several env. vars.Possible solution: It would be nice to be able to read several vars from an
.env
file and add them to a Fleet/Device. For example,balena end add --file </path/to/.env>
Context: CLI version: 13.3.0