This shows you the differences between two versions of the page.
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: | ||
- | advice: Ueber CUPS neu angelegte Drucker werden erst nach etwa 10 Minuten erfolgreich erkannt. | ||
- | full package: https:// | ||
- | |||
- | ==== cupsprinter.ins ==== | ||
- | |||
- | <code winst> | ||
- | [Initial] | ||
- | ; NOTE: | ||
- | ; If a new cups printer is added, it will take some time | ||
- | ; | ||
- | ; use smb.conf paramter " | ||
- | ; | ||
- | |||
- | ; 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$ = " | ||
- | 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$ = " | ||
- | set $DriverOnly$ = " | ||
- | set $UsePrinterPPD$ = " | ||
- | set $PrintServerName$ = " | ||
- | set $PrintProtocol$ = " | ||
- | set $DefaultPrinterName$ = "" | ||
- | |||
- | if ( GetOS = " | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - show product picture | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ShowBitmap /3 " | ||
- | |||
- | set $PrintServerName$ = IniVar(' | ||
- | set $DriverOnly$ = IniVar(' | ||
- | set $UsePrinterPPD$ = IniVar(' | ||
- | set $PrintProtocol$ = IniVar(' | ||
- | comment "=== Product properties =================================" | ||
- | comment " $PrintServerName$ = " + $PrintServerName$ | ||
- | comment " $DriverOnly$ | ||
- | comment " $UsePrinterPPD$ | ||
- | comment " $PrintProtocol$ | ||
- | comment " | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | if not ($DriverOnly$ = " | ||
- | comment " | ||
- | Message=Deinstalliere CUPS-Drucker ... | ||
- | set $list1$ = getOutStreamFromSection (' | ||
- | for $a$ in $list1$ do sub_delete_installed_server_printers | ||
- | endif | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - start install | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | Message=Installiere CUPS-Drucker ... | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - get domainname | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | comment " | ||
- | Set $list1$ = getReturnListFromSection(' | ||
- | Set $DomainName$ = takestring(0, | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | |||
- | ; Address of the cups server | ||
- | set $ServerAddress$ = $PrintServerName$ + " | ||
- | ; 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$ = " | ||
- | ; full path to the inf-file to use | ||
- | set $InfFile$ = $DriverPath$+" | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | comment " | ||
- | set $list1$ = getOutStreamFromSection (' | ||
- | 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] | ||
- | " | ||
- | " | ||
- | ] | ||
- | |||
- | [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 (" | ||
- | if takestring(1, | ||
- | if not ($tmpPrinters$ = "" | ||
- | Set $tmpPrinters$ = $tmpPrinters$ + " | ||
- | endif | ||
- | comment "Found printer: " + takestring(0, | ||
- | Set $tmpPrinters$ = $tmpPrinters$ + takestring(0, | ||
- | endif | ||
- | Set $CupsPrinterNames$ = splitString($tmpPrinters$, | ||
- | |||
- | [sub_install_cups_printers] | ||
- | set $WindowsPrinterName$ = " | ||
- | comment " | ||
- | if ($PrintProtocol$ = " | ||
- | set $PrinterAddress$ = " | ||
- | else | ||
- | set $PrinterAddress$ = " | ||
- | endif | ||
- | if ($UsePrinterPPD$ = " | ||
- | comment "Using PPD from CUPS for printer: " + $WindowsPrinterName$ | ||
- | comment " | ||
- | Files_delete_tmp_driver | ||
- | comment " | ||
- | Files_copy_tmp_driver | ||
- | set $TmpDriverPath$ = $DriverPath$ | ||
- | set $DriverPath$ = $tmpDir$ | ||
- | set $InfFile$ = $DriverPath$+" | ||
- | comment " | ||
- | DosInAnIcon_download_ppd | ||
- | comment " | ||
- | PatchTextFile_cups_driver_inf $InfFile$ | ||
- | set $PrinterNameInInfFile$ = "CUPS Driver - " + $WindowsPrinterName$ | ||
- | endif | ||
- | Winbatch_autohotkey_driver_signing /LetThemGo | ||
- | Winbatch_sleep | ||
- | if ($DriverOnly$ = " | ||
- | comment " | ||
- | DosInAnIcon_install_printer_driver | ||
- | else | ||
- | comment " | ||
- | DosInAnIcon_install_printer | ||
- | endif | ||
- | killtask " | ||
- | if ($UsePrinterPPD$ = " | ||
- | comment " | ||
- | Files_delete_tmp_driver | ||
- | set $DriverPath$ = $TmpDriverPath$ | ||
- | set $InfFile$ = $DriverPath$+" | ||
- | endif | ||
- | |||
- | [Files_copy_tmp_driver] | ||
- | Copy -s " | ||
- | |||
- | [Files_delete_tmp_driver] | ||
- | Delete -sf " | ||
- | |||
- | [DosInAnIcon_download_ppd] | ||
- | " | ||
- | |||
- | [PatchTextFile_cups_driver_inf] | ||
- | GoToTop | ||
- | FindLine_StartingWith '" | ||
- | DeleteTheLine | ||
- | InsertLine '" | ||
- | GoToTop | ||
- | FindLine_StartingWith ' | ||
- | DeleteTheLine | ||
- | InsertLine ' | ||
- | GoToTop | ||
- | FindLine_StartingWith ' | ||
- | DeleteTheLine | ||
- | InsertLine ' | ||
- | |||
- | [sub_get_default_printer] | ||
- | set $WindowsPrinterName$ = " | ||
- | |||
- | if ($WindowsPrinterName$ = " | ||
- | set $DefaultPrinterName$ = $WindowsPrinterName$ | ||
- | endif | ||
- | |||
- | [DosInAnIcon_install_printer] | ||
- | rundll32 printui.dll, | ||
- | |||
- | [DosInAnIcon_install_printer_driver] | ||
- | rundll32 printui.dll, | ||
- | |||
- | [sub_delete_installed_server_printers] | ||
- | set $list2$ = splitStringOnWhitespace (" | ||
- | if takestring(0, | ||
- | set $list3$ = splitString(" | ||
- | set $WindowsPrinterName$ = takestring(1, | ||
- | endif | ||
- | if takestring(0, | ||
- | set $list3$ = splitString (takestring(1, | ||
- | ; CUPS printer | ||
- | if takestring(0, | ||
- | DosInAnIcon_delete_printer | ||
- | endif | ||
- | set $list3$ = splitString (takestring(1, | ||
- | ; Samba printer on server (\\server\xyz) | ||
- | if takestring(2, | ||
- | DosInAnIcon_delete_printer | ||
- | endif | ||
- | endif | ||
- | |||
- | [DosInAnIcon_list_installed_server_printers] | ||
- | @echo off | ||
- | cscript " | ||
- | |||
- | [DosInAnIcon_delete_printer] | ||
- | rundll32 printui.dll, | ||
- | |||
- | [sub_set_default_printer] | ||
- | Files_copy_autostart_files | ||
- | DosInAnIcon_write_autostart_cmd | ||
- | |||
- | [Files_copy_autostart_files] | ||
- | copy %SCRIPTPATH%\cups.lnk " | ||
- | |||
- | [DosInAnIcon_write_autostart_cmd] | ||
- | echo del " | ||
- | echo rundll32 printui.dll, | ||
- | |||
- | |||
- | |||
- | </ | ||
- | ==== delcupsprinter.ins ==== | ||
- | |||
- | <code winst> | ||
- | [Initial] | ||
- | ; NOTE: | ||
- | ; If a new cups printer is added, it will take some time | ||
- | ; | ||
- | ; use smb.conf paramter " | ||
- | ; | ||
- | |||
- | ; 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$ = " | ||
- | DefStringlist $list1$ | ||
- | DefStringlist $list2$ | ||
- | DefStringlist $list3$ | ||
- | |||
- | DefVar $WindowsPrinterName$ | ||
- | DefVar $PrintServerName$ | ||
- | |||
- | set $PrintServerName$ = " | ||
- | |||
- | if ( GetOS = " | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - show product picture | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | | ||
- | |||
- | set $PrintServerName$ = IniVar(' | ||
- | |||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | ; - | ||
- | ; - - - - - - - - - - - - - - - - - - - - - - - | ||
- | | ||
- | set $list1$ = getOutStreamFromSection (' | ||
- | for $a$ in $list1$ do sub_delete_installed_server_printers | ||
- | |||
- | endif | ||
- | |||
- | [sub_delete_installed_server_printers] | ||
- | set $list2$ = splitStringOnWhitespace (" | ||
- | if takestring(0, | ||
- | set $list3$ = splitString(" | ||
- | set $WindowsPrinterName$ = takestring(1, | ||
- | endif | ||
- | if takestring(0, | ||
- | set $list3$ = splitString (takestring(1, | ||
- | ; CUPS printer | ||
- | if takestring(0, | ||
- | DosInAnIcon_delete_printer | ||
- | endif | ||
- | set $list3$ = splitString (takestring(1, | ||
- | ; Samba printer on server (\\server\xyz) | ||
- | if takestring(2, | ||
- | DosInAnIcon_delete_printer | ||
- | endif | ||
- | endif | ||
- | |||
- | [DosInAnIcon_list_installed_server_printers] | ||
- | @echo off | ||
- | cscript c: | ||
- | |||
- | [DosInAnIcon_delete_printer] | ||
- | rundll32 printui.dll, | ||
- | |||
- | |||
- | |||
- | </ |