Magellan Linux

Annotation of /alx-src/trunk/tinyalxconfig-ng/functions/config_printers.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1004 - (hide annotations) (download) (as text)
Tue Aug 4 15:17:16 2009 UTC (14 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 1525 byte(s)
-usb-printing support
1 niro 537 # $Id$
2 niro 386 # configures printing on the host via mysql db settings
3    
4 niro 483 add_printcap()
5 niro 386 {
6 niro 483 echo "$@" >> /etc/printcap
7 niro 386 }
8    
9     config_printing()
10     {
11 niro 483 local printer_list
12 niro 386 local port
13    
14 niro 483 # first of all delete all printers - printcap and spooler dirs -
15     :> /etc/printcap
16 niro 496 find /var/spool/lpd/* -type d | xargs rm -rf &> /dev/null
17 niro 386
18 niro 483 printer_list=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'")
19     for printer in ${printer_list}
20     do
21     evaluate_table_xml cfg_printers "where serial='${ALX_SERIAL}' and id='${printer}'"
22 niro 386
23     # get real port settings
24 niro 483 case ${cfg_printers_port} in
25     lpt1) port="/dev/lp0" ;;
26     com1) port="/dev/ttyS0" ;;
27     com2) port="/dev/ttyS1" ;;
28 niro 1004 usb1) port="/dev/usb/lp0" ;;
29 niro 386 esac
30    
31     # now add new printers (writing printers.conf)
32 niro 483 add_printcap "# alxconfig printer id=${printer} name=${cfg_printers_printer_name}"
33     # printer name
34     add_printcap "${cfg_printers_printer_name}|ALX auto-configured printer id=${printer}"
35     # port
36     add_printcap " :lp=${port}"
37     # spooler dir
38     add_printcap " :sd=/var/spool/lpd/${printer}"
39     # error log
40     add_printcap " :lf=/var/log/lp-errs"
41     # page length
42     #add_printcap " :pl=#66"
43     # page width
44     #add_printcap " :pw=#80"
45     # cost per page
46     #add_printcap " :pc=#150"
47     # maximum file size
48     #add_printcap " :mx=#0"
49     # suppress page header
50     add_printcap " :sh"
51     # empty line as spacer for the next one
52     add_printcap
53    
54     # now create the spooler dir
55     install -o lp -g lp -d /var/spool/lpd/${printer}
56     chmod 0700 /var/spool/lpd/${printer}
57 niro 386 done
58     }