#---------------------------------------------------------------------------- # /etc/rc.d/rc490.cups - configuration of the cups printer daemon # # Creation: 02.01.2006 Christian Brueggemann # Update: 20.06.2006 dito # Update: 02.11.2008 Steffen Sledz # Last update: $Id$ #---------------------------------------------------------------------------- if [ "$OPT_CUPS" = yes ] then begin_script CUPS loggerbin='/usr/bin/logger' colechobin='/usr/local/bin/colecho' cupsspooldir='/var/spool/cups' spooldir_error='true' path='' cupsnet='' start_cups='false' data_mount=`cat /proc/mounts | grep '/data' | grep 'rw'` $colechobin "configuring cups on $HOSTNAME ..." gn if [ -f "$loggerbin" ] then msgcmd="$loggerbin -t cups -p local0" msgcmdfail="$msgcmd.error " msgcmdinfo="$msgcmd.info " else msgcmd='echo' msgcmdfail='echo' msgcmdinfo='echo' fi #-------------------------------------------------------------------------- # do some needed symlinks #-------------------------------------------------------------------------- echo "ipp 631/tcp" >>/etc/services if [ ! -d /etc/cups/ppd ] # existing? then # no, create mkdir -p /etc/cups/ppd fi if [ ! -d /etc/cups/interfaces ] # existing? then # no, create mkdir -p /etc/cups/interfaces fi if [ ! -d /etc/cups/certs ] # existing? then # no, create mkdir -p /etc/cups/certs fi if [ ! -f /etc/cups/printers.conf ] # existing? then # no, create echo "" >> /etc/cups/printers.conf fi if [ ! -d /usr/local/cups/share/cups/model ] # existing? then # no, create mkdir -p /usr/local/cups/share/cups/model fi if [ ! -d /usr/local/cups/share/cups/banners ] # existing? then # no, create mkdir -p /usr/local/cups/share/cups/banners fi if [ -f /usr/local/cups/sbin/accept ] # existing? then if [ ! -d /usr/local/cups/bin ] # existing? then # no, create mkdir -p /usr/local/cups/bin fi ln -s /usr/local/cups/sbin/accept /usr/local/cups/bin/disable ln -s /usr/local/cups/sbin/accept /usr/local/cups/bin/enable ln -s /usr/local/cups/sbin/accept /usr/local/cups/sbin/reject fi if [ -f /usr/local/cups/lib/cups/backend/ipp ] # existing? then ln -s /usr/local/cups/lib/cups/backend/ipp /usr/local/cups/lib/cups/backend/http fi #-------------------------------------------------------------------------- # creat needed symlinks for lpd #-------------------------------------------------------------------------- if [ "$OPT_CUPS_LPD" = yes ] then if [ -f /usr/local/cups/bin/lpr ] # existing? then if [ -f /usr/bin/lpr ] # existing? then rm /usr/bin/lpr fi ln -s /usr/local/cups/bin/lpr /usr/bin/lpr fi if [ -f /usr/local/cups/bin/lprm ] # existing? then if [ -f /usr/bin/lprm ] # existing? then rm /usr/bin/lprm fi ln -s /usr/local/cups/bin/lprm /usr/bin/lprm fi fi #-------------------------------------------------------------------------- # search mounted data partition for spooling #-------------------------------------------------------------------------- if [ -n "$data_mount" ] then for i in minix ext2 ext3 do if [ -n "`echo $data_mount | grep $i`" ] then spooldir_error='false' $msgcmdinfo "mounted writeable partition /data with file system $i found" path='/data' fi done if [ "$spooldir_error" = "false" ] then path="$path/cups_spooldir" if [ -d "$path" ] then rm -r "$path" fi mkdir "$path" if [ $? -eq 0 ] then $msgcmdinfo "spool directory $path on $HOSTNAME created" ln -s "$path" "$cupsspooldir" else $colechobin "*** ERROR: cannot create spool directory $path on $HOSTNAME! ***" br x br $colechobin "*** ERROR: check /proc/mounts! ***" br x br $colechobin "*** ERROR: printing function on hd not available! ***" br x br sleep 5 $msgcmdfail "*** ERROR: cannot create spool directory $path on $HOSTNAME! ***" $msgcmdfail "*** ERROR: check /proc/mounts! ***" $msgcmdfail "*** ERROR: printing function on hd not available! ***" spooldir_error='true' fi fi else $msgcmdinfo "no mounted writeable minix/ext2/ext3 data partition found" sleep 5 fi if [ "$spooldir_error" = "true" ] then mkdir "$cupsspooldir" $colechobin "*** Warning! ***" br x br $colechobin "*** spooling into rootfs ramdisk! ***" br x br $colechobin "*** big jobs can break router functionality! ***" br x br sleep 5 $msgcmdinfo "*** Warning! ***" $msgcmdinfo "*** spooling into rootfs ramdisk! ***" $msgcmdinfo "*** big jobs can break router functionality! ***" fi mkdir "$cupsspooldir/tmp" #-------------------------------------------------------------------------- # begin writing /etc/cups/cupsd.conf, if not exists: #-------------------------------------------------------------------------- if [ ! -f /etc/cups/cupsd.conf ] # existing? then # no, create if [ -n "$CUPS_ALLOWED_NET" ] then cupsnet="$CUPS_ALLOWED_NET" start_cups='true' else idx='1' for idx in `seq 1 $IP_NET_N` do eval iptmp='$IP_NET_'$idx'' eval ethx='$IP_NET_'$idx'_DEV' ipaddr=`echo $iptmp | sed -e 's/\/.*//'` dhciface='no' for i in $DHCLIENT_INTERFACES $DHCPCD_INTERFACES do if [ "$i" = "$ethx" ] then $msgcmdinfo "$ethx is an dhcp client interface, don't configuring cups for it..." dhciface=yes fi done if [ "$dhciface" = "no" ] then if [ "$ipaddr" != "0.0.0.0" -a -n "$ipaddr" ] then eval net='$IP_NET_'$idx'' localnet=`netcalc dnsnet $net` if [ -z "$cupsnet" ] then cupsnet="$localnet." else cupsnet="$cupsnet $localnet." fi start_cups='true' fi fi done fi (echo "" echo "########################################################################" echo "# #" echo "# This is the CUPS configuration file. If you are familiar with #" echo "# Apache or any of the other popular web servers, we've followed the #" echo "# same format. Any configuration variable used here has the same #" echo "# semantics as the corresponding variable in Apache. If we need #" echo "# different functionality then a different name is used to avoid #" echo "# confusion... #" echo "# #" echo "########################################################################" echo "" echo "Listen localhost:631" bind_list= for idx in `seq 1 $CUPS_LISTEN_N` do eval addr='$CUPS_LISTEN_'$idx'' oldIFS="$IFS" IFS=":" set -- $addr IFS="$oldIFS" eval translate_ip_net $1 if [ is_error ] then echo "Listen $res:$2" bind_list="$bind_list $res:$2" fi done echo "User root" echo "Group root" echo "MaxJobs 25" echo "RIPCache 2m" echo "HostNameLookups Off" echo "KeepAlive On" echo "Browsing Off" echo "BrowseProtocols cups" case "$CUPS_WEB_LANG" in de) echo "DefaultLanguage de" ;; fr) echo "DefaultLanguage fr" ;; *) echo "DefaultLanguage en" ;; esac echo "RequestRoot $cupsspooldir" echo "TempDir $cupsspooldir" echo "PreserveJobFiles No" echo "AutoPurgeJobs Yes" echo "PreserveJobHistory Yes" echo "MaxPrinterHistory 10" echo "AccessLog syslog" echo "ErrorLog syslog" echo "LogLevel info" echo "PageLog syslog" echo "" echo "" echo "Order Allow,Deny" for n in $cupsnet do echo "Allow From $n" done echo "" echo "" echo "" echo "AuthType Basic" echo "AuthClass System" echo "Order Allow,Deny" for n in $cupsnet do echo "Allow From $n" done echo "" echo "" ) > /etc/cups/cupsd.conf fi #-------------------------------------------------------------------------- # create Par. Printer if configured #-------------------------------------------------------------------------- if [ "$OPT_CUPS_PARPORT" = "yes" -a "$CUPS_PARPORT_N" != "0" ] then idx='1' idy='0' while [ "$idx" -le "$CUPS_PARPORT_N" ] do eval port='$CUPS_PARPORT_'$idx'_IO' eval interrupt='$CUPS_PARPORT_'$idx'_IRQ' eval direct='$CUPS_PARPORT_'$idx'_DMA' port=`echo $port | tr 'A-FX' 'a-fx'` if [ "$interrupt" = "yes" ] then interrupt='auto' else interrupt='none' fi if [ "$direct" = "yes" ] then direct='auto' else direct='none' fi if [ -z "$parport" ] then parport="$idy" else parport="$parport,$idy" fi if [ -z "$io" ] then io="$port" else io="$io,$port" fi if [ -z "$irq" ] then irq="$interrupt" else irq="$irq,$interrupt" fi if [ -z "$dma" ] then dma="$direct" else dma="$dma,$direct" fi eval lpname='$CUPS_PARPORT_'$idx'_NAME' if [ -n "$lpname" ] then name="$lpname" else name="parpr$idx" fi (echo "" echo "Info Parallel Port Printer" echo "Location attached on $HOSTNAME" echo "DeviceURI parallel:/dev/lp$idy" echo "State Idle" echo "Accepting Yes" echo "JobSheets none none" echo "QuotaPeriod 0" echo "PageLimit 0" echo "KLimit 0" echo "" echo "" ) >> /etc/cups/printers.conf $msgcmdinfo "cups-par-printer $name on $HOSTNAME will be accessable" idx=`expr $idx + 1` idy=`expr $idy + 1` done $colechobin "loading parport on io $io, irq $irq, dma $dma ..." gn $msgcmdinfo "loading parport on io $io, irq $irq, dma $dma ..." do_modprobe parport do_modprobe parport_pc io=$io irq=$irq dma=$dma do_modprobe lp parport=$parport fi #-------------------------------------------------------------------------- # create USB Printer if configured #-------------------------------------------------------------------------- if [ "$OPT_CUPS_USBPORT" = "yes" -a "$CUPS_USBPORT_N" != "0" ] then idx='1' idy='0' while [ "$idx" -le "$CUPS_USBPORT_N" ] do case "$kernel_major" in 2.6) $colechobin "loading usb-printer on /dev/usb/lp$idy ..." gn $msgcmdinfo "loading usb-printer on /dev/usb/lp$idy ..." mkdir -p /dev/usb /bin/mknod "/dev/usb/lp$idy" c 180 "$idy" ;; *) $colechobin "loading usb-printer on /dev/usblp$idy ..." gn $msgcmdinfo "loading usb-printer on /dev/usblp$idy ..." /bin/mknod "/dev/usblp$idy" c 180 "$idy" ;; esac eval lpname='$CUPS_USBPORT_'$idx'_NAME' if [ -n "$lpname" ] then name="$lpname" else name="usbpr$idx" fi (echo "" echo "Info USB Printer" echo "Location attached on $HOSTNAME" case "$kernel_major" in 2.6) echo "DeviceURI usb:/dev/usb/lp$idy" ;; *) echo "DeviceURI usb:/dev/usblp$idy" ;; esac echo "State Idle" echo "Accepting Yes" echo "JobSheets none none" echo "QuotaPeriod 0" echo "PageLimit 0" echo "KLimit 0" echo "" echo "" ) >> /etc/cups/printers.conf $msgcmdinfo "cups-usb-printer $name on $HOSTNAME will be accessable" idx=`expr $idx + 1` idy=`expr $idy + 1` done case "$kernel_major" in 2.6) do_modprobe usblp ;; *) do_modprobe printer ;; esac fi #-------------------------------------------------------------------------- # start cupsd #-------------------------------------------------------------------------- if [ "$start_cups" = "true" ] then $colechobin "starting cups..." gn $msgcmdinfo "starting cups..." /usr/local/cups/sbin/cupsd else $colechobin "*** ERROR: cannot start cups on $HOSTNAME! ***" br x br $msgcmdfail "*** ERROR: cannot start cups on $HOSTNAME! ***" $colechobin "*** ERROR: check OPT_CUPS! ***" br x br $msgcmdfail "*** ERROR: check OPT_CUPS! ***" fi #-------------------------------------------------------------- # CUPS Epson Ink Webinterface #-------------------------------------------------------------- if [ "$CUPS_EPSON_WEBVIEW" = "yes" ] then /usr/local/bin/httpd-menu.sh add cups.cgi Cups Opt fi end_script fi