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. 

 

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

 

 

 

Read 5165 times Last modified on Monday, 25 January 2016 18:45
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.