From 4763a4568fb29d54077e4b2864f69817da5becc9 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 7 Jul 2020 20:16:19 +0200 Subject: Testing that dir listing --- update-gitjoe.pl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/update-gitjoe.pl b/update-gitjoe.pl index a4eccdd..79dc28c 100755 --- a/update-gitjoe.pl +++ b/update-gitjoe.pl @@ -4,6 +4,26 @@ 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; @@ -18,7 +38,7 @@ sub main { closedir(DIR); $i = 0; while ($i < @users) { - print $users[$i] . "\n"; + my @repos = get_repos_index($users[$i]); $i += 1; } exit; -- cgit v1.2.3