Contents of /alx-src/trunk/tinyalxconfig-ng/functions/config_printers.sh
Parent Directory | Revision Log
Revision 483 -
(show annotations)
(download)
(as text)
Sat Jun 7 16:59:07 2008 UTC (15 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 1592 byte(s)
Sat Jun 7 16:59:07 2008 UTC (15 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 1592 byte(s)
- make use of new the mysql-function evaluate_table_xml() - do not split in a retrieve information and configure function; doing it directly
1 | # $Header: /home/cvsd/alx-cvs/alx-src/tinyalxconfig-ng/functions/config_printers.sh,v 1.2 2008-06-07 16:59:07 niro Exp $ |
2 | # configures printing on the host via mysql db settings |
3 | |
4 | add_printcap() |
5 | { |
6 | echo "$@" >> /etc/printcap |
7 | } |
8 | |
9 | config_printing() |
10 | { |
11 | local printer_list |
12 | local port |
13 | |
14 | # first of all delete all printers - printcap and spooler dirs - |
15 | :> /etc/printcap |
16 | find /var/spool/lpd -type d | xargs rm -rf |
17 | |
18 | 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 | |
23 | # get real port settings |
24 | case ${cfg_printers_port} in |
25 | lpt1) port="/dev/lp0" ;; |
26 | com1) port="/dev/ttyS0" ;; |
27 | com2) port="/dev/ttyS1" ;; |
28 | esac |
29 | |
30 | # now add new printers (writing printers.conf) |
31 | 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 | done |
57 | } |