Archive for the ‘nslu2’ tag
Popular pages
This website is a sort of personal project, rather than a proper blog – the reason I make this distinction is because I usually don’t have anything interesting to say; at least, nothing that would be of any interest to anyone who doesn’t know me.
Hardcore HTML
I’ve never really had any cause to write large posts using Wordpress, except for my NSLU2 articles – and even then the built-in WYSIWYG editor was good enough, albeit a little clunky and requiring gentle persuasion every so often.
But after changing blog themes the other day, I realised the NSLU2 pages were actually quite dependent on the underlying CSS – and for some themes, this means that they looked rubbish.
Another new look
One of the features of Wordpress is the ability to change the theme of a blog with the click of a button; and that’s exactly what I did when the K2 theme, although quite powerful in its own right, was found lacking again.
With this theme, my NSLU2 articles currently look like they were formatted by a 4-year-old, so I might get round to fixing them, eventually. They’re by far the most popular pages on this site!
Linksys NSLU2: print server with CUPS
Installing and configuring CUPS with an HP PhotoSmart 8150 was ridiculously easy, since CUPS comes complete with HPIJS (the HP linux print drivers). The printer is attached via a USB hub on port 1.
Installing CUPS
First off, install CUPS and its documentation package. Strangely enough, the docs include a lot of the files required to run the CUPS web interface.
ipkg install cups
ipkg install cups-doc
First of all, edit the CUPS config file.
vi /opt/etc/cups/cupsd.conf
There are a few lines which restrict access to CUPS to only the 192.168.0.0/24 network. This is fine for a lot of people, but if your network doesn’t use that range of addresses, you need to edit them accordingly.
Now you need to make sure your printer is connected to the Slug. By default, CUPS has no permissions on the device that represents the printer (/dev/lp0). Fix that with:
chmod 777 /dev/lp0
Next you need to put the startup script in /opt/etc/init.d so that CUPS can start automatically. Most other packages do this as part of their installation/configuration process, but with CUPS this has to be done manually. Also, start CUPS.
cp /opt/doc/cups/S88cups /opt/etc/init.d
/opt/doc/cups/S88cups
Now you can use a web browser to browse to http://your-slug:631 (where your-slug is the host name or IP address of your Slug) and use the CUPS web interface to manage your printer. Under Manage Printers you’ll see there’s already an HP 990c installed. While the HP990c apparently works with the majority of printers, I prefer to use the right driver for my printer – so I deleted the HP 990c, then went through the ‘Adding a printer to CUPS’ process.
Adding a printer to CUPS
From the main page in the CUPS web interface, click Add Printer. You will probably be presented with the message 426 Upgrade Required. This means that CUPS requires that your browser switches from http to https, but can’t do it automatically – you need to click the link, and you’ll be asked to provide a valid username and password to continue. Using root here is fine.
On the page that follows, give your printer a name – bear in mind this name will be part of the printer’s URL, so it can’t contain spaces, hashes or slashes. Provide a description and the location if you want, too.
On the next page, choose your printer from the drop-down list. CUPS queries the printer for this information, so it’s pretty accurate. If your printer isn’t listed, you probably forgot to change the permissions on /dev/lp0 as described above.
CUPS will then display a list of drivers, and you’ll probably not see your printer there. So head over to http://www.linuxprinting.org/printer_list.cgi, search for your printer, and download the PPD file for it. Once that’s done, return to the CUPS page. Click Browse… and select the PPD you downloaded, then click Add Printer. You’re done.
All you need to do now is click the Printers tab at the top of the page, and start your printer if it isn’t already started.
Note that your printer needs foomatic-rip if your Printers page shows a message such as this:
Filter “foomatic-rip” for printer “HP-PhotoSmart-8150″ not available: No such file or directory
My testing showed that my printer worked fine without foomatic-rip, but the printer needed to be started manually every time CUPS (or the Slug) restarted. There is probably a setting in the configuration file to force a printer to attempt to start regardless of errors, but I found installing foomatic-rip to be a cleaner fix:
cd /opt/lib/cups/filter
wget http://www.linuxprinting.org/foomatic-rip
wget http://www.linuxprinting.org/foomatic-gswrapper
chmod 755 foomatic-rip foomatic-gswrapper
/opt/etc/init.d/S88cups restart
No more error message, and the printer starts automatically when CUPS starts.
It is also worth backing up the /opt/etc/cups/printers.conf file. CUPS has a tendency to overwrite it with a file of the wrong format when you click on certain options in the web interface, resulting in 403 Forbidden errors when you try to access the web interface.
cp /opt/etc/cups/printers.conf /opt/etc/cups/printers.conf.backup
Using a CUPS printer in Windows
In Windows Vista, installing the printer is simple. Open the Control Panel, go to Printers, and then Add Printer. Select Add a network, wireless or Blutooth printer, and click Stop on the next page of the wizard; it won’t detect the printer, but you can add it easily, so click The printer that I want isn’t listed.
In the Select a shared printer by name text field, enter http://your-slug:631/printers/printer-name. You need to replace your-slug with either the host name or IP address of your Slug, and printer-name with the printer name you chose. Click Next. You will then be presented with a list of printer drivers to choose from. The list contains all the drivers that shipped with your release of Windows Vista plus all those that you have installed. If you don’t see the right printer driver in the list, visit your printer manufacturer’s website to download the right driver, and install it.
In Windows XP, open the Control Panel, go to Printers and Faxes, and then Add a Printer. Select Connect to a printer on the Internet or on a home or office network, and in the URL field enter http://your-slug:631/printers/printer-name. You need to replace your-slug with either the host name or IP address of your Slug, and printer-name with the printer name you chose.
Windows XP doesn’t have as comprehensive a driver database as Windows Vista, so the likelihood is that your printer won’t be shown in the dialog you see next (unless you had already installed your printer drivers on that computer). Download the drivers from your manufacturer’s website (or use the printer’s driver disk), and select Have Disk. Locate the driver and click OK, then choose the exact printer from the list that follows.
Issues
On Windows XP, certain actions or operations will cause a crash in Word 2003 and Word 2007 if a CUPS printer is installed and set as the default printer, but the CUPS server is unavailable.
The action that triggers the crash does not obviously relate the problem to the printer’s availability, but removing the printer (or setting a different printer to default) will prevent the problem – as will ensuring CUPS is always online and available to Windows XP clients.
This doesn’t seem to happen on Windows Vista.
If this information was useful, please leave a comment to let me know!
Linksys NSLU2: time server with NTP
If you’re running an email server on your Slug, where accurate server time is vital, or you simply want the Slug’s system time to be accurate, you need to make a few changes.
When it comes out of the factory the Slug has an inherrent bug which causes the internal clock to lose time; apparently Linksys tried to fix this problem by adjusting the time regularly (using cron) but it seems the time is adjusted in the wrong direction – thus, the error is doubled. This problem is fixed in Unslung 2.6 and higher anyway (Unslung 2.10 is the latest release as at Jan 2009), so we can remove the relevant crontab entry.
Edit the crontab file:
vi /etc/crontab
Comment out the call to hwclock (the Linksys ‘fix’). The hash (#) symbol is used to denote a comment:
#1 * * * * root /usr/sbin/hwclock -s &>/dev/null
Now install ntpd, and edit the config file to contain time servers that are geographically close to you – you can find out what these are by visiting http://www.pool.ntp.org/. Editing the config file is quite self-explanatory.
install ntp
vi /opt/etc/ntp/ntp.conf
Now edit the ntp startup script; there are a few things we need to do to make sure the time is set and maintained correctly.
vi /opt/etc/init.d/S77ntp
Add the following lines just before the existing call to ntp:
/opt/bin/tickadj 10000 > /dev/null
/opt/bin/ntpd -q -c /opt/etc/ntp/ntp.conf > /dev/null
The first line corrects the Slug’s tick value, and the second line makes ntp quickly (-q) set the time using the specified time servers, and exits. It is important to note that when ntp is running, it does not just simply set the correct time regularly; it constantly checks the time against that of the time servers, and gradually brings the system time in line. The call we just added, with the -q flag, ensures that the Slug has pretty accurate time before ntp starts properly.
Speaking of which, you will need to make sure the Slug has accurate time now. This can be done using the web interface, for example. It only needs to be as accurate as you can get it, and ntp will take care of the rest.
Now simply restart ntp:
/opt/etc/init.d/S77ntp restart
It will take a while for ntp to synchronise with the time servers you specified in the config file, sometimes upwards of 15 minutes – so don’t be too concerned if nothing seems to be happening straight away. You can check what’s going on with the ntpq tool:
ntpq -p
The command will list information about the time servers. If ntp has decided on a server’s suitability for synchronisation, the time server’s name will be preceeded by * (the chosen server), + (server is suitable), or - (server is unsuitable).
Note: if you are running Dovecot on your Slug, and ntp adjusts the time backwards after you initially set the Slug’s time (using the web interface), Dovecot will complain about time going backwards, and die. You will need to restart Dovecot; but this only happens while you’re configuring ntp, and won’t happen during normal operation once ntp is running.
If this information was useful, please leave a comment to let me know!