Latest News:
2019-02-21: XigmaNAS 11.2.0.4.6536 - released!

Latest BETA Release:
2019-02-21: XigmaNAS 12.0.0.4.6536 - BETA released!

We really need "Your" help on XigmaNAS https://translations.launchpad.net/xigmanas translations. Please help today!

Producing and hosting XigmaNAS cost money, please consider a donation to our project so we can continue to offer you the best.
We need your support! eg: PAYPAL

[HOWTO] Use NAS4Free as a CUPS server for all devices

XigmaNAS Packages
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
bjwil1991
NewUser
NewUser
Posts: 2
Joined: 05 Mar 2015 04:34
Status: Offline

[HOWTO] Use NAS4Free as a CUPS server for all devices

#1

Post by bjwil1991 » 05 Mar 2015 19:38

Hello everyone:

First time poster here, and long time NAS4Free user (formally FreeNAS). If you want to have a multi-function NAS4Free system, like a file and print server, you're in luck. Today's topic is installing CUPS for the print service in NAS4Free as the printer server.

Here are the list of packages required for your setup:

Recommended: Set up a Static IP for your NAS4Free box since the OS can constantly change the IP address after a reboot or a power on, as well as the DNS server(s).

Code: Select all

cups <-- Core components
py27-cups <-- Required for the AVAHI service
gutenprint-cups <-- Lexmark, Epson, Canon, Sony, Olympus, and PCL printers
avahi <-- AirPrint Serive for iOS 4.2 and higher (iOS 6 and above, read the step for setting up AirPrint for the iOS 6+ devices)
hplip <-- HP Printers
Step 1: Basic Setup and Installation of packages

Login to your NAS4Free box via your web browser of your choice: http{s*}://{your-NAS4Free-IP_address}:{port**}

* If you set up your NAS4Free box to use HTTPS, type in https, otherwise, use HTTP.
** Custom port number must be entered if you used a custom port number other than 80 (HTTP) or 443 (HTTPS)

Go to Access > Users and Groups

Click On Groups and click on the Add (+) Button.
Type in your group name, group ID (leave as-is), and type in a description, click on Add and apply
  1. Create a new user by clicking the Add (+) Button
  • Type in the login name of user (ex: john)
  • Type in the full name (ex: John Smith)
  • Type and Re-enter your desired password (ex: VirginaCompany)
  • Specify a User ID, or leave as-is
  • Specify a shell login (bash is recommended)
  • Select your primary group (ex: virginiacompany)
  • Select the additional groups wheel and sshd (recommended for logging in via ssh and for running su - root)
  • Setup a home directory for read-write access for your user (ex: /home/john)
  • *Optional, but recommended* tick the box to allow the user to access the user portal
Click on Add and apply

Go to Services > SSH

Click on Enable, and click on Save and Restart

Sign in to your NAS4Free box on your computer that is either running Windows, Linux, Mac OS X or UNIX via ssh

Windows: download and run PuTTY, and type in the IP Address of your NAS4Free box, and select SSH, and click on open.
Type in your username and password
Linux, Unix, and Mac OS X: Run a terminal and type in the following:

Code: Select all

ssh -l username ip-address
Where username is your newly created username and ip-address is your NAS4Free IP Address and type in your password to login.

Enter the following command to install the packages:

Code: Select all

pkg install foomatic-filters cups avahi gutenprint-cups hplip py27-cups
Note: the jail doesn't have the package installer, so the command above would install the package installer command and the packages themselves.

* Install this package if you have Canon, Sony, Olympus, PCL, Lexmark, or Epson printers.
** Install the hplip package if you have Brother or HP Printers.

After the packages have installed, reboot your NAS4Free system for the package installations to take effect, same as the path for the commands, like hp-setup.

Step 2: Configuring CUPS, DEVfs, rc.conf

Login as root by typing in:

Code: Select all

su - root
Type in root's password (nas4free)

move the cupsd.conf file and make a new one:

Code: Select all

mv /usr/local/etc/cups/cupsd.conf /usr/local/etc/cups/cupsd.bak
nano /usr/local/etc/cups/cupsd.conf
Copy and paste the contents for the new cupsd.conf file:

Code: Select all

#
# "$Id: cupsd.conf.in 11025 2013-06-07 01:00:33Z msweet $"
#
# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
# complete description of this file.
#

# Log general information in error_log - change "warn" to "debug"
# for troubleshooting...
LogLevel warn

DefaultEncryption Never

# Only listen for connections from the local machine.
Listen *:631
Listen /var/run/cups.sock

# Show shared printers on the local network.
Browsing On
BrowseLocalProtocols dnssd

# Default authentication type, when authentication is required...
DefaultAuthType Basic

# Web interface setting...
WebInterface Yes

# Restrict access to the server...
<Location />
  Order allow,deny
  Allow @LOCAL
</Location>

# Restrict access to the admin pages...
<Location /admin>
  Order allow,deny
  Allow @LOCAL
</Location>

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
  Allow @LOCAL
</Location>
Press Ctrl + O to save, and Ctrl + X to exit

make a new file called devfs.rules

Code: Select all

touch /etc/devfs.rules
nano /etc/devfs.rules
Copy and paste the following:

Code: Select all

[system=10]
add path 'unlpt*' mode 0660 group cups
add path 'ulpt*' mode 0660 group cups
add path 'lpt*' mode 0660 group cups
add path 'usb*' mode 0770 group cups
add path 'ugen*' mode 0660 group cups
add path 'usb/X.Y.*' mode 0660 group cups
X and Y are the usb connections

Type in:

Code: Select all

dmesg | grep ugen
and you will get the following line:

Code: Select all

ugen0.2: <Hewlett-Packard> at usbus0
Save the file and exit nano

Like in step 1, make a user and a group called cups

Login to NAS4Free via web interface, go to access > users and groups

Syntax for cups:

Groups tab

group name: cups
group ID: 1001
description: cups

Add and apply

Username: cups
Name: cups
user ID 1001
shell: nologin
primary group: cups
additional group: wheel

Add and apply

Restart both CUPS and devfs:

Code: Select all

/etc/rc.d/devfs restart
/usr/local/etc/rc.d/cupsd restart
Go to System > Advanced and click on rc.conf

Add the following variables and values:
  • Variable---------------------Value
  1. avahi_daemon_enable-----YES
  • cupsd_enable----------------YES
  • devfs_enable----------------YES
  • devfs_system_ruleset------system
Reboot to apply settings.

Step 3: Adding and testing printers, and enabling Avahi (AirPrint)

To access the CUPS print server, type in http://ipaddress:631

Go to Administration and click on Add Printers. If prompted for a username and password, enter root and the password for root (default nas4free)

After the packages are installed, and the printers are connected via USB, LPT, or some other means, it's time for adding the printer.

Normally, people would select the USB Printer #n (no restart) for their USB printers, which limits functionality, such as network scanning. With the proper packages installed, the printer would show up in this style format:

Code: Select all

HP PSC 750 USB MY28OD321XWB HPLIP (HP PSC 750)
Click on your printer name, and click on continue.

The connection type will be in the following format with the proper configuration done in Step 2:

Code: Select all

hp:/usb/PSC_750?serial=MY28OD321XWB
Give your printer a name (ex: PSC-750), Description (ex: HP PSC 750), and Location (optional). Tick on the share this printer to everyone, and click continue. Select your vendor for the driver installation, which uses PPD (PostScript Printer Description) file format, and your printer model.

Click on continue to go to the next page, which is defining the defaults for the printer, such as ink quality and speed ratings, double-sided printing, duplex installed, etc. and click on Add. If all goes well, you have successfully installed a printer in CUPS.

Now, click on your Queue Name (Printer), and under Maintenance, click on print test page. It'll say that the print job is being processed and is printing. If you get this error:

Code: Select all

Paused - "Filter Failed"
Then in ssh, type in:

Code: Select all

nano /usr/local/etc/foomatic/filter.conf
And uncomment the line that reads:

Code: Select all

#cupsfilterpath: /usr/local/lib/cups/filter:/usr/local/lib/cups/filter:/usr/local/libexec/cups/filter:/opt/cups/filter:/usr/lib/cups/filter
into:

Code: Select all

cupsfilterpath: /usr/local/lib/cups/filter:/usr/local/lib/cups/filter:/usr/local/libexec/cups/filter:/opt/cups/filter:/usr/lib/cups/filter
Now, it's time for configuring and enabling Avahi.
  1. Use the following command to add the following line in avahi-daemon.conf

    Code: Select all

     nano /usr/local/etc/avahi/avahi-daemon.conf
  • Disable dbus support by inputting the following line under the server category:

    Code: Select all

    enable-dbus=no
For iOS 6 and above, the following must be entered for URF support:

Code: Select all

echo "image/urf urf string(0,UNIRAST<00>)" > /usr/local/share/cups/mime/airprint.types
echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/local/share/cups/mime/airprint.convs
To announce your printer(s) in the network using Avahi, the following python script must be enforced for your iDevice to search and print to the priner(s) and this should be done via ssh.

Code: Select all

cd /root/
 
wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
python airprint-generate.py
mv AirPrint-*.service /usr/local/etc/avahi/services/
chmod 444 /usr/local/etc/avahi/services/AirPrint-*.service
Avahi decides it's all fun and games to announce the SSH server, so disable this by entering the following commands:

Code: Select all

cd /usr/local/etc/avahi/services/
mv ssh.service ssh.service_bak
mv sftp-ssh.service sftp-ssh.service_bak
Configure the Avahi-Daemon to allow your interfaces and disable dbus:

Code: Select all

nano /usr/local/etc/avahi/avahi-daemon.conf
Uncomment the following lines and alter them as needed:

Code: Select all

#allow-interfaces=eth0
allow-interfaces=<interfaces>
#enable-dbus=yes
enable-dbus=no
Where <interface> is your wireless, or wired connection by typing in the command:

Code: Select all

ifconfig | more
Start the avahi-daemon service by entering the command:

Code: Select all

/usr/local/etc/rc.d/avahi-daemon start
If you get the following message when starting the avahi-daemon:

Code: Select all

Starting avahi-daemon:
Timeout reached while wating for return value
Could not receive return value from daemon process. 
Remove and re-install the packages in the list below:

Code: Select all

pkg delete dbus
pkg install foomatic-filters cups avahi gutenprint-cups hplip py27-cups dbus
Then startup the avahi-daemon:

Code: Select all

/usr/local/etc/rc.d/avahi-daemon start
And this would be the output when starting the daemon:

Code: Select all

nas4free ~ # /usr/local/etc/rc.d/avahi-daemon start
Starting Avahi-Daemon:
nas4free ~ #
Reboot for setting to take effect; test your iDevice to see if it does print to the CUPS printer.
Last edited by bjwil1991 on 07 Mar 2015 03:25, edited 3 times in total.

User avatar
MikeMac
Forum Moderator
Forum Moderator
Posts: 498
Joined: 07 Oct 2012 23:12
Location: Moscow, Russia
Contact:
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#2

Post by MikeMac » 05 Mar 2015 21:41

Hi, bjwil1991

Thank you for interesting HowTo. If I understand right, one is not intended for embedded install, isn't it?

Also I had noticed word "jail" in the original post. Had you tried this HowTo in jail?

bjwil1991
NewUser
NewUser
Posts: 2
Joined: 05 Mar 2015 04:34
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#3

Post by bjwil1991 » 06 Mar 2015 02:53

This is only intended for the full install, not the embedded install, yes. It wouldn't hurt to install the packages with the embedded installation, but I'm not sure if that'll work or not. As for the jail HowTo, I just installed the extension called TheBrig by looking at this forum: viewtopic.php?t=3894 I might as well test the iPad to see if it'll print with either the Jail or the non-jail connections.

Edit: tested the iPad for printouts and it prints. Just had a little issue with the initialization of the avahi-daemon.

User avatar
MikeMac
Forum Moderator
Forum Moderator
Posts: 498
Joined: 07 Oct 2012 23:12
Location: Moscow, Russia
Contact:
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#4

Post by MikeMac » 06 Mar 2015 16:56

bjwil1991 wrote:It wouldn't hurt to install the packages with the embedded installation
I am afraid, it would :(
RAMdisk is limited and packages installation could easily make it full. Good thing about embedded installation - reboot will heal such problems.

Even for full install pkg install could easily prevent NAS from normal working. From the other hands, jails are recommended way to expand nas4free functionality. Virtually nothing in jail could hurt normal nas4free work.

So if your HowTo could be rewritten for jail - one could become very helpful.

StanEsmith
Starter
Starter
Posts: 29
Joined: 13 Mar 2015 16:13
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#5

Post by StanEsmith » 01 Apr 2015 17:13

Has anyone yet tried to install cups via a jail yet?

jamaroney
Advanced User
Advanced User
Posts: 191
Joined: 13 Aug 2012 17:32
Location: Stroudsburg, PA
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#6

Post by jamaroney » 17 Aug 2015 04:15

I tried the following command:

nas4free: ~ # /etc/rc.d/devfs
/etc/rc.d/devfs: Command not found.

So I simply enter:
nas4free: ~ # devfs
usage: devfs rule|ruleset arguments

I then enter:
nas4free: ~ # devfs restart
devfs: unknown command: restart

What's going on?

User avatar
F8BOE
experienced User
experienced User
Posts: 106
Joined: 03 Jun 2013 23:09
Location: France
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#7

Post by F8BOE » 14 Sep 2015 12:40

Hello,

I tried it for some time now under N4F 9.2 but TheBrig wasn't able to find the packages because of a faulty configuration of the "package folder" pointing to an empty folder on the mirrors... So I gave up at first...
A simpler way could be CUPS as extension to avoid running two OSes at a time on older computers, but there's still nothing new in this direction.

A way to go could be to get a Raspberry Pi/Pi2 and install CUPS and why not Saned to get a full tilt setup to print and scan over the network in an Unix/Linux only environment.

Ciao @+

jamaroney
Advanced User
Advanced User
Posts: 191
Joined: 13 Aug 2012 17:32
Location: Stroudsburg, PA
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#8

Post by jamaroney » 31 Dec 2015 17:36

Tried this w/N4F full install (latest version). After setting up printer, when I try to have it print anything, the printer gives its customary light blink acknowledging the print command, but then nothing further happens. However, the CUPS page states that the job has successfully completed.

Help!

jamaroney
Advanced User
Advanced User
Posts: 191
Joined: 13 Aug 2012 17:32
Location: Stroudsburg, PA
Status: Offline

Re: [HOWTO] Use NAS4Free as a CUPS server for all devices

#9

Post by jamaroney » 04 Jan 2016 12:26

After much wrangling, I gave up on CUPS and set up a LPRng Spooler via viewtopic.php?f=55&t=364 for my N4F 10.2 embedded install. Many of the steps within the directions were based on old FreeNas builds, and are no longer needed. It's perfect for my all-Windows environment, and was easy to set up.

Post Reply

Return to “Packages”