Como posso fazer o download de um PPD (driver de impressora) a partir da impressão aberta em um script?

0

Isto é para o meu script Raspberry Pi 3 adicionar uma impressora a um novo sistema (para poupar tempo da próxima vez que o quebro).

Eu quero automatizar o processo de aquisição de drivers usando wget ou curl . Alguma idéia?

Tentativa

curl -L --max-redirs 1 -J -o Oh-brother-this-is-a-pain.ppd "Brother-HL2030-HL1250.ppd" http://www.openprinting.org/ppd-o-matic.php?driver=hl1250&printer=Brother-HL-2030&show=0

O retorno sobre isso é:

foomatic-ppdfile -A
foomatic-ppdfile -P <regexpr>
foomatic-ppdfile -p <printerid> [-d <driver>] [-w]
foomatic-ppdfile list
foomatic-ppdfile cat <CUPS PPD URI> [-w]
foomatic-ppdfile -h

 -A             : show all Printer ID's and compatible drivers
 -P <regexpr>   : show all Printer ID's whose names and model
                  matched by the RE.  For example:
                   -P HP will match all names with HP in them
 -p <printerid> : Printer ID
 -d <driver>    : Driver name
                  If the driver is not specified then the default driver 
                  for the <printerid> is used.
 list           : List all possible PPDs in the format needed by the
                  cups-driverd
 cat <CUPS PPD URI> : Generate PPD file appropriate to the <CUPS PPD URI>.
                  Available CUPS PPD URIs are listed by 
                  "foomatic-ppdfile list".
 -w             : Generate PPD which is compatible with the CUPS PostScript
                  driver for Windows (GUI strings are limited to 39 
                  characters).
 -h             : show help information

Script completo

Projetado para minha impressora específica: Brother HL-2030.

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi
# install cups
if [ $(pacman -Qeq cups) != "cups"  ]
then
  pacman -Sy cups --noconfirm
fi
if [ $(pacman -Qeq ghostscript) != "ghostscript"  ]
  pacman -Sy ghostscript --noconfirm
fi
if [ $(pacman -Qeq foomatic-db) != "foomatic-db"  ]
  pacman -Sy foomatic-db --noconfirm
fi

# allow users of group admin to be admin
perl -ip -e 's/SystemGroup sys root$/SystemGroup sys root admin/' /etc/cups/cups-files.conf

systemctl enable --now org.cups.cupsd.service
cupsctl --remote-admin


# Check to see if the drivers are installed
cd /usr/share/ppd
if [ ! -e /usr/share/ppd/Brother-HL2030-HL1250.ppd ]
then
  echo "Printer driver not found. Attempting to download it and install it under /usr/share/ppd."
  #curl -L --max-redirs 1 -J -s -o "Brother-HL2030-HL1250.ppd" http://www.openprinting.org/ppd-o-matic.php?driver=hl1250&printer=Brother-HL-2030&show=0
  #wget https://cialu.net/wp-content/uploads/2017/04/Brother-HL-2030-hl1250.zip -O Brother-HL2030-HL1250.ppd
fi

# Add printer
lpadmin -p Brother-HL2030 -v $(lpinfo -v | grep direct | cut -d ' ' -f2) -P "Brother-HL2030-HL1250.ppd"
# Set settings
lpadmin -p Brother-HL2030 -o PageSize=A4 -o Resolution=600x600dpi
# List options
# lpoptions -l


# Setup AirPrint
if [ $(pacman -Qeq avahi) != "avahi" ]
then
  pacman -Sy avahi-daemon --noconfirm
fi
cat > /etc/avahi/services/AirPrint-Brother-HL2030.service << STOPSTRING
<?xml version="1.0" ?><!DOCTYPE service-group  SYSTEM 'avahi-service.dtd'><service-group><name replace-wildcards="yes">Brother-HL2030</name><service><type>_ipp._tcp</type><subtype>_universal._sub._ipp._tcp</subtype><port>631</port><txt-record>txtvers=1</txt-record><txt-record>qtotal=1</txt-record><txt-record>Transparent=T</txt-record><txt-record>URF=none</txt-record><txt-record>rp=printers/Brother-HL2030</txt-record><txt-record>note=Raspberry Pi</txt-record><txt-record>product=(GPL Ghostscript)</txt-record><txt-record>printer-state=3</txt-record><txt-record>printer-type=0x80b004</txt-record><txt-record>pdl=application/octet-stream,application/pdf,application/postscript,application/vnd.cups-raster,image/gif,image/jpeg,image/png,image/tiff,image/urf,text/html,text/plain,application/vnd.adobe-reader-postscript,application/vnd.cups-command</txt-record></service></service-group>'
STOPSTRING
systemctl enable --now avahi-daemon

# get status of printers
cupsaccept Brother-HL2030
lpstat -a
    
por Jonathan Komar 30.03.2018 / 20:38

0 respostas