I would like to add AirPrint support to a legacy Brother network printer and, if possible, also have AirPlay audio streaming to a stereo on the same shelf. I ran across a great tutorial on how to do just that by installing CUPS (for AirPrint) and Shairport (for AirPlay) on a Pogoplug with Arch Linux. This made me wonder if the ever more extensible FreeNAS platform could be coaxed into doing the same thing -- I already have a FreeNAS server for backups and rather than having a Pogoplug and my server running at the same time, having everything run on one device seems more efficient. However, I have been unable to find any tutorials aimed at accomplishing this goal.

Is there a relatively straightforward way to get CUPS and Shairport on FreeNAS 9 (perhaps in a "jail")?

| |

Following @Roland Smith's suggestion, I created a portsjail on my FreeNAS. I gave the portsjail a static IP address, disabled VIMAGE and set the default gateway. I then went into the FreeNAS web-based shell and did the following:

  • Type jls, note the number of the jail and then type jexec [number] sh.
  • Once in the jail type pkg install cups hplip py27-cups.
  • Next utilize the CUPS.conf from the tutorial mentioned in my question:

    cd /usr/local/etc/cups
    mv cupsd.conf cupsd.conf.org
    wget http://dl.dropbox.com/u/42238/pogoplug/cupsd.conf
  • Follow the steps in the FreeBSD tutorial on CUPS, save for the part concerning SMB sharing to finish setting up CUPS. Finishing by starting CUPS:

    /etc/rc.d/devfs restart
    /usr/local/etc/rc.d/cupsd restart
  • Then, log into http://[hostname]:631 and set up the printer (unfortunately, CUPS auto detection of network devices doesn't seem to be working in my BSD jail, so I had to manually set up the Brother MFC-7820N using the HP JetDirect option. I printed a test page to confirm my printer was working. I set the printer to be shared during the setup and enabled sharing on the main CUPS administrative web page.

  • To provide for iOS 6 and above support, enter the following, slight variation to the most common fix in the jailed shell:

    echo "image/urf urf string(0,UNIRAST<00>)" > /usr/share/cups/mime/airprint.types
    echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/share/cups/mime/airprint.convs
  • Now, use the handy AirPrint generator to create an Avahi service advertisement:

    cd /
    wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
    python AirPrint-generate.py
  • Next, exit the jail to return to the main server. Then, I copied the AirPrint service to the server's own avahi system (since running Avahi in the jail doesn't seem to work reliably). However, because the /etc/ folder is recreated each time FreeNAS starts, instead of copying it directly, we need to create a Pre-Init script on the FreeNAS to copy it on startup. To do that, login the FreeNAS administrative interface again, click on the System category and then "Add Init/Shutdown Script," set the type to "Pre Init" and enter the following as the command:

    cp [PathToYourJail]/usr/local/etc/avahi/services/AirPrint-*.service /etc/local/avahi/services
  • Click "OK," reboot and you should find that your AirPrint device(s) are now being broadcast by the FreeNAS.

  • From there, you should be good to go!

I've linked to my two remaining SuperUser questions concerning CUPS auto discovery and Avahi shutting down within the jailed environment. If anyone has suggestions on how to resolve those problems, I'd be grateful, however those do not prevent the above from working, they simply make it unnecessarily inelegant.

I have not yet tried to see if it is possible to get audio support to work on FreeNAS for AirPlay; I may try that at some point still.

| |
  • 1
    To add to Timothy's very helpful answer (I can't comment on it with this website since I don't have enough "Reputation" points), for me in a jail on FreeNas, the cups MIME configuration directory was "/usr/local/etc/cups" and not "/usr/share/cups/mime/". – Greg Quinn Dec 15 '13 at 4:53
  • With Freenas 9.3, restarting devfs doesn't work (devfs rule: ioctl DEVFSIO_RGETNEXT: Operation not permitted). Seems some stuff has changed with BSD 10.0... – damian Jan 6 '15 at 19:14
  • 1
    Thanks, CUPS seems to be working. To print from OSX I had to point the Printers & Scanners GUI at IPP address http://freenas.local:631/printers/<printerName>, then change the the driver to raw on the OSX client (which required doing sudo cupsctl WebInterface=yes on the OSX client then going to http://localhost:631). I can't figure out how to get the devfs rules to apply in the jail though, so I have to manually chmod a+rw /dev/ulpt0 in the jail every time it starts. – damian Jan 10 '15 at 17:57
  • 1
    pkg install cups hplip py27-cups gives me an error: "No packages matching 'py27-cups' have been found.." any idea? – Quest Jan 27 '16 at 21:13

Both CUPS and shairport are available in the FreeBSD ports collection.

You can install them on FreeNAS as documented here.

Using packages is probably the easiest way. If you want to build cups with non-default options, you'll have to build from source.

| |

With regards to the pkg install error "No packages matching 'py27-cups'. The new package is called py27-pycups. That should install.

| |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.