Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1972 by niro, Sat May 7 11:02:15 2011 UTC revision 2164 by niro, Wed May 18 14:37:55 2011 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2  # configures printing on the host via mysql db settings  # configures printing on the host via mysql db settings
3    
 get_printer_settings()  
 {  
  local i all count prn_ids settings DB_PRINTER  
   
  # first get all printer names  
  prn_ids=$(mysqldo "select id from cfg_printers where serial='${ALX_SERIAL}'")  
   
  # set counter equal to numbers of printers  
  declare -i count=0  
  for i in ${prn_ids}  
  do  
  # now get the other settings und put them in arrays  
  ALX_PRINTER_NAME[${count}]=$(mysqldo "select printer_name from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'")  
  ALX_PORT[${count}]=$(mysqldo "select port from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'")  
  ALX_IP[${count}]=$(mysqldo "select ip from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'")  
  ALX_SHARE[${count}]=$(mysqldo "select share from cfg_printers where serial='${ALX_SERIAL}' and id='${i}'")  
   
  (( count++ ))  
  done  
   
  # export all settings  
  export ALX_COUNT=${count}  
  export ALX_PRINTER_NAME  
  export ALX_PORT  
  export ALX_IP  
  export ALX_SHARE  
 }  
   
4  config_printing()  config_printing()
5  {  {
6   local port   local port
7     local CONFIG
8     local prn_ids
9    
10   # first of all get the vars   # first of all get the vars
11   get_printer_settings   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   # first of all delete all printers, by wiping /etc/printcap and all spooler directories
14   :> /etc/printcap   CONFIG="/etc/printcap"
15     clearconfig
16    
17   if [[ -d /var/spool/lpd ]]   if [[ -d /var/spool/lpd ]]
18   then   then
19   rm -rf /var/spool/lpd   rm -rf /var/spool/lpd
# Line 47  config_printing() Line 23  config_printing()
23   chmod 0700 /var/spool/lpd/lp   chmod 0700 /var/spool/lpd/lp
24   fi   fi
25    
26   for (( i=0; i < ALX_COUNT; i++ ))   for i in ${prn_ids}
27   do   do
28     evaluate_table cfg_printers "where serial='${ALX_SERIAL}' and id='${i}'"
29   # get real port settings   # get real port settings
30   case ${ALX_PORT[${i}]} in   case ${cfg_printers_port} in
31   lpt[0-9]*) port="/dev/lp$(( ${port/lpt/}-1 ))" ;;   lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;;
32   com[0-9]*) port="/dev/ttyS$(( ${port/com/}-1 ))" ;;   com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;;
33   usb[0-9]*) port="/dev/usb/lp$(( ${port/usb/}-1 ))" ;;   usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;;
34   #lpd) port="lpd://${ip}/${share}" ;;   #lpd) port="lpd://${ip}/${share}" ;;
35   #socket) port="socket://${ip}:${share}" ;;   #socket) port="socket://${ip}:${share}" ;;
36   esac   esac
37    
38   # now add new printers (writing printcap)   # now add new printers (writing printcap)
39   echo "#--- added by alxconfig ---" >> /etc/printcap   addconfig "#--- added by alxconfig ---"
40   echo "${ALX_PRINTER_NAME[${i}]}|${ALX_PRINTER_NAME[${i}]}" >> /etc/printcap   addconfig "${cfg_printers_printer_name}|${cfg_printers_printer_name}"
41   echo " :lp=${port}" >> /etc/printcap   addconfig " :lp=${port}"
42   echo " :sd=/var/spool/lpd/${ALX_PRINTER_NAME[${i}]}" >> /etc/printcap   addconfig " :sd=/var/spool/lpd/${cfg_printers_printer_name}"
43   echo "#-----------------------"   addconfig "#-----------------------"
44   echo >> /etc/printcap   addconfig
45    
46   # install spooler directories   # install spooler directories
47   install -o lp -g lp -m0700 -d /var/spool/lpd/${ALX_PRINTER_NAME[${i}]}   install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_printer_name}
48   done   done
49    
50   # start lprng if ALX_COUNT > 0   # start lprng
51   if [[ ${ALX_COUNT} != 0 ]]   if [[ -n ${prn_ids} ]]
52   then   then
53   rc-config add lprng &> /dev/null   rc-config add lprng &> /dev/null
54   else   else

Legend:
Removed from v.1972  
changed lines
  Added in v.2164