-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·93 lines (63 loc) · 3.05 KB
/
docker-entrypoint.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
set -e
echo "Running traefik helper container"
if [[ ! "$@" == "run" ]]; then
exec "$@"
exit 0
fi
mkdir -p /plugins-local/src
GEOBLOCKING_VERSION="${GEOBLOCKING_VERSION:-v0.2.4}"
if [[ "$TRAEFIK_GEOBLOCK" == "true" ]]; then
cd /plugins-local/src
if [ ! -f /plugins-local/versions.log ] || [ $(grep github.com/kucjac/traefik-plugin-geoblock /plugins-local/versions.log | tail -n 1 | grep " ${GEOBLOCKING_VERSION}$" | wc -l) -eq 0 ]; then
echo "Did not find geoblocking plugin, or found old version, making sure the directory is empty to be cloned from github"
rm -rf github.com/kucjac/traefik-plugin-geoblock
fi
if [ ! -d github.com/kucjac/traefik-plugin-geoblock ]; then
echo "Cloning geoblocking plugin, version ${GEOBLOCKING_VERSION}"
git clone -b ${GEOBLOCKING_VERSION} https://github.com/kucjac/traefik-plugin-geoblock.git github.com/kucjac/traefik-plugin-geoblock
echo "$(date) - github.com/kucjac/traefik-plugin-geoblock - ${GEOBLOCKING_VERSION}" >> /plugins-local/versions.log
fi
cd /plugins-local
rm -rf temp
mkdir temp
cd temp
echo "Updating IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP file"
wget https://download.ip2location.com/lite/IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
if [ $? -eq 0 ]; then
echo "Downloaded archive"
unzip IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP
if [ $? -eq 0 ]; then
echo "Extracted archive, moving new file to plugin location"
ls -ltr IP2LOCATION-LITE-DB1.IPV6.BIN
mv IP2LOCATION-LITE-DB1.IPV6.BIN /plugins-local/src/github.com/kucjac/traefik-plugin-geoblock/
ls -ltr /plugins-local/src/github.com/kucjac/traefik-plugin-geoblock/
fi
fi
cd /plugins-local
rm -rf temp
fi
# make sure prometheus has correct permissions
if [ -d /etc/prometheus ]; then
chown 65534:65534 /etc/prometheus
if [ ! -f /etc/prometheus/prometheus.yml ]; then
cp /prometheus.yml /etc/prometheus/prometheus.yml
chown 65534:65534 /etc/prometheus/prometheus.yml
fi
fi
if [ -d /prometheus ]; then
chown 65534:65534 /prometheus
fi
# make sure grafana has correct permission
if [ -d /var/lib/grafana ]; then
chown 472:0 /var/lib/grafana
chmod 755 /var/lib/grafana
check_datasources=$(curl -s "http://grafana:3000/api/datasources" -u admin:${GF_SECURITY_ADMIN_PASSWORD})
if [ $(echo $check_datasources | grep prometheus | wc -l) -eq 0 ]; then
curl -X "POST" "http://grafana:3000/api/datasources" \
-H "Content-Type: application/json" \
--user admin:${GF_SECURITY_ADMIN_PASSWORD} \
--data '{"id":1,"uid":"de0jejoon5beod","orgId":1,"name":"prometheus","type":"prometheus","typeName":"Prometheus","typeLogoUrl":"public/app/plugins/datasource/prometheus/img/prometheus_logo.svg","access":"proxy","url":"http://prometheus:9090","user":"","database":"","basicAuth":false,"isDefault":true,"jsonData":{"httpMethod":"POST"},"readOnly":false}'
curl -X POST --user admin:${GF_SECURITY_ADMIN_PASSWORD} -H "Content-Type: application/json" -d @/grafanadashboard.json http://grafana:3000/api/dashboards/import
fi
fi