forked from pbuyle/docker-elodie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·60 lines (48 loc) · 1.48 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
set -eu
PYTHON="su-exec ${PUID}:${PGID} python"
ELODIE="${PYTHON} /elodie/elodie.py"
INOTIFY_BIN="inotifywait"
IMPORT_OPTIONS="--destination ${DESTINATION}"
if [ "${TRASH:-}" ]; then
mkdir -p "${XDG_DATA_HOME:-${HOME}/.local/share}"
ln -s "${TRASH}" "${XDG_DATA_HOME:-${HOME}/.local/share/Trash}"
IMPORT_OPTIONS="${IMPORT_OPTIONS} --trash"
fi
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 [ "${INOTIFYWAIT_POLLING:-}" ]; then
INOTIFY_BIN="inotifywait-polling"
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
watch)
${INOTIFY_BIN} -e close_write -mr "${SOURCE}" | while read -r EV;
do
(
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} ${SOURCE}
fi
) &
done
;;
*)
exec ${ELODIE} $@
;;
esac