Path: blob/main/docs/sources/flow/tutorials/assets/generate.sh
4096 views
#!/usr/bin/env bash12# This script generates runt.sh script that pulls down the needed files and runs them for the tutorials themselves.3# This needs to be reran anytime new tutorials are added with new docker composes.4# The runt.sh file is meant to download all the needed files for the example and for them to be used.56echo "#!/usr/bin/env bash" > runt.sh7echo "mkdir ./tutorials" >> runt.sh8echo "cd ./tutorials || exit" >> runt.sh91011# Instead of `for find .` doing it this way due to https://www.shellcheck.net/wiki/SC2044.12while IFS= read -r -d '' i13do14# Ignore current directory, png and ds_store files.15if [[ $i == "." || $i == "./.DS_Store" || $i == *.png || $i == *.sh ]];16then17continue18fi19# If this is a directory create the directory ignoring if it already exists (-p).20if [ -d "$i" ];21then22echo "mkdir -p $i" >> runt.sh23else24# Trim the '.' off the beginning, the file is './assets/file.flow' and need to remove '.'.25trimName="${i:1}"26# TODO at some point change this to release.27echo "curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets$trimName -o $i" >> runt.sh28fi29done < <(find . -print0)3031# Always pull the newest.32# TODO at some point change this from main.33echo "docker pull grafana/agent:main " >> runt.sh34echo "CONFIG_FILE=\$1 docker-compose -f ./docker-compose.yaml up" >> runt.sh353637