This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
/
expireall
78 lines (61 loc) · 1.51 KB
/
expireall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl
#
# expireall - Expire all minivend catalogs
#
use Getopt::Std;
$VendRoot = $VendRoot || '/home/minivend/mvend';
## END CONFIGURABLE VARIABLES
BEGIN {
eval {
require 5.004;
require FindBin;
$VendRoot = $FindBin::RealBin;
$VendRoot =~ s/.bin$//;
};
($VendRoot = $ENV{MINIVEND_ROOT})
if defined $ENV{MINIVEND_ROOT};
}
my $query;
$USAGE = <<EOF;
Expire all listed MiniVend catalogs. Will read information from
either:
$VendRoot/minivend.cfg
$VendRoot/catalogs.list
usage: expireall [-r]
-r Use reorganize parameter in command
EOF
getopts('r') or die "$@\n$USAGE\n";
if ($opt_r) {
$flag = '-r';
}
# Parse the minivend.cfg file to look for script/catalog info
PARSECFG: {
my $file;
my @cfglines;
$file = "$VendRoot/minivend.cfg";
open(MVCFG, $file) or die "Couldn't read $file: $!\n";
while(<MVCFG>) { push(@cfglines, $_) if /^\s*catalog\s+/i }
close MVCFG;
eval {
$file = "$VendRoot/catalogs.list";
open(MVCFG, $file) or die "Couldn't read $file: $!\n";
while(<MVCFG>) { push(@cfglines, $_) if /^\s*catalog\s+/i }
close MVCFG;
};
eval {
$file = "$VendRoot/active.catalogs";
open(MVCFG, $file) or die "Couldn't read $file: $!\n";
while(<MVCFG>) { push(@cfglines, $_) if /^\s*catalog\s+/i }
close MVCFG;
rename $file, "$file.bak";
};
my %seen;
@cfglines = grep !$seen{$_}++, @cfglines;
for(@cfglines) {
next unless /^\s*catalog\s+([-\w_]+)/i;
push @cats, $1;
}
}
for(@cats) {
system "$VendRoot/bin/expire $flag -c $_";
}