Moved cron tasks to another stack. Removed unnecessary output.

This commit is contained in:
yohan 2020-02-23 14:20:51 +01:00
parent ed79f49c5c
commit 6e7ab8ffab
3 changed files with 4 additions and 28 deletions

11
crontab
View File

@ -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

View File

@ -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:

View File

@ -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'