From 167fa1f924ade4504230ed4609c8857628f419cb Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 17 Jan 2016 01:20:24 +0000 Subject: [PATCH] nb-repos-dir --- bin/nb-repo-dirs | 50 +++++++++++++++++++++++++++++++++++++++++ etc/profile.d/functions | 9 -------- 2 files changed, 50 insertions(+), 9 deletions(-) create mode 100755 bin/nb-repo-dirs diff --git a/bin/nb-repo-dirs b/bin/nb-repo-dirs new file mode 100755 index 00000000..39002048 --- /dev/null +++ b/bin/nb-repo-dirs @@ -0,0 +1,50 @@ +#!/usr/bin/env perl +################################################################################# +# +# List Repositery directories - NB 17.01.16 +# +################################################################################# +use strict; +use File::Spec; +use Cwd; +use File::Basename; +my @DIRS = ( + dirname ( File::Spec->rel2abs( Cwd::abs_path(__FILE__) ) ), + '/opt/backup_servers', + '/{opt,home/www}/rent', + 'root:/etc/puppet', + 'root:/etc/zaza', + '/etc/puppet/data', + '/etc/puppet/modules', + '/home/www/izideal', + '/home/*/Dev/*/.nb-install', + '/{opt,home,home/www}/*/.nb-install', +); + +my $debug = 0; +($ARGV[0]||'') =~ /^--?(all|debug)$/ and $debug = 1; + +my %h; + +print + map {"$_\n"} + grep {$_ ne "" and !$h{$_}++} + map { + + my $user = (s/^(\w+:)// ? $1 : ""); + my $dir = /\.nb-install$/ ? dirname($_) : $_; + + if ($debug) { + $user.$dir; + + } elsif (-d $dir and -d "$dir/.git") { + $user.$dir; + + } else { + ""; + + } + + } + glob join(' ',@DIRS) +; diff --git a/etc/profile.d/functions b/etc/profile.d/functions index bf70c010..531bdf90 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -329,15 +329,6 @@ nb_repo_dirs() { /etc/puppet/modules \ /home/www/izideal \ 2>/dev/null - false && echo " - $NB_ROOT - /opt/backup_servers - /{opt,home/www}/rent - root:/etc/puppet - /etc/puppet/data - /etc/puppet/modules - /home/www/izideal - " | xargs ls -d 2> /dev/null (ls /{opt,home,home/www}/*/.nb-install | xargs -n1 dirname) 2>/dev/null ) | perl -ne '/^\s*$/ and next; s/^\s+//; print unless $h{$_}++' } -- 2.47.3