diff --git a/Dockerfile b/Dockerfile index 08ab4d0..61bb40d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,29 @@ -FROM ubuntu:bionic - -# Add repos -RUN echo 'deb [trusted=yes] http://www.openprinting.org/download/printdriver/debian/ lsb3.2 main contrib main-nonfree' >> /etc/apt/sources.list.d/multiverse.list +FROM alpine:latest # Install the packages we need. Avahi will be included -RUN apt-get update && apt-get install -y \ - brother-lpr-drivers-extra brother-cups-wrapper-extra openprinting-ppds-postscript-brother\ - cups \ - cups-pdf \ +RUN echo "http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories &&\ + apk add --update cups cups-libs cups-pdf cups-client \ + cups-filters \ + cups-dev \ + ghostscript \ + avahi \ inotify-tools \ - python-cups \ -&& rm -rf /var/lib/apt/lists/* + python \ + python-dev \ + py-pip \ + build-base \ + wget \ + && pip --no-cache-dir install --upgrade pip \ + && pip install pycups \ + && rm -rf /var/cache/apk/* + +#RUN apt-get update && apt-get install -y \ +# brother-lpr-drivers-extra brother-cups-wrapper-extra openprinting-ppds-postscript-brother\ +# cups \ +# cups-pdf \ +# inotify-tools \ +# python-cups \ +#&& rm -rf /var/lib/apt/lists/* # This will use port 631 EXPOSE 631 @@ -35,4 +48,3 @@ RUN sed -i 's/Listen localhost:631/Listen 0.0.0.0:631/' /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 b756887..697c6ef 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# chuckcharlie/cups-airprint-brother +# chuckcharlie/cups-avahi-airprint Fork from [quadportnick/docker-cups-airprint](https://github.com/quadportnick/docker-cups-airprint) -This Ubuntu-based Docker image runs a CUPS instance that is meant as an AirPrint relay for printers that are already on the network but not AirPrint capable. The other images out there never seemed to work right and didn't support many Brother printers. I forked the original to add more printer support, use the latest Ubuntu base, and work on more host OS's. +This Alpine-based Docker image runs a CUPS instance that is meant as an AirPrint relay for printers that are already on the network but not AirPrint capable. The other images out there never seemed to work right. I forked the original to use the Alpine instead of Ubuntu and work on more host OS's. ## Configuration @@ -24,10 +24,11 @@ docker run --name cups --restart unless-stopped --net host\ -v :/config \ -e CUPSADMIN="" \ -e CUPSPASSWORD="" \ - chuckcharlie/cups-airprint-brother:latest + chuckcharlie/cups-avahi-airprint:latest ``` ## Add and set up printer: * CUPS will be configurable at http://[host ip]:631 using the CUPSADMIN/CUPSPASSWORD. * Make sure you select `Share This Printer` when configuring the printer in CUPS. +* ***After configuring your printer, you need to close the web browser for at least 60 seconds. CUPS will not write the config files until it detects the connection is closed for as long as a minute.*** diff --git a/root/root/printer-update.sh b/root/root/printer-update.sh index f3b70a0..99f23a8 100644 --- a/root/root/printer-update.sh +++ b/root/root/printer-update.sh @@ -1,5 +1,5 @@ -#!/bin/bash -inotifywait -m -e close_write,moved_to,create /etc/cups | +#!/bin/sh +/usr/bin/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 diff --git a/root/root/run_cups.sh b/root/root/run_cups.sh index 61b5f53..a6837f3 100644 --- a/root/root/run_cups.sh +++ b/root/root/run_cups.sh @@ -3,18 +3,19 @@ set -e set -x if [ $(grep -ci $CUPSADMIN /etc/shadow) -eq 0 ]; then - useradd -r -G lpadmin -M $CUPSADMIN + adduser -S -G lpadmin --no-create-home $CUPSADMIN fi echo $CUPSADMIN:$CUPSPASSWORD | chpasswd mkdir -p /config/ppd mkdir -p /services +rm -rf /etc/avahi/services/* rm -rf /etc/cups/ppd ln -s /config/ppd /etc/cups -if [ ls /services/*.service ]; then +if [ `ls -l /services/*.service 2>/dev/null | wc -l` -gt 0 ]; then cp -f /services/*.service /etc/avahi/services/ fi -if [ ! -f /config/printers.conf ]; then +if [ `ls -l /config/printers.conf 2>/dev/null | wc -l` -eq 0 ]; then touch /config/printers.conf fi cp /config/printers.conf /etc/cups/printers.conf