hardware:jednodeskove-pocitace:raspberry-pi:raspberrypi-lan-print-scan-and-pdf-server

no way to compare when less than two revisions

Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.


hardware:jednodeskove-pocitace:raspberry-pi:raspberrypi-lan-print-scan-and-pdf-server [2026/03/09 14:44] (aktuální) – Migrace Raspberry Pi LAN serveru do nove hardware IA Petr Nosek
Řádek 1: Řádek 1:
 +====== Ultimate Raspberry Pi: LAN Print, Scan and PDF Server ======
  
 +Článek jsem měl historicky uložený a pochází ze zdroje, který už neexistuje. Jeho přesná název zněl: **Ultimate Raspberry Pi : LAN Print , Scan and PDF Server : CUPS + AirPrint + IPP + cups-pdf + sanescan ( SaneTwain ) + phpSANE / PHP-Scanner-Server ( scanner webinterface ) + samba ( remote file access )**.
 +
 +Datum článku byl 2.4.2014. Samozřejmě už některé věci nebudou aktuální a je potřeba se přizpůsobit. Dávám zde alespoň přepis článku.
 +
 +===== Assumptions =====
 +  * Completed Ultimate Raspberry Pi : Preparation and with optional server preparation.
 +  * Raspberry Pi IP address: **192.168.1.111**
 +
 +===== Install Dependencies =====
 +<code bash>
 +apt-get update && apt-get install -f avahi-daemon cups cups-pdf python-cups avahi-discover libnss-mdns sane-utils xinetd printer-driver-gutenprint system-config-printer-udev
 +</code>
 +
 +**Optional: Install one of the relevant printer drivers**
 +<code bash>
 +apt-get install printer-driver-c2050 #printer driver for Lexmark 2050 Color Jetprinter
 +apt-get install printer-driver-c2esp #printer driver for Kodak ESP AiO color inkjet Series
 +apt-get install printer-driver-cjet #printer driver for Canon LBP laser printers
 +apt-get install printer-driver-escpr #printer driver for Epson Inkjet that use ESC P-R
 +apt-get install printer-driver-foo2zjs #printer driver for ZjStream-based printers
 +apt-get install printer-driver-gutenprint #printer drivers for CUPS
 +apt-get install printer-driver-hpcups #HP Linux Printing and Imaging - CUPS Raster driver (hpcups)
 +apt-get install printer-driver-hpijs #HP Linux Printing and Imaging - gs IJS driver (hpijs)
 +apt-get install printer-driver-m2300w #printer driver for Minolta magicolor 2300W 2400W color laser printers
 +apt-get install printer-driver-min12xxw #printer driver for KonicaMinolta PagePro 1[234]xxW
 +apt-get install printer-driver-pnm2ppa #printer driver for HP-GDI printers
 +apt-get install printer-driver-postscript-hp #HP Printers PostScript Descriptions
 +apt-get install printer-driver-ptouch #printer driver Brother P-touch label printers
 +apt-get install printer-driver-pxljr #printer driver for HP Color LaserJet 35xx 36xx
 +apt-get install printer-driver-sag-gdi #printer driver for Ricoh Aficio SP 1000s SP 1100s
 +apt-get install printer-driver-splix #Driver for Samsung and Xerox SPL2 and SPLc laser printers
 +</code>
 +
 +===== Configure cups to listen on the LAN =====
 +<code bash>
 +sed -i "s|Listen localhost:631|Listen *:631|" /etc/cups/cupsd.conf
 +</code>
 +
 +===== Allow LAN access to CUPS =====
 +<code bash>
 +sed -i "s|<Location />|<Location />\nAllow from all\n</Location>|g" /etc/cups/cupsd.conf
 +</code>
 +
 +===== Add the server name and browse address =====
 +Replace **192.168.1.255** with your LAN broadcast address.
 +<code bash>
 +echo -e "\nServerName raspberrypi" >> /etc/cups/cupsd.conf
 +sed -i -e "s|BrowseAddress|BrowseAddress 192.168.1.255\n#BrowseAddress|" /etc/cups/cupsd.conf
 +</code>
 +
 +===== Restart CUPS =====
 +<code bash>
 +service cups restart
 +</code>
 +
 +===== Add the pi user to the lpadmin group =====
 +<code bash>
 +adduser pi lpadmin
 +</code>
 +
 +===== Enable print sharing and remote administration =====
 +<code bash>
 +cupsctl --share-printers --remote-admin --remote-printers
 +sed -i "s|Shared No|Shared Yes|g" /etc/cups/printers.conf
 +lpoptions -d PDF -o printer-is-shared=true
 +</code>
 +
 +===== Custom cups-pdf output directory =====
 +**PDF storage directory: /storage/pdf**
 +<code bash>
 +mkdir -p /storage/pdf
 +chown root:lpadmin /storage/pdf
 +chmod 777 /storage/pdf
 +</code>
 +
 +===== Append the date to the PDF file name =====
 +<code bash>
 +mkdir -p /opt/extremeshok
 +cat > /opt/extremeshok/cups-pdf-postprocess <<EOF
 +#!/bin/bash
 +## eXtremeSHOK.com
 +FILENAME=`basename $1`
 +DIRNAME="/storage/pdf"
 +DATE=`date +"%Y-%m-%d_%H-%M-%S"`
 +mv $1 $DIRNAME"/"$DATE"_"$FILENAME
 +EOF
 +</code>
 +
 +===== Enable cups-pdf post processing =====
 +<code bash>
 +chmod 777 /opt/extremeshok/cups-pdf-postprocess
 +chown root:lpadmin /opt/extremeshok/cups-pdf-postprocess
 +sed -i "s|#PostProcessing|PostProcessing /opt/extremeshok/cups-pdf-postprocess|" /etc/cups/cups-pdf.conf
 +sed -i "s|#PDFVer 1.4|PDFVer 1.5|" /etc/cups/cups-pdf.conf
 +</code>
 +
 +===== Enable automatic retrying of failed print jobs =====
 +<code bash>
 +sed -i -e "s|BrowseAddress|ErrorPolicy retry-job\nJobRetryInterval 30\nBrowseAddress|" /etc/cups/cupsd.conf
 +</code>
 +
 +===== Restart CUPS =====
 +<code bash>
 +service cups restart
 +</code>
 +
 +===== Configure your printer =====
 +Visit the web interface: **https://192.168.1.111:631/admin**
 +
 +**Steps:**
 +  * Log in using:
 +    * **Admin username:** pi
 +    * **Admin password:** raspberry
 +  * Navigate to **Administration -> Find New Printers**
 +  * Add your printer and enable **Share This Printer**
 +  * Select your make and model or specify a PPD file.
 +  * Restart services:
 +<code bash>
 +service cups restart
 +service avahi-daemon restart
 +</code>
 +
 +===== Optional: Enable AirPrint =====
 +**(Not needed on iOS 7 and above)**
 +
 +Enhanced iOS support:
 +<code bash>
 +echo "image/urf urf (0,UNIRAST)" > /usr/share/cups/mime/apple.types
 +mkdir /opt/AirPrint
 +cd /opt/AirPrint
 +wget -O airprint-generate.py --no-check-certificate https://raw.github.com/vidaren/airprint-generate/master/airprint-generate.py
 +chmod +x airprint-generate.py
 +./airprint-generate.py -d /etc/avahi/services --cups
 +</code>
 +
 +===== Using your PDF postscript printer via IPP =====
 +**Driver: Microsoft Windows**
 +  * **Manufacturer:** Generic
 +  * **Printer:** MS Publisher Imagesetter
 +
 +Via IPP:
 +Use the following as the printer's location:
 +<code>
 +http://192.168.1.111:631/printers/PDF
 +</code>
 +
 +===== Using your printer via IPP =====
 +**Driver: Microsoft Vista and 7/8**
 +  * **Manufacturer:** HP
 +  * **Printer:** HP Color Laserjet 8550 PS or HP Color Laserjet 4550 PS
 +
 +**Driver: Microsoft 2000 and XP**
 +  * **Manufacturer:** HP
 +  * **Printer:** HP Color Laserjet PS
 +
 +Via IPP:
 +Use the following as the printer's location:
 +<code>
 +http://192.168.1.111:631/printers/printer_name
 +</code>
 +
 +===== Optional: Enable Scanning =====
 +**Enable scanning support and share a scanner on your network**
 +
 +Install:
 +<code bash>
 +apt-get install -f sane-utils xinetd
 +</code>
 +
 +Enable the saned service:
 +<code bash>
 +echo -e "\n192.168.1.0/24" >> /etc/sane.d/saned.conf
 +sed -i "s|RUN=no|RUN=yes|g" /etc/default/saned
 +</code>
 +
 +Enable the xinetd sane service:
 +<code bash>
 +cat > /etc/xinetd.d/saned <<EOF
 +# eXtremeSHOK.com
 +service saned {
 +    socket_type = stream
 +    server = /usr/sbin/saned
 +    protocol = tcp
 +    user = saned
 +    group = scanner
 +    wait = no
 +    disable = no
 +}
 +EOF
 +</code>
 +
 +**BUG FIX:** Scanner not working: usbfs: interface 1 claimed by usblp while `scanimage` sets config #1:
 +<code bash>
 +echo -e "\nblacklist usblp" >> /etc/modprobe.d/blacklist.conf
 +</code>
 +
 +Reboot:
 +<code bash>
 +sync && shutdown -r now
 +</code>
 +
 +Verify the scanner is supported and listening:
 +<code bash>
 +scanimage -L
 +</code>
 +
 +Example output:
 +<code>
 +device `xerox_mfp:libusb:001:004' is a Samsung Samsung SCX-4623 Series multi-function peripheral
 +</code>
 +
 +Verify the service:
 +<code bash>
 +cat /etc/services | grep sane
 +</code>
 +
 +Example output:
 +<code>
 +sane-port 6566/tcp sane saned # SANE network scanner daemon
 +</code>
 +
 +===== Optional: phpSANE (Web-Based Frontend for SANE) =====
 +**Note:** Simple and low requirements.
 +
 +Install Requirements:
 +<code bash>
 +apt-get install -y libapache2-mod-php5 unzip netpbm gocr imagemagick
 +</code>
 +
 +Install phpSANE:
 +<code bash>
 +mkdir -p /tmp/phpSANE
 +cd /tmp/phpSANE
 +wget -O phpSANE-0.8.0.zip "http://downloads.sourceforge.net/project/phpsane/phpsane/0.8.0/phpSANE-0.8.0.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fphpsane%2F&use_mirror=tenet"
 +unzip -q phpSANE-0.8.0.zip
 +mv /tmp/phpSANE/* /var/www/
 +</code>
 +
 +Configure:
 +<code bash>
 +sed -i "s|\" --jpeg-quality 0\"|\"\"|g" /var/www/incl/config.php
 +sed -i "s|/opt/bin/gocr|/usr/bin/gocr|g" /var/www/incl/config.php
 +sed -i "s|/usr/local/bin/pdfunite|/usr/bin/pdfunite|g" /var/www/incl/config.php
 +sed -i "s|Timeout 300|Timeout 900|g" /etc/apache2/apache2.conf
 +sed -i "s|max_execution_time = 30|max_execution_time = 900|g" /etc/php5/apache2/php.ini
 +sed -i "s|max_input_time = 60|max_input_time = 900|g" /etc/php5/apache2/php.ini
 +</code>
 +
 +Set Permissions:
 +<code bash>
 +chmod +s /usr/bin/scanimage
 +mkdir -p /var/www/tmp && chmod 775 /var/www/tmp
 +mkdir -p /var/www/output && chmod 775 /var/www/output
 +mkdir -p /var/www/scanners && chmod 775 /var/www/scanners
 +</code>
 +
 +
 +===== Optional: PHP-Scanner-Server (Advanced Web-Based Frontend for SANE) =====
 +**Note:** Requires 1GB+ drive space and a 512MB Raspberry Pi.
 +
 +Install Requirements:
 +<code bash>
 +apt-get install -y imagemagick sane-utils usbutils libapache2-mod-php5 php5-curl tesseract-ocr tar zip php-fpdf libpaper-utils grep sed coreutils
 +</code>
 +
 +Add `www-data` to the `lp` group:
 +<code bash>
 +adduser www-data lp
 +</code>
 +
 +Install PHP-Scanner-Server:
 +<code bash>
 +mkdir -p /tmp/PHP-Scanner-Server
 +cd /tmp/PHP-Scanner-Server
 +wget -O PHP-Scanner-Server.zip "https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/archive/master.zip"
 +unzip -q PHP-Scanner-Server.zip
 +mkdir -p /var/www/scanner/
 +mv -f /tmp/PHP-Scanner-Server/PHP-Scanner-Server-master/* /var/www/scanner/
 +</code>
 +
 +Configure:
 +<code bash>
 +sed -i "s|Timeout 300|Timeout 900|g" /etc/apache2/apache2.conf
 +sed -i "s|max_execution_time = 30|max_execution_time = 900|g" /etc/php5/apache2/php.ini
 +sed -i "s|max_input_time = 60|max_input_time = 900|g" /etc/php5/apache2/php.ini
 +</code>
 +
 +Create Directories and Set Permissions:
 +<code bash>
 +mkdir -p /var/www/scanner/scans
 +chmod 775 /var/www/scanner/scans
 +chown www-data /var/www/scanner/scans
 +mkdir -p /var/www/scanner/config
 +chmod 775 /var/www/scanner/config
 +chown www-data /var/www/scanner/config
 +</code>
 +
 +Configure PHP-Scanner-Server:
 +<code bash>
 +sed -i "s|Timeout 300|Timeout 900|g" /var/www/scanner/config.ini
 +sed -i "s|FreeSpaceWarn = 2048|FreeSpaceWarn = 1024|g" /var/www/scanner/config.ini
 +sed -i "s|Fortune = true|Fortune = false|g" /var/www/scanner/config.ini
 +sed -i "s|RulerIncrement = 25.4|RulerIncrement = 10|g" /var/www/scanner/config.ini
 +sed -i "s|TimeZone = ''|TimeZone = 'UTC'|g" /var/www/scanner/config.ini
 +sed -i "s|Printer = 0|Printer = 1|g" /var/www/scanner/config.ini
 +</code>
 +
 +Access the web interface for configuration:
 +<code>
 +http://192.168.1.111/scanner/index.php?page=Config
 +</code>
 +
 +===== Using Your Scanner =====
 +**Windows Users:** Use TWAIN drivers to create a bridge between TWAIN and SANE on the network.
 +
 +Download the Windows installer:
 +<code>
 +http://sanetwain.ozuzo.net/downloads/setup136.exe
 +</code>
 +
 +Configure the connection:
 +  * **Hostname:** 192.168.1.111
 +  * **Port:** 6566
 +  * **Username:** PCUSER
 +  * **Options:** Tick "Get list of devices on startup"
 +
 +===== Optional: Enable Samba =====
 +**We will create a PDF share and a scanner share.**
 +
 +Install Samba:
 +<code bash>
 +apt-get install -y samba samba-common-bin
 +</code>
 +
 +Configure `smb.conf`:
 +<code bash>
 +cat > /etc/samba/smb.conf <<EOF
 +# eXtremeSHOK.com
 +[global]
 +workgroup = WORKGROUP
 +netbios name = RASPBERRYPI
 +server string = %h
 +wins support = yes
 +dns proxy = no
 +log file = /var/log/samba/log.%m
 +max log size = 1000
 +security = share
 +share modes = yes
 +name resolve order = bcast host lmhost wins
 +
 +[pdfs]
 +comment = Where PDF's get stored after printing
 +path = /storage/pdf
 +public = yes
 +writable = yes
 +browseable = yes
 +printable = no
 +guest ok = yes
 +create mask = 0777
 +directory mask = 0777
 +
 +[scans]
 +comment = Where scans get stored after scanning
 +path = /var/www/output
 +public = yes
 +writable = yes
 +browseable = yes
 +printable = no
 +guest ok = yes
 +create mask = 0777
 +directory mask = 0777
 +EOF
 +</code>
 +
 +Restart Samba:
 +<code bash>
 +service samba restart
 +</code>
 +
 +===== Optional: rpisysinfoscript (Web-Based System Information Frontend) =====
 +Visit the web interface:
 +<code>
 +http://192.168.1.111/sysinfo.php
 +</code>
 +
 +Install Requirements:
 +<code bash>
 +apt-get install -y libapache2-mod-php5 lsb-release lsscsi git -y
 +</code>
 +
 +Install rpisysinfoscript:
 +<code bash>
 +cd /tmp
 +wget -O rpisysinfoscript.php "https://gist.githubusercontent.com/jvhaarst/4388108/raw/4ae8702effeafb89e583722f5a963ba6c1a4d06a/gistfile1.php"
 +mv /tmp/rpisysinfoscript.php /var/www/sysinfo.php
 +</code>
 +
 +
 +===== CUPS Command Line Utilities =====
 +
 +Here is a list of CUPS command line utilities and their functions:
 +
 +  * **accept**  
 +    Instructs the printing system to accept print jobs to the specified destinations.
 +
 +  * **cancel**  
 +    Cancels existing print jobs from the print queues.
 +
 +  * **cupsaddsmb**  
 +    Exports printers to the Samba software for use with Windows clients.
 +
 +  * **cups-config**  
 +    A CUPS program configuration utility.
 +
 +  * **cupsctl**  
 +    Updates or queries the `cupsd.conf` file for a server.
 +
 +  * **cupsd**  
 +    The scheduler for the Common Unix Printing System.
 +
 +  * **cupsfilter**  
 +    A front-end to the CUPS filter subsystem, allowing you to convert a file to a specific format.
 +
 +  * **cupstestdsc**  
 +    Tests the conformance of PostScript files.
 +
 +  * **cupstestppd**  
 +    Tests the conformance of PPD files.
 +
 +  * **ippfind**  
 +    Finds Internet Printing Protocol (IPP) printers.
 +
 +  * **ipptool**  
 +    Sends IPP requests to the specified URI and tests and/or displays the results.
 +
 +  * **lp**  
 +    Submits files for printing or alters a pending job.
 +
 +  * **lpadmin**  
 +    Configures printer and class queues provided by CUPS.
 +
 +  * **lpc**  
 +    Provides limited control over printer and class queues provided by CUPS.
 +
 +  * **lpinfo**  
 +    Lists the available devices or drivers known to the CUPS server.
 +
 +  * **lpmove**  
 +    Moves the specified job to a new destination.
 +
 +  * **lpoptions**  
 +    Displays or sets printer options and defaults.
 +
 +  * **lppasswd**  
 +    Adds, changes, or deletes passwords in the CUPS digest password file `passwd.md5`.
 +
 +  * **lpq**  
 +    Shows the current print queue status on the named printer.
 +
 +  * **lpr**  
 +    Submits files for printing.
 +
 +  * **lprm**  
 +    Cancels print jobs that have been queued for printing.
 +
 +  * **lpstat**  
 +    Displays status information about the current classes, jobs, and printers.
 +
 +  * **ppdc**  
 +    Compiles PPDC source files into one or more PPD files.
 +
 +  * **ppdhtml**  
 +    Reads a driver information file and produces an HTML summary page listing all the drivers in a file and their supported options.
 +
 +  * **ppdi**  
 +    Imports one or more PPD files into a PPD compiler source file.
 +
 +  * **ppdmerge**  
 +    Merges two or more PPD files into a single, multi-language PPD file.
 +
 +  * **ppdpo**  
 +    Extracts UI strings from PPDC source files and updates either a GNU gettext or Mac OS X strings format message catalog source file for translation.
 +
 +  * **reject**  
 +    Instructs the printing system to reject print jobs to the specified destinations.
 +
 +  * **libcups.so**  
 +    Contains the CUPS API functions.
  • hardware/jednodeskove-pocitace/raspberry-pi/raspberrypi-lan-print-scan-and-pdf-server.txt
  • Poslední úprava: 2026/03/09 14:44
  • autor: Petr Nosek