-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
executable file
·55 lines (44 loc) · 1.37 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
#!/bin/sh
set -eu
PYTHON="su-exec ${PUID}:${PGID} python"
ELODIE="${PYTHON} /elodie/elodie.py"
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 [ "${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
watch)
inotifywait -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