Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2610 - (show annotations) (download) (as text)
Wed Jul 6 21:33:33 2011 UTC (12 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 1809 byte(s)
-do not add printers with a empty name
1 # $Id$
2 # configures printing on the host via mysql db settings
3
4 config_printing()
5 {
6 local port
7 local CONFIG
8 local prn_ids
9
10 # first of all get the vars
11 prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'")
12
13 # first of all delete all printers, by wiping /etc/printcap and all spooler directories
14 CONFIG="/etc/printcap"
15 clearconfig
16
17 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
26 for i in ${prn_ids}
27 do
28 evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'"
29
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 # get real port settings
38 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 usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;;
42 #lpd) port="lpd://${ip}/${share}" ;;
43 #socket) port="socket://${ip}:${share}" ;;
44 esac
45
46 # now add new printers (writing printcap)
47 addconfig "#--- added by alxconfig ---"
48 addconfig "${cfg_printers_printer_name}|${cfg_printers_printer_name}"
49 addconfig " :lp=${port}"
50 addconfig " :sd=/var/spool/lpd/${cfg_printers_printer_name}"
51 addconfig "#-----------------------"
52 addconfig
53
54 # install spooler directories
55 install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_printer_name}
56 done
57
58 # start lprng
59 if [[ -n ${prn_ids} ]]
60 then
61 rc-config add lprng &> /dev/null
62 else
63 rc-config del lprng &> /dev/null
64 fi
65 }