Files
shelfmark/entrypoint.sh
T
CaliBrainandmik593 3a92c5de78 CF BYPASS (#24)
The Calibre dependency was due to the script testing for validity of the
downloaded file, as often they would be corrupted from aa. But CWA is
already doing that, so we are just having redundant code here.

For the cloudflarebypasser, I basically run my own version now, instead
of depending on an external library, this way we have better control for
debugging and on the docker image.

Fixes #18, #33, #27, #48, #65, #78, #86, #88, #89

---------

Co-authored-by: mik593 <91991279+mik593@users.noreply.github.com>
2025-03-16 02:25:15 -04:00

30 lines
746 B
Bash

#!/bin/bash
set -e
# Set UID if not set
if [ -z "$UID" ]; then
UID=1000
fi
# Set GID if not set
if [ -z "$GID" ]; then
GID=100
fi
if ! getent group "$GID" >/dev/null; then
groupadd -g "$GID" appuser
fi
# Create user if it doesn't exist
if ! id -u "$UID" >/dev/null 2>&1; then
useradd -u "$UID" -g "$GID" -d /app -s /sbin/nologin appuser
fi
# Get username for the UID (whether we just created it or it existed)
USERNAME=$(getent passwd "$UID" | cut -d: -f1)
# Ensure proper ownership of application directories
chown -R "${UID}:${GID}" /app /var/log/cwa-book-downloader /cwa-book-ingest
# Switch to the user (either newly created or existing) and execute the main command
exec su -s /bin/bash "$USERNAME" -c "python -m app"