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

Add cron.pl for updating ppd

parent b18b1b4b
#!/usr/bin/perl -w
my $message = "Already up to date.";
my $output = `git pull --ff-only`;
if ($output eq "Already up to date.\n") {
print "Nothing to do";
exit;
}
print $output;
my @files = glob( '/etc/cups/ppd/*.ppd' );
my @new_files = ();
for my $item (@files) {
print "current $item\n";
$item =~ s/\/etc\/cups\/ppd\///;
$item =~ s/\.fi\.muni\.ppd//;
}
for my $printer (@files) {
system("./install.pl --update $printer")
}
......@@ -8,6 +8,21 @@ use Cwd qw(cwd);
use File::Path;
use File::Copy;
use File::Basename;
use Getopt::Long qw(:config bundling);
#my $opt = {
#};
#--------------------------------------------------------------------
# Option processing
#--------------------------------------------------------------------
my $only_update = '';
my $only_usage = '';
GetOptions(
'update' => \$only_update,
'help|h|?' => \$only_usage
) or die;
########
# DATA #
......@@ -162,6 +177,18 @@ sub install_printer {
return;
}
sub update_ppd {
my ($printer_name) = @_;
my $command = qq(lpadmin \\
-p "${printer_name}.fi.muni" \\
-P "ppds/${printer_name}.ppd" );
system($command);
return;
}
sub copy_filter {
my ($path) = @_;
......@@ -258,12 +285,9 @@ sub pre_TA5007ci {
# START OF THE SCRIPT #
#######################
if (@ARGV == 0 || $ARGV[0] eq "-h" || $ARGV[0] eq "--help") {
usage;
}
if (@ARGV != 1) {
usage;
# Show help
if ($only_usage || @ARGV != 1) {
usage();
}
my ($printer_name) = @ARGV;
......@@ -294,7 +318,11 @@ if ($model eq "TA5007ci") {
for my $filter (@{($models->{$model} // {})->{filters} // []}) {
copy_filter($filter);
}
install_printer "$printer_name";
say "[INFO] Installation is completed.";
if ($only_update) {
update_ppd("$printer_name");
say "[INFO] Update is completed.";
}
else {
install_printer("$printer_name");
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