Commit f15e7db0 authored by Martin Klimes (k11m1)'s avatar Martin Klimes (k11m1)
Browse files

cleanup

parent 4d5dde87
...@@ -4,7 +4,6 @@ use 5.24.0; ...@@ -4,7 +4,6 @@ use 5.24.0;
use strict; use strict;
use warnings; use warnings;
use Carp qw/croak/; use Carp qw/croak/;
use Data::Dumper qw(Dumper);
use Cwd qw(cwd); use Cwd qw(cwd);
use File::Path; use File::Path;
use File::Copy; use File::Copy;
...@@ -23,7 +22,7 @@ my $printers = { ...@@ -23,7 +22,7 @@ my $printers = {
'location' => 'Building A, 3th floor kitchen', 'location' => 'Building A, 3th floor kitchen',
}, },
'lj5c' => { 'lj5c' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building C, 5th floor, next to copy', 'location' => 'Building C, 5th floor, next to copy',
}, },
'copy5b' => { 'copy5b' => {
...@@ -31,15 +30,15 @@ my $printers = { ...@@ -31,15 +30,15 @@ my $printers = {
'location' => 'Building B, 5th floor', 'location' => 'Building B, 5th floor',
}, },
'lj4c' => { 'lj4c' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building C, 4th floor, next to copy', 'location' => 'Building C, 4th floor, next to copy',
}, },
'lj4p' => { 'lj4p' => {
'model' => 'hplj-p4015x', 'model' => 'hpljp4015x',
'location' => 'Building B, 4th floor, next to copy', 'location' => 'Building B, 4th floor, next to copy',
}, },
'lj4a' => { 'lj4a' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building A, 4th floor kitchen', 'location' => 'Building A, 4th floor kitchen',
}, },
'copy4a' => { 'copy4a' => {
...@@ -51,11 +50,11 @@ my $printers = { ...@@ -51,11 +50,11 @@ my $printers = {
'location' => 'Building A, 2nd floor kitchen', 'location' => 'Building A, 2nd floor kitchen',
}, },
'lj3a' => { 'lj3a' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building A, 3th floor kitchen', 'location' => 'Building A, 3th floor kitchen',
}, },
'lj2a' => { 'lj2a' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building A, 2nd floor kitchen', 'location' => 'Building A, 2nd floor kitchen',
}, },
'copy5c' => { 'copy5c' => {
...@@ -63,11 +62,11 @@ my $printers = { ...@@ -63,11 +62,11 @@ my $printers = {
'location' => 'Building C, 5th floor', 'location' => 'Building C, 5th floor',
}, },
'lj3b' => { 'lj3b' => {
'model' => 'hplj-p4515x', 'model' => 'hpljp4515x',
'location' => 'Building B, 3th floor, kitchen', 'location' => 'Building B, 3th floor, kitchen',
}, },
'lj-a302' => { 'lj-a302' => {
'model' => 'hplj-600', 'model' => 'hplj600',
'location' => 'Building A, 3th floor A302 LaSArIS', 'location' => 'Building A, 3th floor A302 LaSArIS',
}, },
'copy4c' => { 'copy4c' => {
...@@ -75,21 +74,21 @@ my $printers = { ...@@ -75,21 +74,21 @@ my $printers = {
'location' => 'Building C, 4th floor', 'location' => 'Building C, 4th floor',
}, },
'lj2b' => { 'lj2b' => {
'model' => 'hplj-p3015', 'model' => 'hpljp3015',
'location' => 'Building B, 2nd floor, kitchen', 'location' => 'Building B, 2nd floor, kitchen',
} }
}; };
my $models = { my $models = {
'TA5007ci' => { 'TA5007ci' => {
'filters' => [ 'kyofilter_pre_E', 'kyofilter_E' ], 'filters' => [ 'kyofilter_pre_E', 'kyofilter_E', ],
}, },
'TA4505ci' => { 'TA4505ci' => {
'filters' => ['kyofilter_B'], 'filters' => [ 'kyofilter_B ', ],
'options' => [ 'Option19=One', 'Option21=True', 'Option17=DF730' ], 'options' => [ 'Option19=One', 'Option21=True', 'Option17=DF730', ],
}, },
'hplj-600' => { 'hplj600' => {
'options' => ['HPOption_Duplexer=True'], 'options' => [ 'HPOption_Duplexer=True', ],
} }
}; };
...@@ -112,9 +111,9 @@ sub prompt_password { ...@@ -112,9 +111,9 @@ sub prompt_password {
print "[PROMPT] Enter password: "; print "[PROMPT] Enter password: ";
system("stty -echo"); system("stty -echo");
chomp( my $password1 = <STDIN> ); chomp( my $password1 = <STDIN> );
system('stty echo'); system("stty echo");
print "\n[PROMPT] Repeat password: "; print "\n[PROMPT] Repeat password: ";
system('stty -echo'); system("stty -echo");
chomp( my $password2 = <STDIN> ); chomp( my $password2 = <STDIN> );
system("stty echo"); system("stty echo");
print "\n"; print "\n";
...@@ -160,7 +159,7 @@ sub install_printer { ...@@ -160,7 +159,7 @@ sub install_printer {
} }
sub copy_filter { sub copy_filter {
( my $filter ) = @_; my ($filter) = @_;
my $destination = "/usr/lib/cups/filter/"; my $destination = "/usr/lib/cups/filter/";
...@@ -173,7 +172,7 @@ sub copy_filter { ...@@ -173,7 +172,7 @@ sub copy_filter {
or die "[ERROR] Failed to copy $filter: $!\n"; or die "[ERROR] Failed to copy $filter: $!\n";
say "[OK] Copied $filter."; say "[OK] Copied $filter.";
chmod( 0755, $destination . $filter ); chmod 0755, $destination . $filter;
return; return;
} }
...@@ -190,8 +189,8 @@ sub print_printers() { ...@@ -190,8 +189,8 @@ sub print_printers() {
} }
sub usage() { sub usage() {
say "Script for installing FI printers on linux."; say "Script for installing fi printers on Linux via Samba print server.";
say "Requires local CUPS server running and SAMBA client installed."; say "Requires local CUPS server running and Samba client installed.";
say "usage: $0 <printer-name>"; say "usage: $0 <printer-name>";
say "Must be run as root."; say "Must be run as root.";
say "Triumph-Adler 50007ci needs Python 2.7 as a dependency"; say "Triumph-Adler 50007ci needs Python 2.7 as a dependency";
...@@ -223,7 +222,7 @@ sub check_python { ...@@ -223,7 +222,7 @@ sub check_python {
} }
sub python_package { sub python_package {
( my $package_name, my $python ) = @_; my ( $package_name, $python ) = @_;
say "[INFO] Installing $package_name..."; say "[INFO] Installing $package_name...";
my $status = chdir "$package_name"; my $status = chdir "$package_name";
...@@ -263,14 +262,14 @@ if ( @ARGV != 1 ) { ...@@ -263,14 +262,14 @@ if ( @ARGV != 1 ) {
my ($printer_name) = @ARGV; my ($printer_name) = @ARGV;
# Check for smbclient # Check for smbclient
my $output = `which smbclient >/dev/null 2>/dev/null`; my $output = `which smbclient &>/dev/null`;
if ( $? != 0 ) { if ( $? != 0 ) {
die "[ERROR] Samba client seems not to be installed. (smbclinet)"; die "[ERROR] Samba client seems not to be installed. (smbclinet)";
} }
if ( not( exists( $printers->{$printer_name} ) ) ) { if ( not( exists( $printers->{$printer_name} ) ) ) {
say "[ERROR] Printer $printer_name is not supported."; say "[ERROR] Printer $printer_name is not supported.";
print_printers(); print_printers;
exit 1; exit 1;
} }
...@@ -282,14 +281,13 @@ say "[INFO] Selected model is $model"; ...@@ -282,14 +281,13 @@ say "[INFO] Selected model is $model";
#TA5007ci requires python2 reportlab and PyPDF2 #TA5007ci requires python2 reportlab and PyPDF2
if ( $model eq "TA5007ci" ) { if ( $model eq "TA5007ci" ) {
pre_TA5007ci(); pre_TA5007ci;
} }
for my $filter ( @{ ( $models->{$model} // {} )->{filters} // [] } ) { for my $filter ( @{ ( $models->{$model} // {} )->{filters} // [] } ) {
copy_filter $filter;
copy_filter($filter);
} }
install_printer("$printer_name"); install_printer "$printer_name";
say "[INFO] Installation is completed."; say "[INFO] Installation is completed.";
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment