Annotation of /alx-src/branches/alxconf-060/functions/config_printers.sh
Parent Directory | Revision Log
Revision 2147 -
(hide 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 | niro | 1972 | # $Id$ |
2 | niro | 218 | # configures printing on the host via mysql db settings |
3 | |||
4 | niro | 232 | config_printing() |
5 | niro | 218 | { |
6 | local port | ||
7 | niro | 2034 | local CONFIG |
8 | niro | 2147 | local prn_ids |
9 | niro | 218 | |
10 | niro | 341 | # first of all get the vars |
11 | niro | 218 | get_printer_settings |
12 | niro | 2147 | prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'") |
13 | niro | 218 | |
14 | niro | 1972 | # first of all delete all printers, by wiping /etc/printcap and all spooler directories |
15 | niro | 2034 | CONFIG=/etc/printcap |
16 | clearconfig | ||
17 | |||
18 | niro | 1972 | 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 | niro | 218 | |
27 | niro | 2147 | for i in ${prn_ids} |
28 | niro | 218 | do |
29 | niro | 2147 | evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'" |
30 | niro | 218 | # get real port settings |
31 | niro | 2147 | 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 | niro | 1972 | #lpd) port="lpd://${ip}/${share}" ;; |
36 | #socket) port="socket://${ip}:${share}" ;; | ||
37 | niro | 218 | esac |
38 | |||
39 | niro | 1972 | # now add new printers (writing printcap) |
40 | niro | 2034 | addconfig "#--- added by alxconfig ---" |
41 | niro | 2147 | addconfig "${cfg_printers_name}|${cfg_printers_name}" |
42 | niro | 2034 | addconfig " :lp=${port}" |
43 | niro | 2147 | addconfig " :sd=/var/spool/lpd/${cfg_printers_name}" |
44 | niro | 2034 | addconfig "#-----------------------" |
45 | addconfig | ||
46 | niro | 1972 | |
47 | # install spooler directories | ||
48 | niro | 2147 | install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_name} |
49 | niro | 218 | done |
50 | niro | 244 | |
51 | niro | 2147 | # start lprng |
52 | if [[ -n ${prn_ids} ]] | ||
53 | niro | 244 | then |
54 | niro | 1972 | rc-config add lprng &> /dev/null |
55 | niro | 244 | else |
56 | niro | 1972 | rc-config del lprng &> /dev/null |
57 | niro | 244 | fi |
58 | niro | 218 | } |