Skip to content

Commit

Permalink
Finish and fix entrypoint.sh and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pbuyle committed Mar 30, 2020
1 parent 7b58fed commit 0a9713a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Docker container for [Elodie](https://github.com/jmathai/elodie)

<p align="center"><img src ="https://raw.githubusercontent.com/jmathai/elodie/master/creative/logo@300x.png" /></p>


The container default command is to watch a source folder using `inotifywait` and automatically execute `elodie` to import added images to a destination folder.

## Usage
Expand All @@ -25,20 +26,34 @@ docker run \

| Name | default value | Description
| ---------------------------- |:-------------:| -----------
| PUID | 1000 | for GroupID - see below for explanation
| PGID | 1000 | for GroupID - see below for explanation
| SOURCE | /source | Copy imported files into this directory
| DESTINATION | /destination | Import files from this directory, if specified
| TRASH | | After copying files, move the old files to this trash folder
| PUID | 1000 | for user id - see below for explanation
| PGID | 1000 | for group id - see below for explanation
| SOURCE | /source | Import files from this directory
| DESTINATION | /destination | Copy imported files into this directory
| TRASH | | Set to move files to this trash folder after copying files
| EXCLUDE | | Regular expression for directories or files to exclude
| ALLOW_DUPLICATE | | Set to import the files even if theu have already been imported
| ALBUM_FROM_FOLDER | | Set to use images' folders as their album names
| MAPQUEST_KEY | | Mapquest API key for geo-code location from EXIF's GPS fields
| ELODIE_APPLICATION_DIRECTORY | /elodie | Fully qualified directory path to the configuration file folder
| DEBUG | | Set to enable debug messages

### Advanced configurtion

Mount a custom `config.ini` to set configuration.
Mount a custom `/elodie/config.ini` to set configuration.

```
docker run \
-name elodie
-v /path/to/source:/source \
-v /path/to/destination:/destination \
-v /path/to/config.ini:/elodie/config.ini:ro \
-e PUID=1000 \
-e PGID=1000 \
--restart unless-stopped \
pbuyle/elodie
```

Note: If a custom configuartion file is used, the setting the `MAPQUEST_KEY` environment variable will have not effect.
Note: If a custom configuartion file is used then setting the `MAPQUEST_KEY` environment variable will have not effect.

### User / Group Identifiers

Expand Down
28 changes: 22 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,51 @@ set -eu
PYTHON="su-exec ${PUID}:${PGID} python"
ELODIE="${PYTHON} /elodie/elodie.py"

IMPORT_OPTIONS="--source ${SOURCE} --destination ${DESTINATION}"
IMPORT_OPTIONS="--destination ${DESTINATION}"

if [ "${TRASH:-}" ]; then
mkdir -p "${XDG_DATA_HOME:-~/.local/share}"
ln -s "${TRASH}" "${XDG_DATA_HOME:-${HOME}/.local/share}/Trash"
IMPORT_OPTIONS="${IMPORT_OPTIONS} --trash"
fi

if [ ! -e "${ELODIE_APPLICATION_DIRECTORY}/config.ini" ] && [ "${MAPQUEST_KEY}" ] ; then
if [ "${EXCLUDE:-}" ]; then
IMPORT_OPTIONS="${IMPORT_OPTIONS} --exclude-regex ${EXCLUDE}"
fi

if [ "${ALLOW_DUPLICATE:-}" ]; then
IMPORT_OPTIONS="${IMPORT_OPTIONS} --allow-duplicates}"
fi

if [ "${ALBUM_FROM_FOLDER:-}" ]; then
IMPORT_OPTIONS="${IMPORT_OPTIONS} --album-from-folder"
fi

if [ "${DEBUG:-}" ]; then
IMPORT_OPTIONS="${IMPORT_OPTIONS} --debug"
fi

if [ ! -e "${ELODIE_APPLICATION_DIRECTORY}/config.ini" ] && [ "${MAPQUEST_KEY:-}" ] ; then
echo -e "[MapQuest]\nkey=${MAPQUEST_KEY}\nprefer_english_names=False" > "${ELODIE_APPLICATION_DIRECTORY}/config.ini"
fi

case ${1:-watch}} in
case "${1:-watch}" in
watch)
inotifywait -e close_write -mr "${SOURCE}" | while read -r EV;
do
(
NOW=$(python -c "import time;print(time.time());")
NOW=$($PYTHON -c "import time;print(time.time());")
echo "${NOW}" > /tmp/elodie-last-debounce
sleep 60
LAST_DEBOUNCE=$(cat /tmp/elodie-last-debounce)
if [ "${NOW}" = "${LAST_DEBOUNCE}" ]; then
exec "${ELODIE}" import "${IMPORT_OPTIONS}"
exec ${ELODIE} import ${IMPORT_OPTIONS} ${SOURCE}
fi
) &
done
;;
*)
exec "${ELODIE}" "$@"
exec ${ELODIE} $@
;;

esac

0 comments on commit 0a9713a

Please sign in to comment.