aboutsummaryrefslogtreecommitdiffstats
path: root/update-gitjoe.pl
blob: 92b7622ff69a032b82e0747d9ff7bcbedfc365a9 (plain)
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
#!/usr/local/bin/perl

use strict;
use warnings;
use Term::ANSIColor;

sub get_repos_index {
	my $user = $_[0];
	my $homedir = '/usr/home/' . $user . '/';
	opendir(DIR, $homedir);
	my @repos;
	my $i = 0;
	while (my $dir = readdir(DIR)) {
		next if ($dir =~ m/^\./);
		next if (!(-e $homedir . $dir . '/git-daemon-export-ok'));
		$repos[$i] = $dir;
		$i += 1;
	}
	$i = 0;
	print 'User - ' . colored($user, 'bold') . " - repositories: \n";
	while ($i < @repos) {
		print $repos[$i] . "\n";
		$i += 1;
	}
	closedir(DIR);
	print "\n";
	return @repos;
}

sub stagit_generate {
	my $user = $_[0];
	my @repos = @_[1];
	my $i = 0;
	while ($i < @repos) {
		print colored($repos[$i], 'bold red') . "\n";
		$i += 1;
	}
	return;
}

sub main {
	my $homedir = '/usr/home/';
	my @users;
	opendir(DIR, $homedir);
	my $i = 0;
	while (my $dir = readdir(DIR)) {
		next if ($dir eq 'git-ro');
		next if ($dir =~ m/^\./);
		$users[$i] = $dir;
		$i += 1;
	}
	closedir(DIR);
	$i = 0;
	while ($i < @users) {
		my @repos = get_repos_index($users[$i]);
		stagit_generate($users[$i], @repos);
		$i += 1;
	}
	exit;
}

main();

__END__