Annotation of /alx-src/tags/alxconf-0_6_0-rc8/functions/config_printers.sh
Parent Directory | Revision Log
Revision 547 -
(hide annotations)
(download)
(as text)
Wed Feb 4 20:14:36 2009 UTC (15 years, 7 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/functions/config_printers.sh
File MIME type: application/x-sh
File size: 2961 byte(s)
Wed Feb 4 20:14:36 2009 UTC (15 years, 7 months ago) by niro
Original Path: alx-src/branches/alxconf_20060908/functions/config_printers.sh
File MIME type: application/x-sh
File size: 2961 byte(s)
- added usb printing support
1 | niro | 341 | # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_printers.sh,v 1.9 2005-10-09 21:29:41 niro Exp $ |
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 | # first of all delete all printers, by wiping /etc/cups/printers.conf | ||
40 | # please note that cups must be restarted or reloaded or stopped | ||
41 | [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null | ||
42 | :> /etc/cups/printers.conf | ||
43 | |||
44 | for (( i=0; i < ALX_COUNT; i++ )) | ||
45 | do | ||
46 | # get real port settings | ||
47 | case ${ALX_PORT[${i}]} in | ||
48 | lpt1) | ||
49 | port="parallel:/dev/lp0" | ||
50 | ;; | ||
51 | com1) | ||
52 | port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none" | ||
53 | niro | 341 | ;;# echo "DEBUG: deleting samba+cups+inetd" |
54 | niro | 218 | com2) |
55 | port="serial:/dev/ttyS1?baud=9600+bits=8+parity=none+flow=none" | ||
56 | ;; | ||
57 | niro | 547 | usb1) |
58 | port="usb:/dev/usb/lp0" | ||
59 | ;; | ||
60 | niro | 218 | lpd) |
61 | port="lpd://${ALX_IP[${i}]}/${ALX_SHARE[${i}]}" | ||
62 | ;; | ||
63 | socket) | ||
64 | port="socket://${ALX_IP[${i}]}:${ALX_SHARE[${i}]}" | ||
65 | ;; | ||
66 | esac | ||
67 | |||
68 | # now add new printers (writing printers.conf) | ||
69 | echo "<Printer ${ALX_PRINTER_NAME[${i}]}>" >> /etc/cups/printers.conf | ||
70 | echo "Info ${ALX_PRINTER_NAME[${i}]}" >> /etc/cups/printers.conf | ||
71 | echo "DeviceURI ${port}" >> /etc/cups/printers.conf | ||
72 | echo "State Idle" >> /etc/cups/printers.conf | ||
73 | echo "Accepting Yes" >> /etc/cups/printers.conf | ||
74 | echo "JobSheets none none" >> /etc/cups/printers.conf | ||
75 | echo "QuotaPeriod 0" >> /etc/cups/printers.conf | ||
76 | echo "PageLimit 0" >> /etc/cups/printers.conf | ||
77 | echo "KLimit 0" >> /etc/cups/printers.conf | ||
78 | echo "</Printer>" >> /etc/cups/printers.conf | ||
79 | done | ||
80 | niro | 244 | |
81 | niro | 270 | # setup lpd print-services |
82 | echo "printer stream tcp nowait lp /usr/lib/cups/daemon/cups-lpd cups-lpd" > /etc/inetd.conf | ||
83 | |||
84 | niro | 244 | # start samba and cups if ALX_COUNT > 0 |
85 | if [[ ${ALX_COUNT} != 0 ]] | ||
86 | then | ||
87 | niro | 270 | rc-config add inetd &> /dev/null |
88 | niro | 244 | rc-config add cups &> /dev/null |
89 | rc-config add samba &> /dev/null | ||
90 | else | ||
91 | niro | 270 | rc-config del inetd &> /dev/null |
92 | niro | 244 | rc-config del cups &> /dev/null |
93 | rc-config del samba &> /dev/null | ||
94 | fi | ||
95 | niro | 218 | } |