-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-cron.sh
executable file
·39 lines (30 loc) · 1.21 KB
/
prepare-cron.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
#!/bin/bash
log() {
echo "[$(date +"%Y-%m-%d %H:%M:%S")] - $1"
}
if [ "$BACKUP_ROTATION_ENABLED" == "true" ]; then
cp /rotate_backup.sh /etc/cronscripts/rotate_backup.sh
cat /backup-cron >> /etc/crontabs/dockercron/*
declare -p | grep -E 'BACKUP_ROTATION_MAX_SIZE|BACKUP_ROTATION_CUT_SIZE|BACKUP_ROTATION_SIZE_TYPE' >> /container.env
fi
if [ "$S3_BACKUP_ENABLED" == "true" ]; then
cp /s3_backup.sh /etc/cronscripts/s3_backup.sh
cat /s3_backup-cron >> /etc/crontabs/dockercron/*
declare -p | grep -E 'S3_PATH|S3_HASHDIR|S3_OBJECT_STORAGE_EP|S3_ACCESS_KEY|S3_SECRET_KEY|S3_ENCRYPT_PASSPHRASE|S3_CONFIGS_PATH' >> /container.env
if [ "$S3_BACKUP_ROTATION_ENABLED" == "true" ]; then
cp /s3_backup_rotation.sh /etc/cronscripts/s3_backup_rotation.sh
cat /s3_backup_rotation-cron >> /etc/crontabs/dockercron/*
declare -p | grep -E 'S3_BACKUP_ROTATION_TIME_LIMIT' >> /container.env
fi
fi
if [ -f "/install-packages.sh" ]; then
log "Running install packages"
chmod +x /install-packages.sh
bash /install-packages.sh
log "Packages installed!"
fi
chmod +x /etc/cronscripts/*
crontab /etc/crontabs/dockercron/*
log "Cronjob setup done"
log "Starting crond and tail"
crond -b -l 6 && tail -f /var/log/cron.log