From 018d9232d48851a636b8e44fd59fae5b7917cdfa Mon Sep 17 00:00:00 2001 From: root Date: Wed, 19 Sep 2018 19:57:20 -0500 Subject: [PATCH] Removed dbus configuration and added avahi reload. --- Dockerfile | 1 + README.md | 16 +++------------- root/root/printer-update.sh | 3 +++ root/root/run_cups.sh | 2 ++ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f3bf5d..08ab4d0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,7 @@ RUN sed -i 's/Listen localhost:631/Listen 0.0.0.0:631/' /etc/cups/cupsd.conf && sed -i 's//\n Allow All/' /etc/cups/cupsd.conf && \ sed -i 's//\n Allow All\n Require user @SYSTEM/' /etc/cups/cupsd.conf && \ sed -i 's//\n Allow All/' /etc/cups/cupsd.conf && \ + sed -i 's/.*enable\-dbus=.*/enable\-dbus\=no/' /etc/avahi/avahi-daemon.conf && \ echo "ServerAlias *" >> /etc/cups/cupsd.conf && \ echo "DefaultEncryption Never" >> /etc/cups/cupsd.conf diff --git a/README.md b/README.md index d1d95ea..36fac9d 100644 --- a/README.md +++ b/README.md @@ -14,29 +14,19 @@ This Ubuntu-based Docker image runs a CUPS instance that is meant as an AirPrint * `CUPSADMIN`: the CUPS admin user you want created * `CUPSPASSWORD`: the password for the CUPS admin user -### Ports: -* `631`: the TCP port for CUPS must be exposed +### Ports/Network: +* Must be run on host network. This is required to support multicasting which is needed for Airprint. ### Example run command: ``` -docker run --name cups -p 631:631 --restart unless-stopped \ +docker run --name cups --restart unless-stopped --net host\ -v :/services \ -v :/config \ - -v /var/run/dbus:/var/run/dbus \ -e CUPSADMIN="" \ -e CUPSPASSWORD="" \ chuckcharlie/cups-airprint-brother:latest ``` -## Install Avahi on local host: -These commands only work on RedHat/CentOS/Fedora. Ubuntu will be different. -``` -yum install avahi -systemctl start avahi-daemon -systemctl enable avahi-daemon -``` -***This was the only way I was able to get /var/run/dbus to respond correctly in the container.*** - ## Add and set up printer: CUPS will be configurable at http://[host ip]:631 using the CUPSADMIN/CUPSPASSWORD. diff --git a/root/root/printer-update.sh b/root/root/printer-update.sh index 4bbf1e2..f3b70a0 100644 --- a/root/root/printer-update.sh +++ b/root/root/printer-update.sh @@ -3,7 +3,10 @@ inotifywait -m -e close_write,moved_to,create /etc/cups | while read -r directory events filename; do if [ "$filename" = "printers.conf" ]; then rm -rf /services/AirPrint-*.service + rm -rf /etc/avahi/services/AirPrint-*.service /root/airprint-generate.py -d /services cp /etc/cups/printers.conf /config/printers.conf + cp -f /services/AirPrint-*.service /etc/avahi/services/ & + /usr/sbin/avahi-daemon --reload fi done diff --git a/root/root/run_cups.sh b/root/root/run_cups.sh index cd1e172..c0fcd6d 100644 --- a/root/root/run_cups.sh +++ b/root/root/run_cups.sh @@ -11,10 +11,12 @@ mkdir -p /config/ppd mkdir -p /services rm -rf /etc/cups/ppd ln -s /config/ppd /etc/cups +cp -f /services/*.service /etc/avahi/services/ if [ ! -f /config/printers.conf ]; then touch /config/printers.conf fi cp /config/printers.conf /etc/cups/printers.conf /root/printer-update.sh & +/usr/sbin/avahi-daemon & exec /usr/sbin/cupsd -f