Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2164 - (hide annotations) (download) (as text)
Wed May 18 14:37:55 2011 UTC (13 years ago) by niro
File MIME type: application/x-sh
File size: 1545 byte(s)
-name -> printer_name
1 niro 1972 # $Id$
2 niro 218 # configures printing on the host via mysql db settings
3    
4 niro 232 config_printing()
5 niro 218 {
6     local port
7 niro 2034 local CONFIG
8 niro 2147 local prn_ids
9 niro 218
10 niro 341 # first of all get the vars
11 niro 2147 prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'")
12 niro 218
13 niro 1972 # first of all delete all printers, by wiping /etc/printcap and all spooler directories
14 niro 2160 CONFIG="/etc/printcap"
15 niro 2034 clearconfig
16    
17 niro 1972 if [[ -d /var/spool/lpd ]]
18     then
19     rm -rf /var/spool/lpd
20     install -d /var/spool/lpd
21     install -d /var/spool/lpd/lp
22     chown lp:lp /var/spool/lpd/lp
23     chmod 0700 /var/spool/lpd/lp
24     fi
25 niro 218
26 niro 2147 for i in ${prn_ids}
27 niro 218 do
28 niro 2147 evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'"
29 niro 218 # get real port settings
30 niro 2147 case ${cfg_printers_port} in
31     lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;;
32     com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;;
33 niro 2160 usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;;
34 niro 1972 #lpd) port="lpd://${ip}/${share}" ;;
35     #socket) port="socket://${ip}:${share}" ;;
36 niro 218 esac
37    
38 niro 1972 # now add new printers (writing printcap)
39 niro 2034 addconfig "#--- added by alxconfig ---"
40 niro 2164 addconfig "${cfg_printers_printer_name}|${cfg_printers_printer_name}"
41 niro 2034 addconfig " :lp=${port}"
42 niro 2164 addconfig " :sd=/var/spool/lpd/${cfg_printers_printer_name}"
43 niro 2034 addconfig "#-----------------------"
44     addconfig
45 niro 1972
46     # install spooler directories
47 niro 2164 install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_printer_name}
48 niro 218 done
49 niro 244
50 niro 2147 # start lprng
51     if [[ -n ${prn_ids} ]]
52 niro 244 then
53 niro 1972 rc-config add lprng &> /dev/null
54 niro 244 else
55 niro 1972 rc-config del lprng &> /dev/null
56 niro 244 fi
57 niro 218 }