Magellan Linux

Contents of /alx-src/branches/alxconf-060/functions/config_printers.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1972 - (show annotations) (download) (as text)
Sat May 7 11:02:15 2011 UTC (12 years, 11 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 # $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
36 # first of all get the vars
37 get_printer_settings
38
39 # 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
50 for (( i=0; i < ALX_COUNT; i++ ))
51 do
52 # get real port settings
53 case ${ALX_PORT[${i}]} in
54 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 esac
60
61 # 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 done
72
73 # start lprng if ALX_COUNT > 0
74 if [[ ${ALX_COUNT} != 0 ]]
75 then
76 rc-config add lprng &> /dev/null
77 else
78 rc-config del lprng &> /dev/null
79 fi
80 }