--- alx-src/trunk/alxconfig-ng/functions/config_printers.sh 2005/04/20 11:46:41 270 +++ alx-src/trunk/alxconfig-ng/functions/config_printers.sh 2005/10/09 21:29:41 341 @@ -1,4 +1,4 @@ -# $Header: /home/cvsd/alx-cvs/alx-src/alxconfig-ng/functions/config_printers.sh,v 1.8 2005-04-20 11:46:41 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,55 +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 @@ -114,9 +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 @@ -126,7 +50,7 @@ ;; 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" ;; @@ -139,7 +63,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 @@ -158,12 +81,10 @@ # start samba and cups if ALX_COUNT > 0 if [[ ${ALX_COUNT} != 0 ]] then -# echo "DEBUG: adding samba+cups+inetd" rc-config add inetd &> /dev/null rc-config add cups &> /dev/null rc-config add samba &> /dev/null else -# echo "DEBUG: deleting samba+cups+inetd" rc-config del inetd &> /dev/null rc-config del cups &> /dev/null rc-config del samba &> /dev/null