Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/docs/sources/flow/tutorials/assets/generate.sh
4096 views
1
#!/usr/bin/env bash
2
3
# This script generates runt.sh script that pulls down the needed files and runs them for the tutorials themselves.
4
# This needs to be reran anytime new tutorials are added with new docker composes.
5
# The runt.sh file is meant to download all the needed files for the example and for them to be used.
6
7
echo "#!/usr/bin/env bash" > runt.sh
8
echo "mkdir ./tutorials" >> runt.sh
9
echo "cd ./tutorials || exit" >> runt.sh
10
11
12
# Instead of `for find .` doing it this way due to https://www.shellcheck.net/wiki/SC2044.
13
while IFS= read -r -d '' i
14
do
15
# Ignore current directory, png and ds_store files.
16
if [[ $i == "." || $i == "./.DS_Store" || $i == *.png || $i == *.sh ]];
17
then
18
continue
19
fi
20
# If this is a directory create the directory ignoring if it already exists (-p).
21
if [ -d "$i" ];
22
then
23
echo "mkdir -p $i" >> runt.sh
24
else
25
# Trim the '.' off the beginning, the file is './assets/file.flow' and need to remove '.'.
26
trimName="${i:1}"
27
# TODO at some point change this to release.
28
echo "curl https://raw.githubusercontent.com/grafana/agent/main/docs/sources/flow/tutorials/assets$trimName -o $i" >> runt.sh
29
fi
30
done < <(find . -print0)
31
32
# Always pull the newest.
33
# TODO at some point change this from main.
34
echo "docker pull grafana/agent:main " >> runt.sh
35
echo "CONFIG_FILE=\$1 docker-compose -f ./docker-compose.yaml up" >> runt.sh
36
37