Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 496 - (hide annotations) (download) (as text)
Tue Jun 10 12:21:25 2008 UTC (15 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 1607 byte(s)
-fixed lpd dir cleanup

1 niro 496 # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/config_printers.sh,v 1.3 2008-06-10 12:21:25 niro Exp $
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 386 esac
29    
30     # now add new printers (writing printers.conf)
31 niro 483 add_printcap "# alxconfig printer id=${printer} name=${cfg_printers_printer_name}"
32     # printer name
33     add_printcap "${cfg_printers_printer_name}|ALX auto-configured printer id=${printer}"
34     # port
35     add_printcap " :lp=${port}"
36     # spooler dir
37     add_printcap " :sd=/var/spool/lpd/${printer}"
38     # error log
39     add_printcap " :lf=/var/log/lp-errs"
40     # page length
41     #add_printcap " :pl=#66"
42     # page width
43     #add_printcap " :pw=#80"
44     # cost per page
45     #add_printcap " :pc=#150"
46     # maximum file size
47     #add_printcap " :mx=#0"
48     # suppress page header
49     add_printcap " :sh"
50     # empty line as spacer for the next one
51     add_printcap
52    
53     # now create the spooler dir
54     install -o lp -g lp -d /var/spool/lpd/${printer}
55     chmod 0700 /var/spool/lpd/${printer}
56 niro 386 done
57     }