-
Notifications
You must be signed in to change notification settings - Fork 5
/
docker_entrypoint.sh
executable file
·57 lines (38 loc) · 1.11 KB
/
docker_entrypoint.sh
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
#!/bin/bash
function docron() {
touch /mongo_sync.log
tail -f /mongo_sync.log &
crontab /crontab.conf
echo "=> Running cron job"
exec crond -f
}
env > /crontab.conf
if [[ "${1}" == "backup" ]]; then
if [ -n "${INIT_BACKUP}" ]; then
echo "=> Create a backup on the startup"
/backup.sh
fi
echo "=> Adding backup crontab entry"
echo "${CRON_TIME} /backup.sh >> /mongo_sync.log 2>&1" >> /crontab.conf
docron
elif [[ "${1}" == "restore" ]]; then
if [ -n "${INIT_RESTORE}" ]; then
echo "=> Restore a backup on the startup"
/restore.sh
fi
echo "=> Adding restore crontab entry"
echo "${CRON_TIME} /restore.sh >> /mongo_sync.log 2>&1" >> /crontab.conf
docron
elif [[ -z "${1}" || "${1}" == "sync" ]]; then
if [ -n "${INIT_SYNC}" ]; then
echo "=> Synchronize on the startup"
/sync.sh
fi
echo "=> Adding sync crontab entry"
echo "${CRON_TIME} /backup.sh >> /mongo_sync.log 2>&1" >> /crontab.conf
docron
else
# echo "Unrecognized action. Please specify one of: backup, restore, sync"
# exit 64
exec "$@"
fi