Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2610 - (hide annotations) (download) (as text)
Wed Jul 6 21:33:33 2011 UTC (12 years, 10 months ago) by niro
File MIME type: application/x-sh
File size: 1809 byte(s)
-do not add printers with a empty 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 2610
30     # do not add any printers if the name is empty - warn the user
31     if [[ -z ${cfg_printers_printer_name} ]]
32     then
33     echo -e "${COLRED}No printer_name given in config of printer '${i}' with port '${cfg_printers_port}'. Not added!${COLDEFAULT}"
34     continue
35     fi
36    
37 niro 218 # get real port settings
38 niro 2147 case ${cfg_printers_port} in
39     lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;;
40     com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;;
41 niro 2160 usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;;
42 niro 1972 #lpd) port="lpd://${ip}/${share}" ;;
43     #socket) port="socket://${ip}:${share}" ;;
44 niro 218 esac
45    
46 niro 1972 # now add new printers (writing printcap)
47 niro 2034 addconfig "#--- added by alxconfig ---"
48 niro 2164 addconfig "${cfg_printers_printer_name}|${cfg_printers_printer_name}"
49 niro 2034 addconfig " :lp=${port}"
50 niro 2164 addconfig " :sd=/var/spool/lpd/${cfg_printers_printer_name}"
51 niro 2034 addconfig "#-----------------------"
52     addconfig
53 niro 1972
54     # install spooler directories
55 niro 2164 install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_printer_name}
56 niro 218 done
57 niro 244
58 niro 2147 # start lprng
59     if [[ -n ${prn_ids} ]]
60 niro 244 then
61 niro 1972 rc-config add lprng &> /dev/null
62 niro 244 else
63 niro 1972 rc-config del lprng &> /dev/null
64 niro 244 fi
65 niro 218 }