--- alx-src/trunk/alxconfig-ng/functions/config_printers.sh 2005/03/09 00:28:29 232 +++ alx-src/branches/alxconf_20060908/functions/config_printers.sh 2009/02/04 20:14:36 547 @@ -1,4 +1,4 @@ -# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_printers.sh,v 1.4 2005-03-09 00:28:29 niro Exp $ +# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_printers.sh,v 1.9 2005-10-09 21:29:41 niro Exp $ # configures printing on the host via mysql db settings get_printer_settings() @@ -6,50 +6,21 @@ local i all count prn_ids settings DB_PRINTER # first get all printer names - prn_ids=$(mysql_command ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select id from cfg_printers where serial='${ALX_SERIAL}'") + 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}]=$(mysql_command \ - ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select printer_name - from cfg_printers - where serial='${ALX_SERIAL}' and id='${i}'") - - ALX_PORT[${count}]=$(mysql_command \ - ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select port - from cfg_printers - where serial='${ALX_SERIAL}' and id='${i}'") - - ALX_IP[${count}]=$(mysql_command \ - ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select ip - from cfg_printers - where serial='${ALX_SERIAL}' and id='${i}'") - - ALX_SHARE[${count}]=$(mysql_command \ - ${SQL_USER} ${SQL_PASS} ${SQL_HOST} ${SQL_DB} \ - "select share - from cfg_printers - where serial='${ALX_SERIAL}' and id='${i}'") + 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 - # DEBUG MSG - for (( i=0; i <= count; i++ )) - do - echo -n "${ALX_PRINTER_NAME[${i}]} " - echo -n "${ALX_PORT[${i}]} " - echo -n "${ALX_IP[${i}]} " - echo "${ALX_SHARE[${i}]}" - done - # export all settings export ALX_COUNT=${count} export ALX_PRINTER_NAME @@ -58,54 +29,11 @@ export ALX_SHARE } -config_printing_old() -{ - local port - - #first of all get the vars - get_printer_settings - - # first of all delete all printers, by wiping /etc/cups/printers.conf - # please note that cups must be restarted or reloaded or stopped - [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null - :> /etc/cups/printers.conf - - # now start cups - /etc/init.d/cups start &> /dev/null - - # debug - echo "ALX_COUNT: ${ALX_COUNT}" - for (( i=0; i < ALX_COUNT; i++ )) - do - # get real port settings - case ${ALX_PORT[${i}]} in - lpt1) - port="parallel:/dev/lp0" - ;; - com1) - port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none" - ;; - 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}]}" - ;; - esac - - # now add new printers - /usr/sbin/lpadmin -p ${ALX_PRINTER_NAME[${i}]} -E -v ${port} - done -} - config_printing() { local port - #first of all get the vars + # first of all get the vars get_printer_settings # first of all delete all printers, by wiping /etc/cups/printers.conf @@ -113,8 +41,6 @@ [ -n "$(pidof cupsd)" ] && /etc/init.d/cups stop &> /dev/null :> /etc/cups/printers.conf - # debug - echo "ALX_COUNT: ${ALX_COUNT}" for (( i=0; i < ALX_COUNT; i++ )) do # get real port settings @@ -124,10 +50,13 @@ ;; com1) port="serial:/dev/ttyS0?baud=9600+bits=8+parity=none+flow=none" - ;; + ;;# echo "DEBUG: deleting samba+cups+inetd" com2) port="serial:/dev/ttyS1?baud=9600+bits=8+parity=none+flow=none" ;; + usb1) + port="usb:/dev/usb/lp0" + ;; lpd) port="lpd://${ALX_IP[${i}]}/${ALX_SHARE[${i}]}" ;; @@ -137,7 +66,6 @@ esac # now add new printers (writing printers.conf) - #/usr/sbin/lpadmin -p ${ALX_PRINTER_NAME[${i}]} -E -v ${port} echo "" >> /etc/cups/printers.conf echo "Info ${ALX_PRINTER_NAME[${i}]}" >> /etc/cups/printers.conf echo "DeviceURI ${port}" >> /etc/cups/printers.conf @@ -149,4 +77,19 @@ echo "KLimit 0" >> /etc/cups/printers.conf echo "" >> /etc/cups/printers.conf done + + # setup lpd print-services + echo "printer stream tcp nowait lp /usr/lib/cups/daemon/cups-lpd cups-lpd" > /etc/inetd.conf + + # start samba and cups if ALX_COUNT > 0 + if [[ ${ALX_COUNT} != 0 ]] + then + rc-config add inetd &> /dev/null + rc-config add cups &> /dev/null + rc-config add samba &> /dev/null + else + rc-config del inetd &> /dev/null + rc-config del cups &> /dev/null + rc-config del samba &> /dev/null + fi }