Zuletzt aktiv 6 months ago

Änderung 70787e35ed2943e8575023e931adedf3588498a0

deploy_watchtower.sh Originalformat
1#!/bin/bash
2DOCKER_BASE=/srv/docker
3
4mkdir -p ${DOCKER_BASE}/watchtower/container.conf
5
6cat > ${DOCKER_BASE}/watchtower/container.conf/docker-compose.yml <<EOF
7version: '3.7'
8
9services:
10 watchtower:
11 image: ghcr.io/nicholas-fedor/watchtower
12 labels:
13 com.centurylinklabs.watchtower.enable: "true"
14 restart: on-failure
15 volumes:
16 - /var/run/docker.sock:/var/run/docker.sock
17 - /etc/localtime:/etc/localtime:ro
18 - /etc/timezone:/etc/timezone:ro
19 command: --interval 3600 --label-enable
20EOF
21ln -s container.conf/docker-compose.yml ${DOCKER_BASE}/watchtower/
22
23cat > ${DOCKER_BASE}/watchtower/container.conf/production.yml <<EOF
24version: '3.7'
25EOF
26
27cat > ${DOCKER_BASE}/watchtower/container.conf/watchtower.service <<EOF
28[Unit]
29Description=Watchtower Service
30After=network.target docker.service
31Requires=docker.service
32
33[Service]
34Type=oneshot
35RemainAfterExit=yes
36
37Environment="WORK_DIR=/srv/docker/watchtower/"
38WorkingDirectory=/srv/docker/watchtower/
39ExecStartPre=-/usr/local/bin/docker-compose -f "\${WORK_DIR}/docker-compose.yml" -f "\${WORK_DIR}/container.conf/production.yml" down
40ExecStartPre=-/usr/local/bin/docker-compose -f "\${WORK_DIR}/docker-compose.yml" -f "\${WORK_DIR}/container.conf/production.yml" pull
41ExecStart=/usr/local/bin/docker-compose -f "\${WORK_DIR}/docker-compose.yml" -f "\${WORK_DIR}/container.conf/production.yml" up -d
42ExecStop=/usr/local/bin/docker-compose -f "\${WORK_DIR}/docker-compose.yml" -f "\${WORK_DIR}/container.conf/production.yml" down
43
44[Install]
45WantedBy=docker.service
46EOF
47ln -s ${DOCKER_BASE}/watchtower/container.conf/watchtower.service /etc/systemd/system/
48
49systemctl daemon-reload && systemctl enable watchtower && systemctl start watchtower
50
migrate_1.1.6_notifcations.sh Originalformat
1#!/bin/bash
2DOCKER_BASE=/srv/docker
3WATCHTOWER_PATH=${DOCKER_BASE}/watchtower
4DC_COMMAND="docker-compose -f docker-compose.yml"
5
6cd ${WATCHTOWER_PATH} || exit
7[ -f container.conf/production.yml ] && DC_COMMAND="${DC_COMMAND} -f container.conf/production.yml"
8[ "$(${DC_COMMAND} config | grep "WATCHTOWER_NOTIFICATIONS" | awk '{print $2}')" != "email" ] && exit
9cp container.conf/production.yml container.conf/production.yml.old
10
11SMTP_HOST="$(${DC_COMMAND} config | grep "WATCHTOWER_NOTIFICATION_EMAIL_SERVER:" | awk '{print $2}')"
12SMTP_FROM="$(${DC_COMMAND} config | grep "WATCHTOWER_NOTIFICATION_EMAIL_FROM:" | awk '{print $2}')"
13SMTP_TO="$(${DC_COMMAND} config | grep "WATCHTOWER_NOTIFICATION_EMAIL_TO:" | awk '{print $2}')"
14
15[ ! -e ${WATCHTOWER_PATH}/.env ] && ln -s container.conf/.env ${WATCHTOWER_PATH}/.env
16touch ${WATCHTOWER_PATH}/container.conf/.env
17sed -iE '/^SMTP_/d' ${WATCHTOWER_PATH}/container.conf/.env
18cat >> ${WATCHTOWER_PATH}/container.conf/.env <<EOF
19SMTP_HOST=${SMTP_HOST}
20SMTP_FROM=${SMTP_FROM}
21SMTP_TO=${SMTP_TO}
22EOF
23
24sed -i 's/WATCHTOWER_NOTIFICATIONS.*email/WATCHTOWER_NOTIFICATIONS=shoutrrr/' ${WATCHTOWER_PATH}/container.conf/production.yml
25sed -i 's#WATCHTOWER_NOTIFICATION_EMAIL_FROM.*"#WATCHTOWER_NOTIFICATION_URL=smtp://:@\${SMTP_HOST}/?auth=None\&encryption=None\&fromaddress=\${SMTP_FROM}\&fromname=Watchtower\&starttls=No\&toaddresses=\${SMTP_TO}\&usehtml=No"#' ${WATCHTOWER_PATH}/container.conf/production.yml
26sed -iE '/WATCHTOWER_NOTIFICATION_EMAIL_/d' ${WATCHTOWER_PATH}/container.conf/production.yml
27
migrate_to_containrrr.sh Originalformat
1#!/bin/bash
2DOCKER_BASE=/srv/docker
3
4mkdir -p ${DOCKER_BASE}/watchtower/container.conf
5
6sed -i s/v2tec/containrrr/g ${DOCKER_BASE}/watchtower/container.conf/docker-compose.yml
7
8systemctl restart watchtower && docker image rm v2tec/watchtower
9
migrate_to_image_nicholas-fedor.sh Originalformat
1#!/bin/bash
2DOCKER_BASE=/srv/docker
3
4mkdir -p ${DOCKER_BASE}/watchtower/container.conf
5
6sed -i "s/image: containrrr\/watchtower/image: ghcr.io\/nicholas-fedor\/watchtower/" ${DOCKER_BASE}/watchtower/container.conf/docker-compose.yml && cd ${DOCKER_BASE}/watchtower && systemctl restart watchtower && docker image rm containrrr/watchtower && docker-compose -f docker-compose.yml -f container.conf/production.yml logs -f
7