Magellan Linux

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

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

alx-src/branches/alxconf_20060908/functions/config_printers.sh revision 545 by niro, Wed Feb 4 20:07:30 2009 UTC alx-src/branches/alxconf-060/functions/config_printers.sh revision 2160 by niro, Wed May 18 14:34:35 2011 UTC
# Line 1  Line 1 
1  # $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_printers.sh,v 1.9 2005-10-09 21:29:41 niro Exp $  # $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/cups/printers.conf   # first of all delete all printers, by wiping /etc/printcap and all spooler directories
14   # please note that cups must be restarted or reloaded or stopped   CONFIG="/etc/printcap"
15   [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null   clearconfig
  :> /etc/cups/printers.conf  
16    
17   for (( i=0; i < ALX_COUNT; i++ ))   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   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   lpt1)   lpt[0-9]*) port="/dev/lp$(( ${cfg_printers_port/lpt/}-1 ))" ;;
32   port="parallel:/dev/lp0"   com[0-9]*) port="/dev/ttyS$(( ${cfg_printers_port/com/}-1 ))" ;;
33   ;;   usb[0-9]*) port="/dev/usb/lp$(( ${cfg_printers_port/usb/}-1 ))" ;;
34   com1)   #lpd) port="lpd://${ip}/${share}" ;;
35   port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none"   #socket) port="socket://${ip}:${share}" ;;
  ;;# echo "DEBUG: deleting samba+cups+inetd"  
  com2)  
  port="serial:/dev/ttyS1?baud=9600+bits=8+parity=none+flow=none"  
  ;;  
  lpd)  
  port="lpd://${ALX_IP[${i}]}/${ALX_SHARE[${i}]}"  
  ;;  
  socket)  
  port="socket://${ALX_IP[${i}]}:${ALX_SHARE[${i}]}"  
  ;;  
36   esac   esac
37    
38   # now add new printers (writing printers.conf)   # now add new printers (writing printcap)
39   echo "<Printer ${ALX_PRINTER_NAME[${i}]}>" >> /etc/cups/printers.conf   addconfig "#--- added by alxconfig ---"
40   echo "Info ${ALX_PRINTER_NAME[${i}]}" >> /etc/cups/printers.conf   addconfig "${cfg_printers_name}|${cfg_printers_name}"
41   echo "DeviceURI ${port}" >> /etc/cups/printers.conf   addconfig " :lp=${port}"
42   echo "State Idle" >> /etc/cups/printers.conf   addconfig " :sd=/var/spool/lpd/${cfg_printers_name}"
43   echo "Accepting Yes" >> /etc/cups/printers.conf   addconfig "#-----------------------"
44   echo "JobSheets none none" >> /etc/cups/printers.conf   addconfig
  echo "QuotaPeriod 0" >> /etc/cups/printers.conf  
  echo "PageLimit 0" >> /etc/cups/printers.conf  
  echo "KLimit 0" >> /etc/cups/printers.conf  
  echo "</Printer>" >> /etc/cups/printers.conf  
  done  
45    
46   # setup lpd print-services   # install spooler directories
47   echo "printer stream tcp nowait lp /usr/lib/cups/daemon/cups-lpd cups-lpd" > /etc/inetd.conf   install -o lp -g lp -m0700 -d /var/spool/lpd/${cfg_printers_name}
48     done
49    
50   # start samba and cups if ALX_COUNT > 0   # start lprng
51   if [[ ${ALX_COUNT} != 0 ]]   if [[ -n ${prn_ids} ]]
52   then   then
53   rc-config add inetd &> /dev/null   rc-config add lprng &> /dev/null
  rc-config add cups &> /dev/null  
  rc-config add samba &> /dev/null  
54   else   else
55   rc-config del inetd &> /dev/null   rc-config del lprng &> /dev/null
  rc-config del cups &> /dev/null  
  rc-config del samba &> /dev/null  
56   fi   fi
57  }  }

Legend:
Removed from v.545  
changed lines
  Added in v.2160