Direct avahi logs to container logs

This commit is contained in:
chuckcharlie
2025-04-14 16:31:06 -06:00
parent 690a2bcf58
commit b242cb86f2
3 changed files with 41 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1 +1 @@
1.2.0
1.2.1