Contents of /alx-src/branches/alxconf-060/functions/config_printers.sh
Parent Directory | Revision Log
Revision 2147 -
(show annotations)
(download)
(as text)
Tue May 17 11:45:52 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1532 byte(s)
Tue May 17 11:45:52 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1532 byte(s)
-get database data via evaluate_table() function and use the advantages of xml (no problems with empty values anymore)
1 | # $Id$ |
2 | # configures printing on the host via mysql db settings |
3 | |
4 | config_printing() |
5 | { |
6 | local port |
7 | local CONFIG |
8 | local prn_ids |
9 | |
10 | # first of all get the vars |
11 | get_printer_settings |
12 | prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'") |
13 | |
14 | # first of all delete all printers, by wiping /etc/printcap and all spooler directories |
15 | CONFIG=/etc/printcap |
16 | clearconfig |
17 | |
18 | if [[ -d /var/spool/lpd ]] |
19 | then |
20 | rm -rf /var/spool/lpd |
21 | install -d /var/spool/lpd |
22 | install -d /var/spool/lpd/lp |
23 | chown lp:lp /var/spool/lpd/lp |
24 | chmod 0700 /var/spool/lpd/lp |
25 | fi |
26 | |
27 | for i in ${prn_ids} |
28 | do |
29 | evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'" |
30 | # get real port settings |
31 | case ${cfg_printers_port} in |
32 | lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;; |
33 | com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;; |
34 | usb[0-9]*) port="/dev/usb/lp$(( $cfg_printers_port/usb/}-1 ))" ;; |
35 | #lpd) port="lpd://${ip}/${share}" ;; |
36 | #socket) port="socket://${ip}:${share}" ;; |
37 | esac |
38 | |
39 | # now add new printers (writing printcap) |
40 | addconfig "#--- added by alxconfig ---" |
41 | addconfig "${cfg_printers_name}|${cfg_printers_name}" |
42 | addconfig " :lp=${port}" |
43 | addconfig " :sd=/var/spool/lpd/${cfg_printers_name}" |
44 | addconfig "#-----------------------" |
45 | addconfig |
46 | |
47 | # install spooler directories |
48 | install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_name} |
49 | done |
50 | |
51 | # start lprng |
52 | if [[ -n ${prn_ids} ]] |
53 | then |
54 | rc-config add lprng &> /dev/null |
55 | else |
56 | rc-config del lprng &> /dev/null |
57 | fi |
58 | } |