Magellan Linux

Annotation of /alx-src/trunk/alxconfig-ng/functions/config_printers.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 232 - (hide annotations) (download) (as text)
Wed Mar 9 00:28:29 2005 UTC (19 years, 2 months ago) by niro
File MIME type: application/x-sh
File size: 4077 byte(s)
fixed typos

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