File: misc

package info (click to toggle)
hobbit-plugins 20100527
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 196 kB
  • ctags: 32
  • sloc: perl: 1,080; makefile: 49; sh: 43
file content (32 lines) | stat: -rwxr-xr-x 733 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl -w

use strict;
use Sysadm::Install qw/tap/;
use Hobbit;
my $bb = new Hobbit ('misc');

my @tests = sort grep { /\/[a-zA-Z0-9_-]+$/ } glob "/etc/hobbit/misc.d/*";

foreach my $test (@tests) {
	next unless -x $test;
	my ($stdout, $stderr, $rc) = tap($test);
	$rc >>= 8;

	$test =~ /\/([a-zA-Z0-9_-]+)$/;
	my $name = $1;

	my $color = ($rc == 0 and not $stderr) ? 'green' :
		    (($rc == 1 and not $stderr) ? 'yellow' : 'red');

	$bb->color_line($color, $name . ($rc ? " returned $rc" : '') . (($stdout or $stderr) ? ':' : '') ."\n");
	if ($stdout) {
		$stdout =~ s/^/   /mg;
		$bb->print ($stdout);
	}
	if ($stderr) {
		$stderr =~ s/^/   /mg;
		$bb->print ($stderr);
	}
}

$bb->send unless ($bb->{color} eq 'clear');