File entrypoint.sh of Package firefox-dev-entrypoint
#!/bin/bash
# Function to log messages
log() {
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')] $@"
}
log "Starting Firefox entrypoint script"
# Trap signals for graceful shutdown
trap 'log "Received SIGTERM, initiating shutdown"; cleanup' SIGTERM
trap 'log "Received SIGINT, initiating shutdown"; cleanup' SIGINT
# Cleanup function to stop all relevant processes
cleanup() {
log "Cleaning up and stopping processes"
pkill -SIGTERM firefox
sleep 3
log "Cleanup complete, exiting"
exit 0
}
# Set default DISPLAY if not set
if [ -z "$DISPLAY" ]; then
log "DISPLAY variable is not set, defaulting to :0"
DISPLAY=:0
fi
# Set default URL if not set
if [ -z "$URL" ]; then
log "URL variable is not set, defaulting to https://suse.com"
URL="https://suse.com"
fi
# Log any additional flags requested
if [ -n "$ADDITIONAL_FLAGS" ]; then
log "ADDITIONAL_FLAGS are set: $ADDITIONAL_FLAGS"
fi
if [ $# -gt 0 ]; then
log "Executing custom command: $@"
exec "$@"
else
# Start Firefox
log "Starting Firefox on display $DISPLAY with URL: $URL"
firefox --kiosk $URL $ADDITIONAL_FLAGS &
FF_PID=$!
# Wait for Firefox process to finish
log "Firefox running"
wait $FF_PID
log "Firefox has exited"
fi