Thursday, 21 January 2016 17:28

Network Printer Server (using Cups) on an Asuswrt Router : FAIL

Written by 
Rate this item
(1 Vote)

How-To: Install and Setup a Network Print Server on your Asuswrt Router

Installing CUPS directly on the wrt linux router with these instructions

I was planning on installing CUPS via entware on my Asuswrt router.  It was a FAIL, but I documented my progress for reference.

I attempted to document some of the details of my failure after the fact.  As a solution I ended up installing CUPS onto a raspberry pi instead.

 

I have an older HP USB only laserjet printer that I had originally connected to my virtual machine computer server.  Using CUPS (common unix printing system) I was able to access my USB only printer throughout my network, as long as my vm machine was on.  It worked great but moving on to the present, nowadays I occasionally do not have my vm server running, but still require access to my printer.  I recently installed a formatted USB thumb drive into my router and installed entware.  Using entware allows you to install a number of applications onto the router, everything from nano to asterisk. 

 

Update 2017.10.1

- A person was kind enough to email me some information on his findings, he was able to get it to work.  See the bottom of the article for the details he sent me. 

 

Install a USB thumb drive onto the router

You'll need a formatted USB thumb drive to be able to install applications such as CUPS onto the router.  It needs to be formatted as an Ext2 filesystem.  I went and created 2 partitions for my needs, you can find instructions on what I did here.

 

Install Entware

Entware is a software repository for routers running WRT firmware.  It allows a wide variety of software applications to be installed directly onto the router.  It's a "modern alternative" to Optware.

Plug in the formatted USB drive, SSH into your router and run the entware script.

entware-setup.sh

The script will require you to select which USB partition to install entware on.  (In my case it was a partition labelled entware).

 

Once the script is completed, you should be able to access the entware filesystem any time by cd'ing to the linked /opt directory.

cd /opt

In my case I end up in /tmp/mnt/entware/entware (my USB partion is mounted as entware, which holds a directory named entware...a bit confusing due to labelling the partition on my part) Note, all your applications you install using entware will use this, in my case /tmp/mnt/entware/entware as its root directory.  Don't make the mistake as I initially did when searching for config files for certain applications in the routers root directory /tmp.

 

Install and configure CUPS

Unlike using the command apt-get to install applications (like in Ubuntu which I am more familiar with) entware uses opkg.  It's still just a easy to use.

Update the repository list of applications

opkg update

 

Install CUPS

opkg install cups

*It was downloading and installing

http://entware.wl500g.info/binaries/entware/cups_2.0.3-1_entware.ipk

 

After installation, even before modifying anything I ran

cupsd -t

and it came back with "/opt/etc/cups/cups-files.conf" contains errors.

 

Edit the cupsd.conf file

nano /opt/etc/cups/cupsd.conf

Here is my original cupsd.conf file, with my new edited file below.

########################################################################
#                                                                      #
# This is the CUPS configuration file.  If you are familiar with       #
# Apache or any of the other popular web servers, we've followed the   #
# same format.  Any configuration variable used here has the same      #
# semantics as the corresponding variable in Apache.  If we need       #
# different functionality then a different name is used to avoid       #
# confusion...                                                         #
#                                                                      #
########################################################################

AccessLog syslog
ErrorLog syslog
LogLevel info
PageLog syslog
PreserveJobHistory No
PreserveJobFiles No
AutoPurgeJobs Yes
MaxJobs 25
MaxPrinterHistory 10
#Printcap /etc/printcap
#PrintcapFormat BSD
#RequestRoot /opt/var/cups
RequestRoot /opt/var/spool/cups
#RemoteRoot remroot
User nobody
Group nogroup
RIPCache 512k
TempDir /opt/var/cups
Port 631
HostNameLookups Off
KeepAlive On
Browsing On
BrowseProtocols cups

<Location />
Order Deny,Allow
Allow From 127.0.0.1
#Allow From 192.168.1.0/24 <-- I commented out this line
Allow From 192.168.138.0/24 <-- and changed to my actual network address, edit this to match your actual network address
</Location>

<Location /admin>
AuthType Basic
AuthClass System
Order Allow,Deny
Allow From All
</Location>

 

Anytime you make changes to the cupsd.conf file you must restart the cups service.  (Instead of it just being called cupsd, when I installed it, it is labelled S60cupsd, YMMV)

/opt/etc/init.d/S60cupsd restart

 

Troubleshooting

I first attempted to remove the /opt/etc/cups/cups-files.conf in an attempt just to get cups running

mv /opt/etc/cups/cups-files.conf /opt/etc/cups/cups-files.conf.old

 

I again ran

cupsd -t 

admin@router:/tmp/home/root# cupsd -t
"/opt/etc/cups/cups-files.conf" is OK.
"/opt/etc/cups/cupsd.conf" is OK.

At this point I should be able to browse to http://myroutersip:631 and see the CUPS index page, but instead I received a "Not Found".  Interestingly enough I was able to see the admin page http://myroutersip:631/admin but it was not formatted, the stylesheet was missing.

 

Next I viewed the error log

cat /opt/var/log/cups/error_log

I found numerous errors including the fact items in cupsd.conf that should now actually be in cups-files.conf and cupsdLoadBanners: Unable to open banner directory "/opt/share/cups/banners": No such file or directory

I also used a plugin (Inspect Element in Firefox) on my browser to see what files were not loading on the webgui.

 

So I looked for the banners and stylesheet files

find / -name "banners"

No banners directory exsists...

find / -name "cups.css"

doesn't exsist either...

 

I attempted to clean up the conf files some more, but I wasn’t getting very far.  I could've also possibly copied over some files from another CUPS installation, but it was getting late.  I finally I gave up any further attempts at troubleshooting and removed the install package

opkg remove cups
rm -r /opt/etc/cups

 

Depending on the project, I usually will continue my troubleshooting in an attempt to get things working properly, but in this case, I had a raspberry pi laying around, and my time was more valuable than the efforts to continue on.  I also read in some random forums that some people did not recommend CUPS running on the router anyhow due to resource issues. Onto my next project...

If anyone has any comments or suggestions, I'd love to know what I was missing...

 

 

 

References:

https://github.com/RMerl/asuswrt-merlin/wiki/Entware

https://help.ubuntu.com/lts/serverguide/cups.html

 

Updated Information from someone who was able to get this to work:

Hello,
 
I'd just like to let you know that CUPS on Entware is in the meantime working (not directly but after some changes). Configuration files (cupsd.conf and cups-files.conf) still have to be changed, but at least web interface is included.
 
admin@RT-AC68U:/tmp/home/root# find / -name "cups.css"
/tmp/mnt/ASUS/entware/share/doc/cups/cups.css
 
There is no need to remove cups-files.conf completely, because mentioned error is coming from invalid line:
SystemGroup lpadmin sys root
 
I have changed it to: 
SystemGroup admin root
 
I'm not sure if it's exactly how it should be (it also works with a single 'admin' or 'root' or even disabled completely with #), but at least it doesn't throw up errors anymore.
 
Still, in web interface I could only see LPT and USB generic printers and not Brother. Searching for new printers results in "No printers found". The problem was that CUPS didn't have access to printer.
 
Check printer's ID (in my case it was vid 0x04F9 pid 0x01CE): 
admin@RT-AC68U:/tmp/home/root# dmesg
usblp0: USB Bidirectional printer dev 3 if 0 alt 0 proto 2 vid 0x04F9 pid 0x01CE
scsi2 : usb-storage 2-2:1.2
scsi 2:0:0:0: Direct-Access    Brother  DCP-135C        1.00 PQ: 0 ANSI: 2
sd 2:0:0:0: Attached scsi generic sg1 type 0
sd 2:0:0:0: [sdb] Attached SCSI removable disk
usbcore: deregistering interface driver usblp
usblp0: removed
usblp0: USB Bidirectional printer dev 3 if 0 alt 0 proto 2 vid 0x04F9 pid 0x01CE
usbcore: registered new interface driver usblp
 
Get bus and device ID based on vid & pid from previous step (here is bus = 002 and device = 003): 
admin@RT-AC68U:/tmp/home/root# lsusb
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 001: ID 1d6b:0001
Bus 001 Device 002: ID 0781:5567
Bus 002 Device 003: ID 04f9:01ce
 
So I changed printer's device permissions:
admin@RT-AC68U:/tmp/home/root# chmod 0666 /dev/bus/usb/002/003
 
After that go to CUPS webinterface, Find new printers and Brother is now listed. Tested printing and works perfectly! The only negative side is that /dev/bus/usb permissions are being lost on reboot, so it has to be set on each start-up (using /jffs/scripts/services-start script).

 

 

Read 5913 times Last modified on Wednesday, 18 October 2017 21:08
Algis Salys

Creator and owner of algissalys.com.  Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.