aboutsummaryrefslogtreecommitdiffstats
path: root/src/update-gitjoe.pl
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-07-07 20:49:26 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-07-07 20:49:26 +0200
commitc546fee3fa3f3f1430bd289c51fc6a9e1a1030bf (patch)
tree5cf3e5c2396ef327383fba372cedfccf7bb5d98f /src/update-gitjoe.pl
parenttest (diff)
downloadjoe-scripts-c546fee3fa3f3f1430bd289c51fc6a9e1a1030bf.tar.gz
joe-scripts-c546fee3fa3f3f1430bd289c51fc6a9e1a1030bf.tar.bz2
joe-scripts-c546fee3fa3f3f1430bd289c51fc6a9e1a1030bf.tar.xz
joe-scripts-c546fee3fa3f3f1430bd289c51fc6a9e1a1030bf.tar.zst
joe-scripts-c546fee3fa3f3f1430bd289c51fc6a9e1a1030bf.zip
Better dir
Diffstat (limited to 'src/update-gitjoe.pl')
-rwxr-xr-xsrc/update-gitjoe.pl64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/update-gitjoe.pl b/src/update-gitjoe.pl
new file mode 100755
index 0000000..a0471ee
--- /dev/null
+++ b/src/update-gitjoe.pl
@@ -0,0 +1,64 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use Term::ANSIColor;
+
+sub get_repos_index {
+ my $user = $_[0];
+ my $home_dir = '/usr/home/' . $user . '/';
+ opendir(DIR, $home_dir);
+ my @repos;
+ my $i = 0;
+ while (my $dir = readdir(DIR)) {
+ next if ($dir =~ m/^\./);
+ next if (!(-e $home_dir . $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, @repos) = @_;
+ my $i = 0;
+ my $site_dir = '/usr/local/www/git-jozan/';
+ chdir($site_dir);
+ while ($i < @repos) {
+ $i += 1;
+ }
+ return;
+}
+
+sub main {
+ my $home_dir = '/usr/home/';
+ my @users;
+ opendir(DIR, $home_dir);
+ 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__