lpadmin/cups problem

Per Foreby perf at ddg.lth.se
Wed Jan 31 16:57:40 CET 2007


On Wed, 31 Jan 2007, Lou Ruppert wrote:

> Per Foreby a écrit :
>> I'm trying to setup printers during the installation, using "$ROOTCMD
>> lpadmin ...".
>>
>> What I do now is to create /INSTALL.NEW at the end of the
>> installation, and make that file trigger "fai softupdate" at the first
>> boot, but it would of course be nice to avoid that extra stage.
>
> I found the same problem.  What I've been doing is creating an init
> script to run on the first reboot of the machine, which then finishes
> the job when CUPS is running.  The script then deletes itself when it's
> finished.  Here's an example install script from FAI:
>
> #!/bin/sh
> #
> # We copy an init script to do the dirty work on reboot, so that we have
> CUPS
> # running properly, and so on.  It's a dirty hack, but it works.
> fcopy /etc/rc2.d/S20installprinter
>
> And the script in question:
> #!/bin/sh
> /usr/sbin/lpadmin -E -plab -D"HP Laser Printer" -vparallel:/dev/lp0
> -P/usr/share/ppd/hpijs/HP/HP-LaserJet_4V-hpijs.ppd
> /usr/bin/cupsenable lab
> /usr/sbin/lpadmin -d lab
> rm /etc/rc2.d/S20installprinter
>
> Same strategy works for other things which require a running system to
> pull off.

Thanks, as you say, on less reboot. I try to use the same config for 
install and softupdate, but you solutions could easily be tweaked into 
running the script immediately on a softupdate:

   fcopy /etc/rc2.d/S20installprinter
   if [ "$FAI_ACTION" == "softupdate" ]; then
     /etc/rc2.d/S20installprinter
   fi

To those who suggested fcopy/ftar: I try to avoid that approach for 
configuration files. The reason is maintainability. With fcopy most of 
the files need to be replaced when upgrading to a new debian version. 
However, using cfengine, debconf and configuration utilies like lpadmin, 
most of the local changes survive the upgrade. And I do of course have 
the same possibility to take advantage of the class hieracy in shell 
scripts (ifclass CLASS) and cfengine scripts (CLASS::).

Cups is an excellent example: The upgrade from sarge to etch (cups 
1.1.23 to 1.2.7) is a major cups upgrade, and the config files are 
probably not portable, but the lpadmin approach is.

/Per


More information about the linux-fai mailing list