-
Notifications
You must be signed in to change notification settings - Fork 2
/
mc.service
32 lines (26 loc) · 1.17 KB
/
mc.service
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
[Unit]
Description=sends links to telegram from whatsapp chats and email
Requires=docker.service
After=docker.service
[Service]
Restart=always
# Set working directory to where you've cloned the project
WorkingDirectory=/home/user/Meetings-Channel
# There can be random links it misses if it runs for too long, so restart every 12 hours
RuntimeMaxSec=43200
# Remove old containers, images and volumes
ExecStartPre=/usr/local/bin/docker-compose down -v
ExecStartPre=/usr/local/bin/docker-compose rm -fv
ExecStartPre=-/bin/bash -c 'docker volume ls -qf "name=%i_" | xargs docker volume rm'
ExecStartPre=-/bin/bash -c 'docker network ls -qf "name=%i_" | xargs docker network rm'
ExecStartPre=-/bin/bash -c 'docker ps -aqf "name=%i_*" | xargs docker rm'
# build the docker image
ExecStartPre=/usr/bin/docker build -t meetings-channel .
# Compose up
ExecStart=/usr/local/bin/docker-compose up --remove-orphans --abort-on-container-exit
# Compose down, remove containers, untagged images and volumes
ExecStop=/usr/local/bin/docker-compose down -v --remove-orphans
ExecStop=/usr/bin/docker rmi f_whatsapp_whatsapp:latest -f
ExecStop=/usr/bin/docker image prune -f
[Install]
WantedBy=multi-user.target