cups/overlay/usr/local/bin/entrypoint
Robert Kaussow d64b0c7ea4
Some checks failed
ci/woodpecker/push/build-package Pipeline was successful
ci/woodpecker/push/build-container Pipeline was successful
ci/woodpecker/push/docs Pipeline failed
ci/woodpecker/push/notify Pipeline was successful
initial commit
2024-10-25 19:27:47 +02:00

31 lines
670 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
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 &
child=$!
# Wait for the CUPS process
wait "$child"