User Tools

Site Tools


userspace:cups_printer_installation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

userspace:cups_printer_installation [2012/09/19 12:49]
bhubal
userspace:cups_printer_installation [2021/08/23 08:37]
Line 1: Line 1:
-====== CUPS Printer Installation ====== 
-2009-02-25\\ 
-Script by uib Gmbh \\ 
-Comments and improvements welcome \\ 
-id: cupsprinter\\ 
-name: CUPS Printer Installation\\ 
-description: Installiert auf dem Server verfuegbare Drucker als CUPS-Postscript-Drucker\\ 
-advice: Ueber CUPS neu angelegte Drucker werden erst nach etwa 10 Minuten erfolgreich erkannt. 
  
-full package: https://download.uib.de/opsi4.0/products/contribute/full-package/cupsprinter_1.1-1.opsi 
- 
-==== cupsprinter.ins ==== 
- 
-<code winst> 
-[Initial] 
-; NOTE: 
-;   If a new cups printer is added, it will take some time 
-;   before the printer is published by samba (default 750s) 
-;   use smb.conf paramter "printcap cache time" to change printer reload interval 
-; 
- 
-; Message at install time: 
-Message=Installiere CUPS-Drucker ... 
-LogLevel=2 
-;  Log Errors in Logfile but don't abort: 
-ExitOnError=false 
-; Show syntax errors in the script: 
-ScriptErrorMessages=on 
-; Dont trace step by step through the script: 
-TraceMode=off 
-; let started programs run in front of the winst window 
-StayOnTop=false 
- 
-[Aktionen] 
-DefVar $ProductId$ 
-Set $ProductId$ = "cupsprinter" 
-DefStringlist $list1$ 
-DefStringlist $list2$ 
-DefStringlist $list3$ 
-DefStringlist $CupsPrinterNames$ 
- 
-DefVar $tmpDir$ 
-DefVar $tmpPrinters$ 
-DefVar $DriverOnly$ 
-DefVar $UsePrinterPPD$ 
-DefVar $PrintServerName$ 
-DefVar $PrintProtocol$ 
-DefVar $DefaultPrinterName$ 
-DefVar $DomainName$ 
-DefVar $WindowsPrinterName$ 
-DefVar $DriverPath$ 
-DefVar $TmpDriverPath$ 
-DefVar $InfFile$ 
-DefVar $ServerAddress$ 
-DefVar $PrinterAddress$ 
-DefVar $PrinterNameInInfFile$ 
- 
-set $tmpDir$ = "%systemdrive%\tmp\cupsprinter" 
-set $DriverOnly$ = "false" 
-set $UsePrinterPPD$ = "true" 
-set $PrintServerName$ = "server" 
-set $PrintProtocol$ = "smb" 
-set $DefaultPrinterName$ = "" 
- 
-if ( GetOS = "Windows_NT") 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   show product picture                    - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ShowBitmap /3 "%scriptpath%\"+$ProductId$+".bmp" $ProductId$ 
-  
- set $PrintServerName$ = IniVar('printserver') 
- set $DriverOnly$ = IniVar('driver_only') 
- set $UsePrinterPPD$ = IniVar('use_printer_ppd') 
- set $PrintProtocol$ = IniVar('print_protocol') 
- comment "=== Product properties =================================" 
- comment " $PrintServerName$ = " + $PrintServerName$ 
- comment " $DriverOnly$      = " + $DriverOnly$ 
- comment " $UsePrinterPPD$   = " + $UsePrinterPPD$ 
- comment " $PrintProtocol$   = " + $PrintProtocol$ 
- comment "========================================================" 
-  
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   uninstall first                         - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- if not ($DriverOnly$ = "true") 
- comment "Deleting printers" 
- Message=Deinstalliere CUPS-Drucker ... 
- set $list1$ = getOutStreamFromSection ('DosInAnIcon_list_installed_server_printers') 
- for $a$ in $list1$ do sub_delete_installed_server_printers 
- endif 
-  
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   start install                           - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- Message=Installiere CUPS-Drucker ... 
-  
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   get domainname                          - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- comment "Getting domain name from service" 
- Set $list1$ = getReturnListFromSection('opsiservicecall_getDomain') 
- Set $DomainName$ = takestring(0, $list1$) 
-  
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   common printer settings                 - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
-  
- ; Address of the cups server 
- set $ServerAddress$ = $PrintServerName$ + "." + $DomainName$ 
- ; Name of to printer model exactly as it is in the inf-file below 
- set $PrinterNameInInfFile$ ="CUPS Test Driver v6" 
- ; full path to the printer driver 
- set $DriverPath$ = "%ScriptPath%\cups-windows" 
- ; full path to the inf-file to use 
- set $InfFile$ = $DriverPath$+"\cups6.inf" 
-  
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- ; -   install all available printers          - 
- ; - - - - - - - - - - - - - - - - - - - - - - - 
- comment "Getting available samba printers from server " + $PrintServerName$ 
- set $list1$ = getOutStreamFromSection ('DosInAnIcon_list_available_cups_printers') 
- for $a$ in $list1$ do sub_get_cups_printer_names 
-  
- ; for $a$ in $CupsPrinterNames$ do sub_get_default_printer 
- for $a$ in $CupsPrinterNames$ do sub_install_cups_printers 
-  
- if not ($DefaultPrinterName$ = "") 
- sub_set_default_printer 
- endif 
- 
-endif 
- 
-[opsiservicecall_getDomain] 
-"method": "getDomain" 
-"params": [ 
-          ] 
- 
-[Winbatch_autohotkey_driver_signing] 
-%ScriptPath%\autohotkey.exe %ScriptPath%\driver_signing.ahk 
- 
-[Winbatch_sleep] 
-%ScriptPath%\sleep.exe 2 
- 
-[DosInAnIcon_list_available_cups_printers] 
-@echo off 
-net view \\$PrintServerName$ | findstr Drucker 
- 
- 
-[sub_get_cups_printer_names] 
-set $list2$ = splitStringOnWhitespace ("$a$") 
-if takestring(1, $list2$) = "Drucker" 
- if not ($tmpPrinters$ = "") 
- Set $tmpPrinters$ = $tmpPrinters$ + "|" 
- endif 
- comment "Found printer: " + takestring(0, $list2$) 
- Set $tmpPrinters$ = $tmpPrinters$ + takestring(0, $list2$) 
-endif 
-Set $CupsPrinterNames$ = splitString($tmpPrinters$, "|") 
- 
-[sub_install_cups_printers] 
-set $WindowsPrinterName$ = "$a$" 
-comment "Installing printer: " + $WindowsPrinterName$ 
-if ($PrintProtocol$ = "ipp") 
- set $PrinterAddress$ = "http://"+$ServerAddress$+":631/printers/"+$WindowsPrinterName$ 
-else 
- set $PrinterAddress$ = "\\" + $PrintServerName$ + "\"+ $WindowsPrinterName$ 
-endif 
-if ($UsePrinterPPD$ = "true") 
- comment "Using PPD from CUPS for printer: " + $WindowsPrinterName$ 
- comment "Deleting temp driver directory" 
- Files_delete_tmp_driver 
- comment "Copying driver to temp driver directory" 
- Files_copy_tmp_driver 
- set $TmpDriverPath$ = $DriverPath$ 
- set $DriverPath$ = $tmpDir$ 
- set $InfFile$ = $DriverPath$+"\cups6.inf" 
- comment "Downloading PPD for printer: " + $WindowsPrinterName$ 
- DosInAnIcon_download_ppd 
- comment "Patching inf to use new PPD" 
- PatchTextFile_cups_driver_inf $InfFile$ 
- set $PrinterNameInInfFile$ = "CUPS Driver - " + $WindowsPrinterName$ 
-endif 
-Winbatch_autohotkey_driver_signing /LetThemGo 
-Winbatch_sleep 
-if ($DriverOnly$ = "true") 
- comment "Installing printer driver" 
- DosInAnIcon_install_printer_driver 
-else 
- comment "Installing printer" 
- DosInAnIcon_install_printer 
-endif 
-killtask "autohotkey.exe" 
-if ($UsePrinterPPD$ = "true") 
- comment "Deleting temp driver directory" 
- Files_delete_tmp_driver 
- set $DriverPath$ = $TmpDriverPath$ 
- set $InfFile$ = $DriverPath$+"\cups6.inf" 
-endif 
- 
-[Files_copy_tmp_driver] 
-Copy -s "$DriverPath$\*" "$tmpDir$\" 
- 
-[Files_delete_tmp_driver] 
-Delete -sf "$tmpDir$" 
- 
-[DosInAnIcon_download_ppd] 
-"%ScriptPath%\wget\wget.exe" "http://$ServerAddress$:631/printers/$WindowsPrinterName$.ppd" -O "$DriverPath$\\$WindowsPrinterName$.ppd" 
- 
-[PatchTextFile_cups_driver_inf] 
-GoToTop 
-FindLine_StartingWith '"CUPS Test Driver v6" = CUPS6.PS' 
-DeleteTheLine 
-InsertLine '"CUPS Driver - $WindowsPrinterName$" = CUPS6.PS' 
-GoToTop 
-FindLine_StartingWith 'CopyFiles=@CUPS6.PPD' 
-DeleteTheLine 
-InsertLine 'CopyFiles=@$WindowsPrinterName$.ppd' 
-GoToTop 
-FindLine_StartingWith 'DataFile=' 
-DeleteTheLine 
-InsertLine 'DataFile=$WindowsPrinterName$.ppd' 
- 
-[sub_get_default_printer] 
-set $WindowsPrinterName$ = "$a$" 
- 
-if ($WindowsPrinterName$ = "oben") or (takestring(1, splitString($WindowsPrinterName$, "_")) = "oben") 
- set $DefaultPrinterName$ = $WindowsPrinterName$ 
-endif 
- 
-[DosInAnIcon_install_printer] 
-rundll32 printui.dll,PrintUIEntry /q /if /x /n "" /b "$WindowsPrinterName$" /m "$PrinterNameInInfFile$" /r "$PrinterAddress$" /f "$InfFile$" /l "$DriverPath$" 
- 
-[DosInAnIcon_install_printer_driver] 
-rundll32 printui.dll,PrintUIEntry /q /ia /x /n "" /b "$WindowsPrinterName$" /m "$PrinterNameInInfFile$" /r "$PrinterAddress$" /f "$InfFile$" /l "$DriverPath$" 
- 
-[sub_delete_installed_server_printers] 
-set $list2$ = splitStringOnWhitespace ("$a$") 
-if takestring(0, $list2$) = "Druckername" 
- set $list3$ = splitString("$a$", "Druckername ") 
- set $WindowsPrinterName$ = takestring(1, $list3$) 
-endif 
-if takestring(0, $list2$) = "Anschlussname" 
- set $list3$ = splitString (takestring(1, $list2$), "/") 
- ; CUPS printer 
- if takestring(0, $list3$) = "http:" 
- DosInAnIcon_delete_printer 
- endif 
- set $list3$ = splitString (takestring(1, $list2$), "\") 
- ; Samba printer on server (\\server\xyz) 
- if takestring(2, $list3$) = $PrintServerName$ 
- DosInAnIcon_delete_printer 
- endif 
-endif 
- 
-[DosInAnIcon_list_installed_server_printers] 
-@echo off 
-cscript "%ScriptPath%\prnmngr.vbs" -l 
- 
-[DosInAnIcon_delete_printer] 
-rundll32 printui.dll,PrintUIEntry /q /dl /n "$WindowsPrinterName$" 
- 
-[sub_set_default_printer] 
-Files_copy_autostart_files 
-DosInAnIcon_write_autostart_cmd 
- 
-[Files_copy_autostart_files] 
-copy %SCRIPTPATH%\cups.lnk "C:\Dokumente und Einstellungen\username\Startmenü\Programme\Autostart" 
- 
-[DosInAnIcon_write_autostart_cmd] 
-echo del "C:\Dokumente und Einstellungen\username\Startm~1\Programme\Autostart\cups.lnk" > c:\windows\temp\cups.cmd 
-echo rundll32 printui.dll,PrintUIEntry /y /n "$DefaultPrinterName$" >> c:\windows\temp\cups.cmd 
- 
- 
- 
-</code> 
-==== delcupsprinter.ins ==== 
- 
-<code winst> 
-[Initial] 
-; NOTE: 
-;   If a new cups printer is added, it will take some time 
-;   before the printer is published by samba (default 750s) 
-;   use smb.conf paramter "printcap cache time" to change printer reload interval 
-; 
- 
-; Message at install time: 
-Message=Deinstalliere CUPS-Drucker ... 
-LogLevel=2 
-;  Log Errors in Logfile but don't abort: 
-ExitOnError=false 
-; Show syntax errors in the script: 
-ScriptErrorMessages=on 
-; Dont trace step by step through the script: 
-TraceMode=off 
-; let started programs run in front of the winst window 
-StayOnTop=false 
- 
-[Aktionen] 
-DefVar $ProductId$ 
-Set $ProductId$ = "cupsprinter" 
-DefStringlist $list1$ 
-DefStringlist $list2$ 
-DefStringlist $list3$ 
- 
-DefVar $WindowsPrinterName$ 
-DefVar $PrintServerName$ 
- 
-set $PrintServerName$ = "server" 
- 
-if ( GetOS = "Windows_NT") 
-   ; - - - - - - - - - - - - - - - - - - - - - - - 
-   ; -   show product picture                    - 
-   ; - - - - - - - - - - - - - - - - - - - - - - - 
-   ShowBitmap /3 "%scriptpath%\"+$ProductId$+".bmp" $ProductId$ 
-    
-   set $PrintServerName$ = IniVar('printserver') 
-    
-   ; - - - - - - - - - - - - - - - - - - - - - - - 
-   ; -   uninstall                               - 
-   ; - - - - - - - - - - - - - - - - - - - - - - - 
-   Message=Deinstalliere CUPS-Drucker ... 
-   set $list1$ = getOutStreamFromSection ('DosInAnIcon_list_installed_server_printers') 
-   for $a$ in $list1$ do sub_delete_installed_server_printers 
- 
-endif 
- 
-[sub_delete_installed_server_printers] 
-set $list2$ = splitStringOnWhitespace ("$a$") 
-if takestring(0, $list2$) = "Druckername" 
-   set $list3$ = splitString("$a$", "Druckername ") 
-   set $WindowsPrinterName$ = takestring(1, $list3$) 
-endif 
-if takestring(0, $list2$) = "Anschlussname" 
-   set $list3$ = splitString (takestring(1, $list2$), "/") 
-   ; CUPS printer 
-   if takestring(0, $list3$) = "http:" 
-      DosInAnIcon_delete_printer 
-   endif 
-   set $list3$ = splitString (takestring(1, $list2$), "\") 
-   ; Samba printer on server (\\server\xyz) 
-   if takestring(2, $list3$) = $PrintServerName$ 
-      DosInAnIcon_delete_printer 
-   endif 
-endif 
- 
-[DosInAnIcon_list_installed_server_printers] 
-@echo off 
-cscript c:\windows\system32\prnmngr.vbs -l 
- 
-[DosInAnIcon_delete_printer] 
-rundll32 printui.dll,PrintUIEntry /q /dl /n "$WindowsPrinterName$" 
- 
- 
- 
-</code> 
userspace/cups_printer_installation.txt · Last modified: 2021/08/23 08:37 (external edit)