mirror of
https://github.com/nikdoof/cups-avahi-airprint.git
synced 2025-12-10 17:42:17 +00:00
Direct avahi logs to container logs
This commit is contained in:
18
root/root/avahi-service.sh
Normal file
18
root/root/avahi-service.sh
Normal 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
|
||||
@@ -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
|
||||
@@ -1 +1 @@
|
||||
1.2.0
|
||||
1.2.1
|
||||
|
||||
Reference in New Issue
Block a user