cups/overlay/usr/local/bin/entrypoint
Robert Kaussow eab91e3c36
All checks were successful
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/push/build-container Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/notify Pipeline was successful
refactor: move everything to /cups base dir
2024-10-25 20:11:13 +02:00

32 lines
778 B
Bash
Executable File

#!/usr/bin/env sh
# shellcheck disable=SC3040
set -eo pipefail
# Function to handle SIGTERM
terminate() {
echo "Received SIGTERM, shutting down CUPS..."
kill -TERM "$child" 2>/dev/null
wait "$child"
exit 0
}
# Set up SIGTERM trap
trap terminate TERM
if [ -n "$CUPS_ADMIN_USERNAME" ] && [ -n "$CUPS_ADMIN_PASSWORD" ]; then
if ! id -u "$CUPS_ADMIN_USERNAME" >/dev/null 2>&1; then
echo "Creating user $CUPS_ADMIN_USERNAME..."
adduser -S -H -G lpadmin "$CUPS_ADMIN_USERNAME"
echo "$CUPS_ADMIN_USERNAME:$CUPS_ADMIN_PASSWORD" | chpasswd 2>/dev/null
fi
fi
# Start CUPS in the background and get its PID
/usr/sbin/cupsd -f -c /cups/conf/cupsd.conf -s /cups/conf/cups-files.conf &
child=$!
# Wait for the CUPS process
wait "$child"