#------------------------------------------------------------------------------ # /etc/rc.d/rc445.lpd - start lpd __FLI4LVER__ # was file /etc/rc.d/rc550.lpd # # Creation : 27.12.2000 fm # Last Update: $Id$ #------------------------------------------------------------------------------ if [ "$OPT_LPD" = "yes" ] then begin_script LPD "configuring lpd..." echo "lp:x:7:" >>/etc/group echo "printer 515/tcp" >>/etc/services #-------------------------------------------------------------------------- # create ramdisk and directories for spooling: #-------------------------------------------------------------------------- port='' io='' irq='' interrupt='' parport='' dma='' direct='' spooldir_error='true' path='' lpdir='/var/spool/lp' lpddir='/var/spool/lpd' do_printing='' printcapfile='/etc/printcap' hostslpdfile='/etc/hosts.lpd' data_mount=`cat /proc/mounts | grep ' /data ' | grep ' rw'` mkdir -p "$lpddir" chmod 775 "$lpddir" chown root "$lpddir" chgrp root "$lpddir" if [ -n "$data_mount" ] then case "$data_mount" in *minix* | *ext2* | *ext3*) path="/data/lp_spooldir" rm -rf "$path" if mkdir "$path"; then log_info "spool directory $path on $HOSTNAME created" ln -s "$path" "$lpdir" do_printing='yes' spooldir_error='false' else log_error "cannot create spool directory $path on $HOSTNAME!" log_error "check /proc/mounts!" log_error "printing function on hdd not available!" fi ;; esac else log_warn "no mounted writeable minix/ext2/ext3 data partition found" fi if [ "$spooldir_error" = "true" ] then mkdir "$lpdir" do_printing='yes' log_warn "spooling into rootfs ramdisk!" log_warn "big jobs can break router functionality!" fi #-------------------------------------------------------------------------- # begin writing /etc/printcap, if not exists: #-------------------------------------------------------------------------- overwrite='false' if [ "$do_printing" = "yes" ] then if [ ! -f "$printcapfile" ] then overwrite='true' { echo "#----------------------------------------------------------------------------" echo "# $printcapfile" echo "# automatically created by rc445.lpd" echo "#----------------------------------------------------------------------------" } >"$printcapfile" fi #---------------------------------------------------------------------- # configuration for local parallel printers #---------------------------------------------------------------------- if [ "$OPT_LPD_PARPORT" = "yes" ] then idx='1' idy='0' while [ "$idx" -le "$LPD_PARPORT_N" ] do mkdir "$lpdir/pr$idx" chmod 777 "$lpdir/pr$idx" eval port='$LPD_PARPORT_'$idx'_IO' eval interrupt='$LPD_PARPORT_'$idx'_IRQ' eval direct='$LPD_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 if [ "$overwrite" = true ] then { echo "pr$idx:\\" echo " :rw:\\" echo " :sh:\\" echo " :lp=/dev/lp$idy:\\" echo " :sd=$lpdir/pr$idx:\\" echo " :fx=flp:\\" echo " :sf:\\" echo " :mx#0:" echo } >>"$printcapfile" fi idx=`expr $idx + 1` idy=`expr $idy + 1` done fi #---------------------------------------------------------------------- # configuration for local usb printers #---------------------------------------------------------------------- if [ "$OPT_LPD_USBPORT" = "yes" ] then idx='1' idy='0' while [ "$idx" -le "$LPD_USBPORT_N" ] do mkdir "$lpdir/usbpr$idx" chmod 777 "$lpdir/usbpr$idx" mknod "/dev/usblp$idy" c 180 "$idy" if [ "$overwrite" = "true" ] then { echo "usbpr$idx:\\" echo " :rw:\\" echo " :sh:\\" echo " :lp=/dev/usblp$idy:\\" echo " :sd=$lpdir/usbpr$idx:\\" echo " :fx=flp:\\" echo " :sf:\\" echo " :mx#0:" echo } >>"$printcapfile" fi idx=`expr $idx + 1` idy=`expr $idy + 1` done fi #---------------------------------------------------------------------- # configuration for remote printers #---------------------------------------------------------------------- if [ "$OPT_LPD_REMOTE" = "yes" ] then idx='1' while [ "$idx" -le "$LPD_REMOTE_N" ] do mkdir "$lpdir/repr$idx" chmod 777 "$lpdir/repr$idx" eval remoteip='$LPD_REMOTE_'$idx'_IP' eval remoteport='$LPD_REMOTE_'$idx'_PORT' eval remotequeuename='$LPD_REMOTE_'$idx'_QUEUENAME' if [ "$overwrite" = "true" ] then { echo "repr$idx:\\" echo " :rw:\\" echo " :sh:\\" echo " :sd=$lpdir/repr$idx:\\" echo " :fx=flp:\\" echo " :sf:\\" if [ -n "$remoteport" ] then echo " :lp=$remoteport@$remoteip:\\" else echo " :lp=:\\" echo " :rm=$remoteip:\\" echo " :rp=$remotequeuename:\\" fi echo " :mx#0:" echo } >>$printcapfile fi idx=`expr $idx + 1` done fi #---------------------------------------------------------------------- # configuration for remote smb printers #---------------------------------------------------------------------- if [ "$OPT_LPD_SMBREMOTE" = "yes" ] then eval debuglevel='$LPD_SMBREMOTE_DEBUGLEVEL' idx='1' while [ "$idx" -le "$LPD_SMBREMOTE_N" ] do mkdir "$lpdir/smbrepr$idx" mkdir "$lpdir/smbrepr$idx/acct" chmod 777 "$lpdir/smbrepr$idx" >"/dev/smbrepr$idx" eval server='$LPD_SMBREMOTE_'$idx'_SERVER' eval service='$LPD_SMBREMOTE_'$idx'_SERVICE' eval user='$LPD_SMBREMOTE_'$idx'_USER' eval password='$LPD_SMBREMOTE_'$idx'_PASSWORD' eval ip='$LPD_SMBREMOTE_'$idx'_IP' if [ "$overwrite" = "true" ] then { echo "server=$server" echo "service=$service" echo "username=\"$user\"" echo "password=\"$password\"" echo "ip=$ip" echo "debuglevel=$debuglevel" } >>"$lpdir/smbrepr$idx/acct/.config" { echo "smbrepr$idx:\\" echo " :rw:\\" echo " :sh:\\" echo " :lp=/dev/smbrepr$idx:\\" echo " :sd=$lpdir/smbrepr$idx:\\" echo " :if=/bin/smbprint:\\" echo " :af=$lpdir/smbrepr$idx/acct:\\" echo " :fx=flp:\\" echo " :sf:\\" echo " :mx#0:" echo } >>"$printcapfile" fi idx=`expr $idx + 1` done fi fi #-------------------------------------------------------------------------- # write /etc/hosts.lpd to allow remote printing via lpr #-------------------------------------------------------------------------- if [ ! -f "$hostslpdfile" ] then { echo "#----------------------------------------------------------------------------" echo "# $hostslpdfile" echo "# automatically created by rc445.lpd" echo "#----------------------------------------------------------------------------" } >"$hostslpdfile" idx=1 while [ "$idx" -le "$HOSTS_N" ] do eval name='$HOST_'$idx'_NAME' if [ -n "$name" ] then echo "$name" >>"$hostslpdfile" fi idx=`expr $idx + 1` done fi #-------------------------------------------------------------------------- # loading drivers #-------------------------------------------------------------------------- if [ "$OPT_LPD_PARPORT" = "yes" -a "$LPD_PARPORT_N" != "0" ] then log_info "loading parport on io $io, irq $irq, dma $dma ..." do_modprobe parport_pc io=$io irq=$irq dma=$dma do_modprobe lp parport=$parport fi if [ "$OPT_LPD_USBPORT" = "yes" -a "$LPD_USBPORT_N" != "0" ] then case $kernel_major in 2.6) do_modprobe usblp ;; *) do_modprobe printer ;; esac fi #---------------------------------------------------------------------------- # start server #---------------------------------------------------------------------------- log_info "starting lpd..." /usr/sbin/lpd -l end_script fi