forked from WeslyG/keenetic_backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
39 lines (30 loc) · 815 Bytes
/
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
#!/bin/sh
# Assert env variable
if [ -z "$ROUTER_HOST" ]; then
echo "ERROR: 'ROUTER_HOST' env variable is not defined"
exit 1
fi
# Assert env variable
if [ -z "$USER_NAME" ]; then
echo "ERROR: 'USER_NAME' env variable is not defined"
exit 1
fi
# Assert env variable
if [ -z "$PASSWORD" ]; then
echo "ERROR: 'PASSWORD' env variable is not defined"
exit 1
fi
# Set default SSH port
SSH_PORT="${SSH_PORT:-22}"
export SSH_PORT
# Set default backup numbers if the env variable is not set
NUMBER_OF_BACKUPS="${NUMBER_OF_BACKUPS:-30}"
export NUMBER_OF_BACKUPS
# Set default backup frequency if the env variable is not set
CRON="${CRON:-@daily}"
# Provide env variables to the cron
env >> /etc/environment
# Add cron task
echo "$CRON /etc/backup.sh" >> /etc/crontabs/root
# Run cron
exec crond -l 2 -f