diff --git a/root/root/avahi-service.sh b/root/root/avahi-service.sh new file mode 100644 index 0000000..c0c6aac --- /dev/null +++ b/root/root/avahi-service.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +# Function to start avahi-daemon +start_avahi() { + echo "Starting avahi-daemon..." + # Run in foreground to capture logs in container logs + avahi-daemon --no-drop-root --no-chroot --no-proc-title +} + +# Main service loop +while true; do + # Start avahi-daemon and wait for it to exit + start_avahi + + # If avahi-daemon exits, wait a moment before restarting + echo "avahi-daemon exited, restarting in 5 seconds..." + sleep 5 +done \ No newline at end of file diff --git a/root/root/run_cups.sh b/root/root/run_cups.sh index 66eb5d9..7361265 100644 --- a/root/root/run_cups.sh +++ b/root/root/run_cups.sh @@ -36,6 +36,26 @@ else cp /etc/cups/cupsd.conf /config/cupsd.conf fi -/usr/sbin/avahi-daemon --daemonize +# Function to handle cleanup on exit +cleanup() { + echo "Cleaning up..." + if [ -f /var/run/avahi-daemon.pid ]; then + PID=$(cat /var/run/avahi-daemon.pid) + if kill -0 $PID 2>/dev/null; then + kill $PID + rm -f /var/run/avahi-daemon.pid + fi + fi + exit 0 +} + +# Set up trap for cleanup +trap cleanup SIGTERM SIGINT + +# Start avahi-daemon service in the background +/root/avahi-service.sh & +AVAHI_SERVICE_PID=$! + +# Start CUPS and printer update /root/printer-update.sh & -exec /usr/sbin/cupsd -f +exec /usr/sbin/cupsd -f \ No newline at end of file diff --git a/version.txt b/version.txt index 26aaba0..6085e94 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 +1.2.1