From 6e7ab8ffabfcecddc70c3be30211c2088112fff4 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 23 Feb 2020 14:20:51 +0100 Subject: [PATCH] Moved cron tasks to another stack. Removed unnecessary output. --- crontab | 11 ----------- docker-compose.yml | 8 -------- start_or_update.sh | 13 ++++--------- 3 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 crontab diff --git a/crontab b/crontab deleted file mode 100644 index 1856f14..0000000 --- a/crontab +++ /dev/null @@ -1,11 +0,0 @@ -# /etc/crontab: system-wide crontab -# Unlike any other crontab you don't have to run the `crontab' -# command to install the new version when you edit this file -# and files in /etc/cron.d. These files also have username fields, -# that none of the other crontabs do. - -SHELL=/bin/sh -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin - -# m | h | day of month | month | day of week | user | command -5 2 * * * root docker -H tcp://127.0.0.1:2375 exec dockerreverseproxystack_reverse-proxy_1 certbot renew > /proc/1/fd/2 2>&1 diff --git a/docker-compose.yml b/docker-compose.yml index 8ee3430..0ce3993 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,14 +16,6 @@ services: - /mnt/volumes/reverse-proxy_conf_enabled/data:/etc/apache2/sites-enabled:Z - /mnt/volumes/reverse-proxy_letsencrypt/data:/etc/letsencrypt:Z - cron: - image: cron:$VERSION_CRON - #build: "https://git.scimetis.net/yohan/docker-cron.git" - restart: always - network_mode: "host" - volumes: - - ./crontab:/etc/crontab:Z - networks: reverse-proxy: diff --git a/start_or_update.sh b/start_or_update.sh index 4114c8b..4c8b604 100755 --- a/start_or_update.sh +++ b/start_or_update.sh @@ -1,9 +1,9 @@ #!/bin/bash for NETWORK in reverse-proxy do - sudo docker network inspect ${NETWORK} && continue + sudo docker network inspect ${NETWORK} &> /dev/null && continue sudo docker network create ${NETWORK} - sudo docker network inspect ${NETWORK} || \ + sudo docker network inspect ${NETWORK} &> /dev/null || \ { echo "ERROR: could not create network ${NETWORK}, exiting."; exit 1; } done @@ -23,9 +23,6 @@ do fi done -sudo chown root. crontab -sudo chmod 644 crontab - export OS_REGION_NAME=GRA test -f ~/duplicity_password.sh || { echo "ERROR: ~/duplicity_password.sh not found, exiting."; exit 1; } source ~/duplicity_password.sh @@ -34,7 +31,7 @@ sudo docker image inspect duplicity:latest &> /dev/null || { echo "ERROR: duplic rm -rf ~/build mkdir -p ~/build -for name in docker-cron docker-reverse-proxy +for name in docker-reverse-proxy do sudo -E docker run --rm -e SWIFT_USERNAME=$OS_USERNAME \ -e SWIFT_PASSWORD=$OS_PASSWORD \ @@ -49,13 +46,11 @@ do done # --force-recreate is used to recreate container when crontab file has changed -unset VERSION_PROXY VERSION_CRON +unset VERSION_PROXY DIRECTORY=$(pwd) cd ~/build/docker-reverse-proxy; export VERSION_PROXY=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY -cd ~/build/docker-cron; export VERSION_CRON=$(git show-ref --head| head -1 | cut -f 1|cut -c -10); cd $DIRECTORY sudo docker build -t reverse-proxy:$VERSION_PROXY ~/build/docker-reverse-proxy -sudo docker build -t cron:$VERSION_CRON ~/build/docker-cron sudo -E bash -c 'docker-compose up -d --force-recreate'