AirPrint and AirPlay on FreeNAS

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
  • 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 --no-check-certificate
  • 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.