forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_docker_compose.sh
executable file
·62 lines (51 loc) · 1.48 KB
/
create_docker_compose.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
blocks_dir=docker/blocks
docker_dir=docker
template_dir=templates
grafana_config_file=conf.tmp
grafana_config=config
compose_header_file=docker/compose_header.yml
compose_file=docker-compose.yaml
env_file=.env
if [ "$#" == 0 ]; then
blocks=`ls $blocks_dir`
if [ -z "$blocks" ]; then
echo "No Blocks available in $blocks_dir"
else
echo "Available Blocks:"
for block in $blocks; do
echo " $block"
done
fi
exit 0
fi
for file in $grafana_config_file $compose_file $env_file; do
if [ -e $file ]; then
echo "Deleting $file"
rm $file
fi
done
echo "Adding Compose header to $compose_file"
cat $compose_header_file >> $compose_file
for dir in $@; do
current_dir=$blocks_dir/$dir
if [ ! -d "$current_dir" ]; then
echo "$current_dir is not a directory"
exit 1
fi
if [ -e $current_dir/$grafana_config ]; then
echo "Adding $current_dir/$grafana_config to $grafana_config_file"
cat $current_dir/$grafana_config >> $grafana_config_file
echo "" >> $grafana_config_file
fi
if [ -e $current_dir/$compose_file ]; then
echo "Adding $current_dir/$compose_file to $compose_file"
cat $current_dir/$compose_file >> $compose_file
echo "" >> $compose_file
fi
if [ -e $current_dir/$env_file ]; then
echo "Adding $current_dir/$env_file to .env"
cat $current_dir/$env_file >> .env
echo "" >> .env
fi
done