Contents of /alx-src/tags/alxconf-0_6_0-rc8/functions/config_printers.sh
Parent Directory | Revision Log
Revision 2126 -
(show annotations)
(download)
(as text)
Mon May 16 12:23:08 2011 UTC (13 years, 4 months ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_printers.sh
File MIME type: application/x-sh
File size: 2328 byte(s)
Mon May 16 12:23:08 2011 UTC (13 years, 4 months ago) by niro
Original Path: alx-src/branches/alxconf-060/functions/config_printers.sh
File MIME type: application/x-sh
File size: 2328 byte(s)
-fixed ports
1 | # $Id$ |
2 | # configures printing on the host via mysql db settings |
3 | |
4 | get_printer_settings() |
5 | { |
6 | local i all count prn_ids settings DB_PRINTER |
7 | |
8 | # first get all printer names |
9 | prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'") |
10 | |
11 | # set counter equal to numbers of printers |
12 | declare -i count=0 |
13 | for i in ${prn_ids} |
14 | do |
15 | # now get the other settings und put them in arrays |
16 | ALX_PRINTER_NAME[${count}]=$(mysqldo "select printer_name from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'") |
17 | ALX_PORT[${count}]=$(mysqldo "select port from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'") |
18 | ALX_IP[${count}]=$(mysqldo "select ip from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'") |
19 | ALX_SHARE[${count}]=$(mysqldo "select share from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'") |
20 | |
21 | (( count++ )) |
22 | done |
23 | |
24 | # export all settings |
25 | export ALX_COUNT=${count} |
26 | export ALX_PRINTER_NAME |
27 | export ALX_PORT |
28 | export ALX_IP |
29 | export ALX_SHARE |
30 | } |
31 | |
32 | config_printing() |
33 | { |
34 | local port |
35 | local CONFIG |
36 | |
37 | # first of all get the vars |
38 | get_printer_settings |
39 | |
40 | # first of all delete all printers, by wiping /etc/printcap and all spooler directories |
41 | CONFIG=/etc/printcap |
42 | clearconfig |
43 | |
44 | if [[ -d /var/spool/lpd ]] |
45 | then |
46 | rm -rf /var/spool/lpd |
47 | install -d /var/spool/lpd |
48 | install -d /var/spool/lpd/lp |
49 | chown lp:lp /var/spool/lpd/lp |
50 | chmod 0700 /var/spool/lpd/lp |
51 | fi |
52 | |
53 | for (( i=0; i < ALX_COUNT; i++ )) |
54 | do |
55 | # get real port settings |
56 | case ${ALX_PORT[${i}]} in |
57 | lpt[0-9]*) port="/dev/lp$(( ${ALX_PORT[${i}]/lpt/}-1 ))" ;; |
58 | com[0-9]*) port="/dev/ttyS$(( ${ALX_PORT[${i}]/com/}-1 ))" ;; |
59 | usb[0-9]*) port="/dev/usb/lp$(( ${ALX_PORT[${i}]/usb/}-1 ))" ;; |
60 | #lpd) port="lpd://${ip}/${share}" ;; |
61 | #socket) port="socket://${ip}:${share}" ;; |
62 | esac |
63 | |
64 | # now add new printers (writing printcap) |
65 | addconfig "#--- added by alxconfig ---" |
66 | addconfig "${ALX_PRINTER_NAME[${i}]}|${ALX_PRINTER_NAME[${i}]}" |
67 | addconfig " :lp=${port}" |
68 | addconfig " :sd=/var/spool/lpd/${ALX_PRINTER_NAME[${i}]}" |
69 | addconfig "#-----------------------" |
70 | addconfig |
71 | |
72 | # install spooler directories |
73 | install -o lp -g lp -m0700 -d /var/spool/lpd/${ALX_PRINTER_NAME[${i}]} |
74 | done |
75 | |
76 | # start lprng if ALX_COUNT > 0 |
77 | if [[ ${ALX_COUNT} != 0 ]] |
78 | then |
79 | rc-config add lprng &> /dev/null |
80 | else |
81 | rc-config del lprng &> /dev/null |
82 | fi |
83 | } |