Handle hostnames with upper-case letters
[webmin.git] / cluster-cron / cron.pl
1 #!/usr/local/bin/perl
2 # cron.pl
3 # Run a command on multiple servers at once
4
5 $no_acl_check++;
6 require './cluster-cron-lib.pl';
7
8 @jobs = &list_cluster_jobs();
9 ($job) = grep { $_->{'cluster_id'} eq $ARGV[0] } @jobs;
10 $job || die "Job ID $ARGV[0] does not exist!";
11 $ENV{'SERVER_ROOT'} = $root_directory;  # hack to make 'this server' work
12 &run_cluster_job($job, \&callback);
13
14 # callback(error, &server, message)
15 sub callback
16 {
17 local $d = $_[1]->{'desc'} || $_[1]->{'host'};
18 if (!$_[0]) {
19         # Failed - show error
20         print "Failed to run on $d : $_[2]\n\n";
21         }
22 else {
23         # Show output if any
24         if ($_[2]) {
25                 print "Output from $d ..\n";
26                 print $_[2];
27                 print "\n";
28                 }
29         }
30 }
31