--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use File::Basename;
+# use File::Find::Rule;
+# use Data::Dumper;
+use Getopt::Long;
+use Cwd;
+use POSIX qw (strftime);
+my $basepath = "/Volumes/Macintosh2 HD/backup/1-Neuer Server";
+my $logfile = "/Volumes/Macintosh2 HD/log/githelper.".strftime("%Y%m%d",localtime()).".log";
+open(LOG,">>".$logfile);
+# my @wksp = ($ENV{HOME}.'/Workspace',$ENV{HOME}.'/Workspace/Websites',$ENV{HOME}.'/Workspace/Apps');
+# if ($^O eq "MSWin32"){
+# @wksp = ($ENV{USERPROFILE}.'/Workspace',$ENV{USERPROFILE}.'/Workspace/Websites',$ENV{HOME}.'/Workspace/Apps');
+# $wksp[0] =~ s/\\/\//g;
+# $wksp[1] =~ s/\\/\//g;
+# $wksp[2] =~ s/\\/\//g;
+# }
+my $get = 0;
+my $set = 0;
+my $check = 0;
+GetOptions("get" => \$get,"set" => \$set, "check" => \$check);
+#print $wksp."\n";
+#print ."\n";
+my $git='/usr/local/bin/git';
+if ($check == 1){
+ my @testgit = `find "$basepath" -type d -depth 2`;
+ foreach my $t (@testgit){
+ chomp($t);
+ if (($t =~ /^$basepath\/.=/) && (! -d $t.'/.git')){
+ if (basename($t) =~ /^\w+\d\d\d\d\w+/ ){
+ chdir($t) or die "cannot change dir to '$t'!";
+ print LOG "automated git init: '$t'\n";
+ my $ret = `$git init`;
+ print LOG $ret."\n";
+ }else {
+ print LOG "Needs MANUAL git init: '$t'\n";
+ }
+ }
+
+ }
+}
+
+if ($get == 1){
+ my @rep = `find "$basepath" -type d -depth 3 -name ".git"`;
+ foreach my $r (@rep){
+ chomp($r);
+ $r = dirname($r);
+ if (! -d $r.'/.git'){
+ print LOG "$r: Nothing to do! Not a GIT-Repository!\n";
+ next();
+ }
+ print LOG "repo:sitory ".$r."!\n";
+ chdir($r) or die "cannot change dir to '$r'!";
+ #print "CWD:".getcwd()."\n";
+ my $ret = `$git status`;
+ #my $ret = `git pull`;
+ print LOG $ret."\n---\n";
+ }
+}
+if ($set == 1){
+my @rep = `find "$basepath" -type d -depth 3 -name ".git"`;
+foreach my $r (@rep){
+ chomp($r);
+ $r = dirname($r);
+ if (! -d $r.'/.git'){
+ print LOG "$r: Nothing to do! Not a GIT-Repository!\n";
+ next();
+ }
+ chdir($r) or die "cannot change dir to '$r'!";
+ my $ret = `$git status`;
+ if ($ret =~ /nothing to commit, working tree clean/){
+ print LOG "repository ".basename($r)." OK!\n";
+ next;
+ } elsif (($ret =~ /Changes not staged for commit/) || ($ret =~ /Untracked files/)){
+ print LOG "repository ".basename($r)." changes to add,commit and push!\n";
+ my $add = `$git add -A`;
+ print LOG "Data Added:".$add."\n";
+ my $msg = "Version ".strftime("%Y-%m-%d %H:%M",localtime());
+ my $commit = `$git commit -m "$msg"`;
+ print LOG "Data Commited:".$commit."\n";
+ #my $push = `$git push`;
+ #if ($push =~ /\!\s\[rejected\]/){
+ # my $pull = `git pull`;
+ # print "Data pulled:".$pull."\n";
+ # $push = `git push`;
+ # print "Data pushed:".$push."\n";
+ #}
+ $ret = `$git status`;
+ print LOG $ret."\n---\n";
+ }
+}
+}
+close(LOG);
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use POSIX;
+use File::Basename;
+use utf8;
+use lib (dirname($0));
+#use URL::Encode qw(url_encode);
+use CGI::Util qw(escape);
+
+my $config = { basesource => "/Volumes/Macintosh2 HD/Backup/1-Neuer Server", defaultlevel => 2, exclude => ['Z-outils'] };
+my $todaydate = POSIX::strftime('%Y-%m-%d',localtime);
+chdir $config->{basesource};
+#print getcwd()."\n";
+my $deflevel = $config->{defaultlevel};
+my $strdirs = `find . -type d -depth $deflevel | grep -v ".git"`;
+my @dirs = split("\n",$strdirs);
+foreach my $d (@dirs){
+ chdir($config->{basesource});
+ $d = substr($d,2);
+ chdir($d);
+ #print getcwd()."\n";
+ if (($d =~ /^\./) || ($d =~ /\/\./)){
+ next;
+ }
+ if ($d =~ /^Z-outils/){
+ #print "$d excluded!\n";
+ next;
+ }
+
+ my @x = grep(/$d/,@{$config->{exclude}});
+ if (scalar(@x) > 0){
+ # print "$d EXCLUDED!\n";
+ next;
+ }
+ if (! -d '.git'){
+ # print "init git\n";
+ system ('git init');
+ system ('echo "'.basename($d).'" > .git/description' );
+ system ('git config --global core.autocrlf false');
+
+ }
+ my $gitfiles = `git ls-files`;
+ my @files = split("\n",$gitfiles);
+ foreach my $f (@files){
+ if (! -e $f){
+ system ('git rm "'.$f.'"');
+ }
+ }
+ #print "git add files\n";
+ system('git add .');
+ #print "git commit files\n";
+ system('git commit -a -m "'.$todaydate.'"');
+}
+# chdir dirname($0);
+# my $project_list_cmd = 'find "'.$config->{basesource}.'" -type d -name ".git"';
+# my $prlists = `$project_list_cmd`;
+# my @pr = split("\n",$prlists);
+
+# open (GWP,">".dirname($0).'/web/gitweb_projects.conf') or die "Cannot write file!\n";
+# my $basedir = $config->{basesource}.'/';
+# foreach my $p (@pr){
+# if ($p ne ""){
+# my $x = substr($p,length($basedir));
+## print $x."\n";
+# print GWP escape($x).' '.$ENV{USER}."\n";
+# }
+# }
+
+# close(GWP);