-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright (c) 2018 Anton Semjonov | ||
# Licensed under the MIT License | ||
|
||
FROM python:alpine | ||
|
||
# default cron interval | ||
ENV MINUTES=15 | ||
|
||
# copy init script which execs crond | ||
COPY assets/container/init.sh /init.sh | ||
ENTRYPOINT ["/bin/ash", "/init.sh", "/usr/bin/imapfetch.py"] | ||
CMD ["/config"] | ||
|
||
# copy imapfetch script | ||
COPY imapfetch/imapfetch.py /usr/bin/imapfetch.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/ash | ||
|
||
# Copyright (c) 2018 Anton Semjonov | ||
# Licensed under the MIT License | ||
|
||
# command is given as parameter | ||
export COMMAND="${*:?command required}" | ||
|
||
# assemble cron schedule from env | ||
# either use '-e MINUTES=n' to run test every n minutes | ||
# or define the complete schedule part with '-e SCHEDULE=...' | ||
export SCHEDULE="${SCHEDULE:-"*/$MINUTES * * * *"}" | ||
|
||
# install crontab | ||
echo "$SCHEDULE $COMMAND" | crontab - | ||
|
||
# run command once before schedule | ||
${SHELL:-sh} -c "$COMMAND" || { | ||
echo "command error. exiting." | ||
exit 1 | ||
} | ||
|
||
# exec crontab in foreground | ||
exec crond -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters