Annotation of /alx-src/branches/alxconf-060/functions/config_printers.sh
Parent Directory | Revision Log
Revision 218 -
(hide annotations)
(download)
(as text)
Tue Mar 8 20:29:46 2005 UTC (19 years, 6 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_printers.sh
File MIME type: application/x-sh
File size: 4060 byte(s)
Tue Mar 8 20:29:46 2005 UTC (19 years, 6 months ago) by niro
Original Path: alx-src/trunk/alxconfig-ng/functions/config_printers.sh
File MIME type: application/x-sh
File size: 4060 byte(s)
new
1 | niro | 218 | # configures printing on the host via mysql db settings |
2 | |||
3 | #delme settings | ||
4 | SQL_USER=alx_install | ||
5 | SQL_PASS=@lx | ||
6 | SQL_HOST=128.20.41.110 | ||
7 | SQL_DB=alx_web | ||
8 | ALX_SERIAL=10 | ||
9 | |||
10 | get_printer_settings() | ||
11 | { | ||
12 | local i all count prn_ids settings DB_PRINTER | ||
13 | |||
14 | # first get all printer names | ||
15 | prn_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
16 | "select id from cfg_printers where serial='${ALX_SERIAL}'") | ||
17 | |||
18 | # set counter equal to numbers of printers | ||
19 | declare -i count=0 | ||
20 | for i in ${prn_ids} | ||
21 | do | ||
22 | # now get the other settings und put them in arrays | ||
23 | ALX_PRINTER_NAME[${count}]=$(mysql_command \ | ||
24 | ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
25 | "select printer_name | ||
26 | from cfg_printers | ||
27 | where serial='${ALX_SERIAL}' and id='${i}'") | ||
28 | |||
29 | ALX_PORT[${count}]=$(mysql_command \ | ||
30 | ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
31 | "select port | ||
32 | from cfg_printers | ||
33 | where serial='${ALX_SERIAL}' and id='${i}'") | ||
34 | |||
35 | ALX_IP[${count}]=$(mysql_command \ | ||
36 | ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
37 | "select ip | ||
38 | from cfg_printers | ||
39 | where serial='${ALX_SERIAL}' and id='${i}'") | ||
40 | |||
41 | ALX_SHARE[${count}]=$(mysql_command \ | ||
42 | ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ | ||
43 | "select share | ||
44 | from cfg_printers | ||
45 | where serial='${ALX_SERIAL}' and id='${i}'") | ||
46 | |||
47 | (( count++ )) | ||
48 | done | ||
49 | |||
50 | # DEBUG MSG | ||
51 | for (( i=0; i <= count; i++ )) | ||
52 | do | ||
53 | echo -n "${ALX_PRINTER_NAME[${i}]} " | ||
54 | echo -n "${ALX_PORT[${i}]} " | ||
55 | echo -n "${ALX_IP[${i}]} " | ||
56 | echo "${ALX_SHARE[${i}]}" | ||
57 | done | ||
58 | |||
59 | # export all settings | ||
60 | export ALX_COUNT=${count} | ||
61 | export ALX_PRINTER_NAME | ||
62 | export ALX_PORT | ||
63 | export ALX_IP | ||
64 | export ALX_SHARE | ||
65 | } | ||
66 | |||
67 | config_printing() | ||
68 | { | ||
69 | local port | ||
70 | |||
71 | #first of all get the vars | ||
72 | get_printer_settings | ||
73 | |||
74 | # first of all delete all printers, by wiping /etc/cups/printers.conf | ||
75 | # please note that cups must be restarted or reloaded or stopped | ||
76 | [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null | ||
77 | :> /etc/cups/printers.conf | ||
78 | |||
79 | # now start cups | ||
80 | /etc/init.d/cups start &> /dev/null | ||
81 | |||
82 | # debug | ||
83 | echo "ALX_COUNT: ${ALX_COUNT}" | ||
84 | for (( i=0; i < ALX_COUNT; i++ )) | ||
85 | do | ||
86 | # get real port settings | ||
87 | case ${ALX_PORT[${i}]} in | ||
88 | lpt1) | ||
89 | port="parallel:/dev/lp0" | ||
90 | ;; | ||
91 | com1) | ||
92 | port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none" | ||
93 | ;; | ||
94 | com2) | ||
95 | port="serial:/dev/ttyS1?baud=9600+bits=8+parity=none+flow=none" | ||
96 | ;; | ||
97 | lpd) | ||
98 | port="lpd://${ALX_IP[${i}]}/${ALX_SHARE[${i}]}" | ||
99 | ;; | ||
100 | socket) | ||
101 | port="socket://${ALX_IP[${i}]}:${ALX_SHARE[${i}]}" | ||
102 | ;; | ||
103 | esac | ||
104 | |||
105 | # now add new printers | ||
106 | /usr/sbin/lpadmin -p ${ALX_PRINTER_NAME[${i}]} -E -v ${port} | ||
107 | done | ||
108 | } | ||
109 | |||
110 | config_printing2() | ||
111 | { | ||
112 | local port | ||
113 | |||
114 | #first of all get the vars | ||
115 | get_printer_settings | ||
116 | |||
117 | # first of all delete all printers, by wiping /etc/cups/printers.conf | ||
118 | # please note that cups must be restarted or reloaded or stopped | ||
119 | [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null | ||
120 | :> /etc/cups/printers.conf | ||
121 | |||
122 | # debug | ||
123 | echo "ALX_COUNT: ${ALX_COUNT}" | ||
124 | for (( i=0; i < ALX_COUNT; i++ )) | ||
125 | do | ||
126 | # get real port settings | ||
127 | case ${ALX_PORT[${i}]} in | ||
128 | lpt1) | ||
129 | port="parallel:/dev/lp0" | ||
130 | ;; | ||
131 | com1) | ||
132 | port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none" | ||
133 | ;; | ||
134 | com2) | ||
135 | port="serial:/dev/ttyS1?baud=9600+bits=8+parity=none+flow=none" | ||
136 | ;; | ||
137 | lpd) | ||
138 | port="lpd://${ALX_IP[${i}]}/${ALX_SHARE[${i}]}" | ||
139 | ;; | ||
140 | socket) | ||
141 | port="socket://${ALX_IP[${i}]}:${ALX_SHARE[${i}]}" | ||
142 | ;; | ||
143 | esac | ||
144 | |||
145 | # now add new printers (writing printers.conf) | ||
146 | #/usr/sbin/lpadmin -p ${ALX_PRINTER_NAME[${i}]} -E -v ${port} | ||
147 | echo "<Printer ${ALX_PRINTER_NAME[${i}]}>" >> /etc/cups/printers.conf | ||
148 | echo "Info ${ALX_PRINTER_NAME[${i}]}" >> /etc/cups/printers.conf | ||
149 | echo "DeviceURI ${port}" >> /etc/cups/printers.conf | ||
150 | echo "State Idle" >> /etc/cups/printers.conf | ||
151 | echo "Accepting Yes" >> /etc/cups/printers.conf | ||
152 | echo "JobSheets none none" >> /etc/cups/printers.conf | ||
153 | echo "QuotaPeriod 0" >> /etc/cups/printers.conf | ||
154 | echo "PageLimit 0" >> /etc/cups/printers.conf | ||
155 | echo "KLimit 0" >> /etc/cups/printers.conf | ||
156 | echo "</Printer>" >> /etc/cups/printers.conf | ||
157 | done | ||
158 | } |