Showing posts with label wzr-hp-g300nh. Show all posts
Showing posts with label wzr-hp-g300nh. Show all posts

Wednesday, 25 January 2012

CUPS + HL-2140 (USB printer) + WZR-HP-G300NH + OpenWRT

Why running CUPS on the router?

I've had a small home server running Ubuntu to server the whole house, but it seems I'm the only one using it fully. I had my Brother HL-2140 connected to the server but since I've some spare room left in the router, why not run the print server on the router?

But why CUPS?

The other option I've is running non-spooling server, p910nd, but I believe I should make full use of the free space/memory on the router. If the router overloaded, I'll consider using p910nd later on.

What needs to be done to get CUPS running?

You need a capable router, WZR-HP-G300NH is one. It has 32MB flash ROM and 64MB RAM. I'm currently running OpenWrt Backfire 10.03.1-RC6 on it.

To install CUPS, just use LUCI to install the cups package.

How about getting the HL-2140 USB printer to work along?

There is nothing special, cups seems to have supported USB printer, so we shouldn't need to install the kmod-usb-printer package. It seems that the CUP's backend needs libusb, so, please install the libusb package.

just install the kmod-usb-printer package from LUCI, this will also install all the required packages such as kmod-usb-core, kmod-usb-ohci and kmod-usb2. If everything working, you'll see the following messages from dmesg or system log:

usblp0: USB Bidirectional printer dev 9 if 0 alt 0 proto 2 vid 0x04F9 pid 0x0033
usbcore: registered new interface driver usblp


There should be new device available: /dev/lp0


If everything works, you'll see your printer when you issue the following command:
root@OpenWrt:/mnt/share# /usr/lib/cups/backend/usb
DEBUG: list_devices
DEBUG: usb_find_busses=1
DEBUG: usb_find_devices=5
direct usb://Brother/HL-2140%20series?serial=F9J555425 "Brother HL-2140 series" "Brother HL-2140 series" "MFG:Brother;CMD:PJL,HBP;MDL:HL-2140 series;CLS:PRINTER;" ""



That is it?

Not so fast young man, there are few more things need to be done especially spooling. Since we've pretty much limited space, adding external USB storage is recommended. I've few USB sticks that I don't really use. So, I got myself a 4-port hub. Stick the 4GB USB stick, format it with ext4 and mount it. To get the USB storage working, I've installed kmod-usb-storage (I believe this will install few other packages too), kmod-fs-ext4 and e2fsprogs (to prepare the USB stick). Format the stick and mount it to /mnt/share and using LUCI, configure to make this mounted during bootup time.

The standard configuration file for CUPS has the USB pointing to /dev/usb/lp0 but OpenWRT has instead created /dev/lp0. So, edit /etc/cups/printers.conf and change that. Otherwise CUPS won't find the USB printer.

Here is my /etc/cups/cupsd.conf configuration file:
AccessLog syslog
ErrorLog syslog
LogLevel info
PageLog syslog
PreserveJobHistory No
PreserveJobFiles No
AutoPurgeJobs Yes
MaxJobs 25
MaxPrinterHistory 10
User root
Group root
RIPCache 512k
TempDir /mnt/share/cups
RequestRoot /mnt/share/cups
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
HostNameLookups Off
KeepAlive On
# Share local printers on the local network.
Browsing On
BrowseOrder allow,deny
BrowseRemoteProtocols
BrowseAddress @LOCAL
BrowseLocalProtocols CUPS
BrowseProtocols cups
< Location />
# Allow shared printing and remote administration...
Order allow,deny
Allow all
< /Location>
< Location /admin>
AuthType Basic
AuthClass System
# Allow remote administration...
Order allow,deny
Allow all
< /Location>
< Location /admin/conf>
AuthType Default
Require user @SYSTEM
# Allow remote access to the configuration files...
Order allow,deny
Allow all
< /Location>


NOTE: The code above won't allow me to have '< >' so, I put a space after the '<' .. So, edit and remove the space if you want to cut and paste my configuration. Yes, I'm allowing everyone to get access to CUPS configuration interface. You're free to edit it for sure. To add the printer, just go to http://your-router-ip-address:631 Go to administration, add printer, select the AppSocket/HP JetDirect option. Remember the output from /usr/lib/cups/backend/usb? Use the URI there and paste it into the "Connection" field. Example, for my printer, the URI returned by the backend command is: usb://Brother/HL-2140%20series?serial=F9J555425

Cut and paste the above into "Connection" field.

Somehow, we're not allowed by cups to have both User and Group to be the same, so to force the the backend to run as root, change the permission for /usr/lib/cups/backend/usb to 700.

Make sure cupsd running, so, fire it up in LUCI under System -> Startup, enable it and click start.

What else need to be done?

I had a problem when trying to print from my Mac, I'm getting an authentication error. Checking the syslog, there is this error: "Returning IPP client-error-not-authorized for Print-Job" and from my Mac, I'm getting "Authentication Required to Print" error. I didn't realised that I did not click on the "Share" option for the printer. So, if you're getting this error.. check if the printer has "Share This Printer" option ticked.

That is all .. have fun to get your printer + CUPS running on your router.

Thanks for the Openwrt wiki, somehow, my previous setup was working great until suddenly it won't print anything after I upgraded my router to the latest 10.03.01 backfire. So, please check for updated guide here:

http://wiki.openwrt.org/doc/howto/cups.server.

Thursday, 19 May 2011

TM/Unifi - Replacing DIR-615 for good

Finally, managed to remove MicroTik Routeboard RB250G from my setup. The old WZR-HP-G300NH router finally get the much needed firmware upgrade to the latest OpenWRT Attitude Adjustment (r26915) bleeding edge release few days ago.  Someone has managed to get his DIR-825 working here and found that DIR-825 uses the same switch as WZR-HP-G300NH. I managed to add the VLAN tagging and VLAN port assignment manually using the same configuration, this was with the older RC release of OpenWRT that I've flashed many moons back.

I've no idea if this will work for other non-Atheros chip, but if you've a wireless router with the Atheros chip, feel free to get into the bleeding edge. Installation was surely not a straight forward, the trunk/bleeding edge releases are usually without Luci (GUI) preinstalled. You've two choices, one is to download the system upgradable release (sysupgrade) and flash your router from the web interface. All you configuration files will be intact if you go by this route, this includes the WAN and LAN interfaces. What you need to do is just to install Luci from opkg. But for those who're 'stupid' enough to go the hard way (as I've chosen to do), you need to download the packages upfront into your local server and point the opkg configuration to retrive the packages from your local server instead.

How to get Unifi working? Well, in the new Luci interface (yes, the Luci interface is much nicer too compared to the stable release), there is a Switch tab under the Network configuration page. This is where you configure the VLAN tagging and VLAN to port assignment.

Here is the sample of the page (yup, this is not mine.. someone has done this before, why reinvent the wheel :)..


From the above screenshot, your IPTV should be connected to the first port while the rest of the ports are free to be used as normal. Have fun flashing and configuring your router and good luck.

Note: I'm not taking any credit on this .. all thanks to the guy who posted this in lowyat forum as per the link above.

Consuming EUDR Webservices from SAP ECC

There are number of us who're still stuck in the old SAP ECC or S/4 Hana on Premise and yet to move into Private or Public Cloud. A rece...