aboutsummaryrefslogtreecommitdiffstats
path: root/update-gitjoe.pl
blob: 79dc28c9f1eebdd5481489f3806ba6c70e1f299a (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
#!/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'));
		$i += 1;
	}
	$i = 0;
	while ($i < @repos) {
		print $repos[$i] . "\n";
		$i += 1;
	}
	closedir(DIR);
	return @repos;
}

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]);
		$i += 1;
	}
	exit;
}

main();

__END__