This commit fixes a nasty bug, where the docker-entrypoint.sh silently
exits without any error message. The test for a lock file can fail and
due to the `set -e` at the beginning of the file the bash script exists
without starting the paperless application.
It is fixed by moving the check for the existence of the lock file into
the if statement, where the `set -e` does not trigger an exit in case
the statement fails.
Additionally this commit enables the script to trap exit signals and in
that case deletes the lock file.
issues found by shellcheck were:
```
$ shellcheck docker-entrypoint.sh
In docker-entrypoint.sh line 10:
if [[ ${USERMAP_UID} != ${USERMAP_ORIG_UID} || ${USERMAP_GID} != ${USERMAP_ORIG_GID} ]]; then
^-- SC2053: Quote the rhs of != in [[ ]] to prevent glob matching.
^-- SC2053: Quote the rhs of != in [[ ]] to prevent glob matching.
In docker-entrypoint.sh line 12:
groupmod -g ${USERMAP_GID} paperless
^-- SC2086: Double quote to prevent globbing and word splitting.
In docker-entrypoint.sh line 65:
if dpkg -s "$pkg" 2>&1 > /dev/null; then
^-- SC2069: The order of the 2>&1 and the redirect matters. The 2>&1 has to be last.
In docker-entrypoint.sh line 69:
if ! apt-cache show "$pkg" 2>&1 > /dev/null; then
^-- SC2069: The order of the 2>&1 and the redirect matters. The 2>&1 has to be last.
```