-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
47 lines (38 loc) · 1.21 KB
/
start.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
#!/bin/bash
# Entrypopint of the Dockerfile.
# Sets up the crontab to call import.sh on a regular basis
set +e
# Adjust timezone.
# TIMEZONE is set in the Dockerfile
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime
echo ${TIMEZONE} > /etc/timezone
echo "Date: `date`."
# Set up import group.
# IMPORT_GID is set in the Dockerfile
: ${IMPORT_GID:="$IMPORT_DEFAULT_GID"}
if [ "$(id -g import)" != "$IMPORT_GID" ]; then
groupmod -o -g "$IMPORT_GID" import
fi
echo "Using group ID $(id -g import)."
# Set up import user.
# IMPORT_UID is set in the Dockerfile
: ${IMPORT_UID:="$IMPORT_DEFAULT_UID"}
if [ "$(id -u import)" != "$IMPORT_UID" ]; then
usermod -o -u "$IMPORT_UID" import
fi
echo "Using user ID $(id -u import)."
# Make sure the files are owned by the user executing import, as we
# will need to add/delete files.
chown import:import /app/import.sh
# Set up crontab.
# CRONTAB and DEFAULT_SCHEDULE are set in the Dockerfile
# IMPORT_SCHEDULE is set in docker-compose.yml
if [ "$IMPORTER_CRON_ENABLE" = true ]; then
echo "" > $CRONTAB
echo "${IMPORT_SCHEDULE:-$DEFAULT_SCHEDULE} /app/import.sh" >> $CRONTAB
else
echo "No cronjob set for importer"
fi
crontab -u import - < $CRONTAB
#echo "Starting cron."
exec cron -l 8 -f