1+ #! /bin/bash -ex
2+ # # для тестов
3+ export DOCKER_HOST=ssh://apopov@zabbixs
4+
5+ docker stop -t 1 $( docker ps -a -q) | true
6+ sleep 1
7+ docker rm -f $( docker ps -a -q ) | true
8+ sleep 1
9+ docker network rm network-zabbixs | true
10+ sleep 1
11+
12+ docker network create --driver=bridge --subnet=172.18.0.0/16 network-zabbixs
13+
14+ if [ ! -v ZABBIX_DOCKER_VERSIONS ];
15+ then
16+ export ZABBIX_DOCKER_VERSIONS=" 5.2 5.0 4.4 4.2 4.0 3.2 3.0"
17+ # export ZABBIX_DOCKER_VERSIONS="5.2"
18+ fi
19+ # ZABBIX_DOCKER_VERSIONS="4.4"
20+
21+ docker run -it -d \
22+ --name pg_for_zabbix \
23+ --ip 172.18.0.7 \
24+ --net network-zabbixs \
25+ --hostname pg_for_zabbix \
26+ -e POSTGRES_PASSWORD=" 111111" \
27+ -e POSTGRES_HOST_AUTH_METHOD=trust \
28+ --restart unless-stopped \
29+ postgres:13 /bin/bash /docker-entrypoint.sh -c max_connections=200
30+ sleep 5
31+
32+ docker exec -d -i pg_for_zabbix psql -U postgres -c ' create user zabbix superuser'
33+ sleep 1
34+ docker exec -d -i pg_for_zabbix psql -U postgres -c ' create database zabbix owner zabbix'
35+ sleep 3
36+
37+ for VER in $ZABBIX_DOCKER_VERSIONS
38+ do
39+ Z_PORT=" 8080"
40+ if [[ " $VER " == " 4.2" || " $VER " == " 3.4" || " $VER " == " 3.2" ]]
41+ then
42+ Z_PORT=" 80"
43+ fi
44+
45+
46+ VER2=" ${VER/ ./ _} "
47+ IFS=' .' read -ra VER_ARRAY <<< $VER
48+ VER_MAJOR=${VER_ARRAY[0]}
49+ VER_MINOR=${VER_ARRAY[1]}
50+ docker exec -d -i pg_for_zabbix psql -U postgres -c " create database zabbix_$VER2 owner zabbix"
51+ sleep 1
52+ docker run \
53+ --name=" zabbix-server-pgsql_$VER2 " \
54+ --ip=" 172.18.0.1$VER_MAJOR$VER_MINOR " \
55+ --net network-zabbixs \
56+ --hostname=" zabbix-server-pgsql_$VER2 " \
57+ -e DB_SERVER_HOST=" pg_for_zabbix" \
58+ -e DB_SERVER_DBNAME=" server_$VER2 " \
59+ -e POSTGRES_USER=" zabbix" \
60+ -e POSTGRES_DB=" zabbix_$VER2 " \
61+ -e PHP_TZ=" Europe/Moscow" \
62+ -p 200$VER_MAJOR$VER_MINOR :10051 \
63+ --restart unless-stopped \
64+ -d zabbix/zabbix-server-pgsql:alpine-$VER -latest
65+
66+ sleep 1
67+
68+ docker run \
69+ --name=" zabbix-web-apache-pgsql_$VER2 " \
70+ --net=" network-zabbixs" \
71+ --ip=" 172.18.0.2$VER_MAJOR$VER_MINOR " \
72+ -e DB_SERVER_HOST=" pg_for_zabbix" \
73+ -e ZBX_SERVER_HOST=" zabbix-server-pgsql_$VER2 " \
74+ -e DB_SERVER_DBNAME=" zabbix_$VER2 " \
75+ -e POSTGRES_DB=" zabbix_$VER2 " \
76+ -e POSTGRES_USER=" zabbix" \
77+ --restart unless-stopped \
78+ -e PHP_TZ=" Europe/Moscow" \
79+ -p 80$VER_MAJOR$VER_MINOR :$Z_PORT \
80+ --restart unless-stopped \
81+ -d zabbix/zabbix-web-apache-pgsql:alpine-$VER -latest
82+
83+ echo " http port 80$VER_MAJOR$VER_MINOR "
84+ echo " zabbix server port 200$VER_MAJOR$VER_MINOR "
85+ done
86+ exit 0
87+
88+
89+ # docker exec -it -i pg_for_zabbix psql -U postgres -c '\l'
90+ # docker exec -it -i pg_for_zabbix psql -U postgres -c '\du'
91+ # docker exec -it zabbix-web-apache-pgsql_5.0 bash
0 commit comments