Annotation of /alx-src/branches/alxconf-060/functions/config_printers.sh
Parent Directory | Revision Log
Revision 1972 -
(hide annotations)
(download)
(as text)
Sat May 7 11:02:15 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2322 byte(s)
Sat May 7 11:02:15 2011 UTC (13 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2322 byte(s)
-fixed header -support lprng and dropped samba/cups support
1 | niro | 1972 | # $Id$ |
2 | niro | 218 | # 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 | niro | 341 | prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'") |
10 | niro | 218 | |
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 | niro | 341 | 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 | niro | 218 | |
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 | niro | 232 | config_printing() |
33 | niro | 218 | { |
34 | local port | ||
35 | |||
36 | niro | 341 | # first of all get the vars |
37 | niro | 218 | get_printer_settings |
38 | |||
39 | niro | 1972 | # first of all delete all printers, by wiping /etc/printcap and all spooler directories |
40 | :> /etc/printcap | ||
41 | if [[ -d /var/spool/lpd ]] | ||
42 | then | ||
43 | rm -rf /var/spool/lpd | ||
44 | install -d /var/spool/lpd | ||
45 | install -d /var/spool/lpd/lp | ||
46 | chown lp:lp /var/spool/lpd/lp | ||
47 | chmod 0700 /var/spool/lpd/lp | ||
48 | fi | ||
49 | niro | 218 | |
50 | for (( i=0; i < ALX_COUNT; i++ )) | ||
51 | do | ||
52 | # get real port settings | ||
53 | case ${ALX_PORT[${i}]} in | ||
54 | niro | 1972 | lpt[0-9]*) port="/dev/lp$(( ${port/lpt/}-1 ))" ;; |
55 | com[0-9]*) port="/dev/ttyS$(( ${port/com/}-1 ))" ;; | ||
56 | usb[0-9]*) port="/dev/usb/lp$(( ${port/usb/}-1 ))" ;; | ||
57 | #lpd) port="lpd://${ip}/${share}" ;; | ||
58 | #socket) port="socket://${ip}:${share}" ;; | ||
59 | niro | 218 | esac |
60 | |||
61 | niro | 1972 | # now add new printers (writing printcap) |
62 | echo "#--- added by alxconfig ---" >> /etc/printcap | ||
63 | echo "${ALX_PRINTER_NAME[${i}]}|${ALX_PRINTER_NAME[${i}]}" >> /etc/printcap | ||
64 | echo " :lp=${port}" >> /etc/printcap | ||
65 | echo " :sd=/var/spool/lpd/${ALX_PRINTER_NAME[${i}]}" >> /etc/printcap | ||
66 | echo "#-----------------------" | ||
67 | echo >> /etc/printcap | ||
68 | |||
69 | # install spooler directories | ||
70 | install -o lp -g lp -m0700 -d /var/spool/lpd/${ALX_PRINTER_NAME[${i}]} | ||
71 | niro | 218 | done |
72 | niro | 244 | |
73 | niro | 1972 | # start lprng if ALX_COUNT > 0 |
74 | niro | 244 | if [[ ${ALX_COUNT} != 0 ]] |
75 | then | ||
76 | niro | 1972 | rc-config add lprng &> /dev/null |
77 | niro | 244 | else |
78 | niro | 1972 | rc-config del lprng &> /dev/null |
79 | niro | 244 | fi |
80 | niro | 218 | } |