Contents of /alx-src/branches/alxconf-060/functions/config_printers.sh
Parent Directory | Revision Log
Revision 2164 -
(show annotations)
(download)
(as text)
Wed May 18 14:37:55 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1545 byte(s)
Wed May 18 14:37:55 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 1545 byte(s)
-name -> printer_name
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 | prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'") |
12 | |
13 | # first of all delete all printers, by wiping /etc/printcap and all spooler directories |
14 | CONFIG="/etc/printcap" |
15 | clearconfig |
16 | |
17 | if [[ -d /var/spool/lpd ]] |
18 | then |
19 | rm -rf /var/spool/lpd |
20 | install -d /var/spool/lpd |
21 | install -d /var/spool/lpd/lp |
22 | chown lp:lp /var/spool/lpd/lp |
23 | chmod 0700 /var/spool/lpd/lp |
24 | fi |
25 | |
26 | for i in ${prn_ids} |
27 | do |
28 | evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'" |
29 | # get real port settings |
30 | case ${cfg_printers_port} in |
31 | lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;; |
32 | com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;; |
33 | usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;; |
34 | #lpd) port="lpd://${ip}/${share}" ;; |
35 | #socket) port="socket://${ip}:${share}" ;; |
36 | esac |
37 | |
38 | # now add new printers (writing printcap) |
39 | addconfig "#--- added by alxconfig ---" |
40 | addconfig "${cfg_printers_printer_name}|${cfg_printers_printer_name}" |
41 | addconfig " :lp=${port}" |
42 | addconfig " :sd=/var/spool/lpd/${cfg_printers_printer_name}" |
43 | addconfig "#-----------------------" |
44 | addconfig |
45 | |
46 | # install spooler directories |
47 | install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_printer_name} |
48 | done |
49 | |
50 | # start lprng |
51 | if [[ -n ${prn_ids} ]] |
52 | then |
53 | rc-config add lprng &> /dev/null |
54 | else |
55 | rc-config del lprng &> /dev/null |
56 | fi |
57 | } |