-
Notifications
You must be signed in to change notification settings - Fork 2
/
dirvish-runall.pl
117 lines (97 loc) · 3.01 KB
/
dirvish-runall.pl
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# $Id: dirvish-runall.pl,v 12.0 2004/02/25 02:42:14 jw Exp $ $Name: Dirvish-1_2 $
$VERSION = ('$Name: Dirvish-1_2_1 $' =~ /Dirvish/i)
? ('$Name: Dirvish-1_2_1 $' =~ m/^.*:\s+dirvish-(.*)\s*\$$/i)[0]
: '1.1.2 patch' . ('$Id: dirvish-runall.pl,v 12.0 2004/02/25 02:42:14 jw Exp $'
=~ m/^.*,v(.*:\d\d)\s.*$/)[0];
$VERSION =~ s/_/./g;
#########################################################################
# #
# Copyright 2002 and $Date: 2004/02/25 02:42:14 $
# Pegasystems Technologies and J.W. Schultz #
# #
# Licensed under the Open Software License version 2.0 #
# #
# This program is free software; you can redistribute it #
# and/or modify it under the terms of the Open Software #
# License, version 2.0 by Lauwrence E. Rosen. #
# #
# This program is distributed in the hope that it will be #
# useful, but WITHOUT ANY WARRANTY; without even the implied #
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR #
# PURPOSE. See the Open Software License for details. #
# #
#########################################################################
use Time::ParseDate;
use POSIX qw(strftime);
use Getopt::Long;
sub loadconfig;
sub seppuku;
sub usage
{
my $message = shift(@_);
length($message) and print STDERR $message, "\n\n";
$! and exit(255); # because getopt seems to send us here for death
print STDERR <<EOUSAGE;
USAGE
dirvish-runall OPTIONS
OPTIONS
--config configfile
--no-run
--quiet
--version
EOUSAGE
exit 255;
}
$Options = {
version => sub {
print STDERR "dirvish version $VERSION\n";
exit(0);
},
help => \&usage,
};
GetOptions($Options, qw(
config=s
quiet no-run|dry-run
version help
)) or usage;
if ($$Options{config})
{
$Config = loadconfig(undef, $$Options{config})
}
elsif ($CONFDIR =~ /dirvish$/ && -f "$CONFDIR.conf")
{
$Config = loadconfig(undef, "$CONFDIR.conf");
}
elsif (-f "$CONFDIR/master.conf")
{
$Config = loadconfig(undef, "$CONFDIR/master.conf");
}
elsif (-f "$CONFDIR/dirvish.conf")
{
seppuku 250, <<EOERR;
ERROR: no master configuration file.
An old $CONFDIR/dirvish.conf file found.
Please read the dirvish release notes.
EOERR
}
else
{
seppuku 251, "ERROR: no global configuration file";
}
$$Config{Dirvish} ||= 'dirvish';
$$Options{'no-run'} and $$Options{quiet} = 0;
$errors = 0;
for $sched (@{$$Config{Runall}})
{
($vault, $itime) = split(/\s+/, $sched);
$cmd = "$$Config{Dirvish} --vault $vault";
$itime and $cmd .= qq[ --image-time "$itime"];
$$Options{quiet}
or printf "%s %s\n", strftime('%H:%M:%S', localtime), $cmd;
$$Options{'no-run'} and next;
$status = system($cmd);
$status < 0 || $status / 256 and ++$errors;
}
$$Options{quiet}
or printf "%s %s\n", strftime('%H:%M:%S', localtime), 'done';
exit ($errors < 200 ? $errors : 199);