#!/bin/bash if [ "$#" -lt 3 ]; then echo "Usage: $0 workspace from-stack to-stack" exit 1 fi set -eu stackSrc="$2" stackTo="$3" cmd="bl --workspace $1 --stack-admin" config="$($cmd --stack "$stackSrc" get)" getComponentType() { $cmd --stack "$stackSrc" component list | grep "$1" | awk '{print $2}' } bl stack create "$stackTo" for c in $($cmd --stack "$stackSrc" component list | tail -n +2 | awk '{print $1}'); do componentName="$(echo "$c" | tr '[:upper:]' '[:lower:]')" echo "$config" | \ jq --arg c "$c" '.Component[$c].Settings' | \ $cmd --stack "$stackTo" install -f - "$componentName" "$(getComponentType "$c")" || true done