-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdc
72 lines (68 loc) · 4.1 KB
/
dc
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
#!/usr/bin/env bash
if [ "$1" == "start" ]; then
sudo docker-compose start
fi
if [ "$1" == "stop" ]; then
sudo docker-compose stop
fi
if [ "$1" == "update" ]; then
sudo docker pull woosungchoi/fpm-alpine && sudo docker-compose pull && sudo docker-compose up --build -d && sudo docker image prune -f
fi
if [ "$1" == "setup" ]; then
echo 'Исходные данные...' \
&& read -p "[1/6] Укажите доменное имя (прим : mydomain.ru) : " DOMAIN
read -p "[2/6] Укажите актуальный адрес электронной почты для генерации SSL сертификата (прим : [email protected]) : " EMAIL
read -p "[3/6] Укажите root пароль для настройки СУБД (прим : rootdbpassword) : " ROOTDBPASSWORD
read -p "[4/6] Укажите имя базы данных для wordpress (прим : dbuser) : " DATABASEUSER
read -p "[5/6] Укажите пароль к базе данных для wordpress (прим : dbpassword) : " DATABASEPASSWORD
read -p "[6/6] Укажите имя базы данных для wordpress (прим : wordpress) : " DATABASE \
&& rm -rf wordpress; git clone https://github.com/woosungchoi/docker-wordpress wordpress \
&& cd wordpress \
&& sed -i "s/<rootdbpassword>/$ROOTDBPASSWORD/g" .env \
&& sed -i "s/<databaseuser>/$DATABASEUSER/g" .env \
&& sed -i "s/<databasepassword>/$DATABASEPASSWORD/g" .env \
&& sed -i "s/<database>/$DATABASE/g" .env \
&& sed -i "s/<domain>/$DOMAIN/g" docker-compose.yml \
&& sed -i "s/<domain>/$DOMAIN/g" docker-compose.production.yml \
&& sed -i "s/<email>/$EMAIL/g" docker-compose.yml \
&& sed -i "s/<domain>/$DOMAIN/g" nginx/conf.d/ssl-conf \
&& sed -i "s/<domain>/$DOMAIN/g" nginx/conf.d/wordpress.conf \
&& sed -i "s/<domain>/$DOMAIN/g" nginx/conf.d/portainer.conf \
&& sed -i "s/<domain>/$DOMAIN/g" nginx/conf.d/phpmyadmin.conf \
&& echo 'Установка часового пояса на Europa/Moscow...' \
&& sudo timedatectl set-timezone Eurpoa/Moscow \
&& echo 'Установка Docker...' \
&& sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y \
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
&& sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" -y \
&& sudo apt update -y \
&& sudo apt install docker-ce docker-ce-cli containerd.io -y \
&& if [ ! -f /usr/local/bin/docker-compose ] ; then
echo 'Установка Docker Compose...' \
&& COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4) \
&& sudo curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& sudo chmod +x /usr/local/bin/docker-compose
else echo 'Установка Docker Compose пропущенна'
fi
echo 'Настройка SSL...' \
&& sudo docker-compose up \
&& echo 'Подготовка docker-compose up' \
&& sudo docker-compose down -v \
&& sudo mkdir -p /usr/share/nginx/html;
curl -sSLo nginx/conf.d/options-ssl-nginx https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf \
&& sudo chmod a+x build/docker-entrypoint.sh \
&& sudo chmod a+x dc \
&& mv docker-compose.yml docker-compose.ssl.yml \
&& mv docker-compose.production.yml docker-compose.yml \
&& echo 'Настройка cron...' \
&& echo "0 23 * * * docker start certbot >> /var/log/docker_cron.log 2>&1
5 23 * * * docker exec nginx nginx -s reload >> /var/log/docker_cron.log 2>&1" >> mycron \
&& sudo crontab mycron; rm mycron \
&& echo 'Запуск DoЗапускcker ...' \
&& sudo docker-compose up -d \
&& echo 'Готово!' \
&& sudo docker-compose ps \
&& echo 'Ссылка на wordpress: https://'$DOMAIN;
echo 'Ссылка на phpmyadmin: https://pma.'$DOMAIN;
echo 'Ссылка на portainer: https://port.'$DOMAIN;
fi