From 1daf3d71a7003e905ef7cef4f85c3111ef613ee3 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 1 Apr 2015 20:12:42 -0700 Subject: [PATCH] recyclebin: /srv/git-recyclebin -> /srv/git/_recyclebin The recyclebin area is now under $Girocco::Config::reporoot instead of being a sibling directory. This facilitates storing all the Git repositories on a single volume mounted at $reporoot. To upgrade from the old layout, simply do this PRIOR to installation: sudo mv $cfg_reporoot-recyclebin $cfg_reporoot/_recyclebin If the installation has already been run creating a new and distinct $cfg_reporoot/_recyclebin, either it can be removed (if empty) and then the old directory renamed or each subdirectory of the old directory can be moved into the new location and then the old directory removed. --- Girocco/Config.pm | 2 +- cgi/delproj.cgi | 2 +- install.sh | 6 +++--- toolbox/inactive.sh | 6 +++--- toolbox/remove-inactive-projects.sh | 6 +++--- toolbox/reports/project-disk-use.sh | 27 ++++++++++++++------------- toolbox/trash-project.pl | 2 +- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 8b84baa..de33bae 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -298,7 +298,7 @@ our $basedir = '/home/repo/repomgr'; our $certsdir = '/home/repo/certs'; # The repository collection -# "$reporoot-recyclebin" will also be created for use by toolbox/trash-project.pl +# "$reporoot/_recyclebin" will also be created for use by toolbox/trash-project.pl our $reporoot = "/srv/git"; # The repository collection's location within the chroot jail diff --git a/cgi/delproj.cgi b/cgi/delproj.cgi index f8f8a5f..e7b0d71 100755 --- a/cgi/delproj.cgi +++ b/cgi/delproj.cgi @@ -131,7 +131,7 @@ EOT use POSIX qw(strftime); my $destdir = $proj->{base_path}; $destdir =~ s,(?<=[^/])/+$,,; - $destdir .= "-recyclebin/"; + $destdir .= "/_recyclebin/"; $destdir .= $1 if $proj->{name} =~ m,^(.*/)[^/]+$,; my $destbase = $proj->{name}; $destbase = $1 if $destbase =~ m,^.*/([^/]+)$,; diff --git a/install.sh b/install.sh index 5a79340..4bfe390 100755 --- a/install.sh +++ b/install.sh @@ -234,13 +234,13 @@ echo "*/30 * * * * /usr/bin/nice -n 18 $cfg_basedir/jobd/jobd.sh -q --all-once" echo "*** Setting up repository root..." -mkdir -p "$cfg_reporoot" "$cfg_reporoot-recyclebin" +mkdir -p "$cfg_reporoot" "$cfg_reporoot/_recyclebin" if [ "$cfg_owning_group" ]; then chgrp "$cfg_owning_group" "$cfg_reporoot" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot" - chgrp "$cfg_owning_group" "$cfg_reporoot-recyclebin" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot-recyclebin" + chgrp "$cfg_owning_group" "$cfg_reporoot/_recyclebin" || echo "WARNING: Cannot chgrp $cfg_owning_group $cfg_reporoot/_recyclebin" fi chmod 02775 "$cfg_reporoot" || echo "WARNING: Cannot chmod $cfg_reporoot properly" -chmod 02775 "$cfg_reporoot-recyclebin" || echo "WARNING: Cannot chmod $cfg_reporoot-recyclebin properly" +chmod 02775 "$cfg_reporoot/_recyclebin" || echo "WARNING: Cannot chmod $cfg_reporoot/_recyclebin properly" if [ -n "$cfg_chrooted" ]; then diff --git a/toolbox/inactive.sh b/toolbox/inactive.sh index 04e71f1..9a77bd3 100644 --- a/toolbox/inactive.sh +++ b/toolbox/inactive.sh @@ -8,12 +8,12 @@ exit 99 echo Checking for inactive projects (empty repositories) cd "$cfg_reporoot" -mkdir -p "$cfg_reporoot-recyclebin" +mkdir -p "$cfg_reporoot/_recyclebin" for i in $(find . -name heads -type d); do [ "$(ls $i)" ] && continue; fb="${i##*/}"; fb="${fb%.git}"; [ -d "$i/../../../$fb" ] && continue; [ -e "$i/../../packed-refs" ] && continue; echo "${i%/refs/heads} $(cat $i/../../owner)"; done >sack while read x y; do echo -e 'Hello,\n\nI have removed your project '"$x from $cfg_name since you have set it up quite some time ago and nothing has ever been pushed in (I run this job once in few months). If you want to publish anything on $cfg_name in the future, feel free to create the project again. If you experienced any technical difficulties with publishing on $cfg_name, please let me know, hopefully we can solve them together (sometimes I don't reply for some time, in that case it's best to harass me again, and repeatedly ;-). In case the automated check went wrong, the repository is still backed up..."'\n\nThanks for using '"$cfg_name"'!\n\n\t\t\tPetr Baudis ' | mail -s "[$cfg_name] Automated project removal" $y; done ghost("'$j'", 0)->_group_remove()'; done diff --git a/toolbox/remove-inactive-projects.sh b/toolbox/remove-inactive-projects.sh index 83d173c..273ee1b 100755 --- a/toolbox/remove-inactive-projects.sh +++ b/toolbox/remove-inactive-projects.sh @@ -83,15 +83,15 @@ echo " done." exit -#for i in $(find . -name heads -type d); do [ "$(ls $i)" ] && continue; mv ${i%/refs/heads} "$cfg_reporoot-recyclebin/"; done +#for i in $(find . -name heads -type d); do [ "$(ls $i)" ] && continue; mv ${i%/refs/heads} "$cfg_reporoot/_recyclebin/"; done echo -n "Moving repositories to recycle bin..." while read x y; do f="${x%/*}" x="${x##*/}" [ "$f" != "$x" ] || f="" echo "$f .. $x" - mkdir -p "$cfg_reporoot-recyclebin/$f" - mv "$cfg_reporoot/$f/$x" "$cfg_reporoot-recyclebin/$f" + mkdir -p "$cfg_reporoot/_recyclebin/$f" + mv "$cfg_reporoot/$f/$x" "$cfg_reporoot/_recyclebin/$f" done <$OUT echo " done." diff --git a/toolbox/reports/project-disk-use.sh b/toolbox/reports/project-disk-use.sh index 5b9391b..7bb37b6 100755 --- a/toolbox/reports/project-disk-use.sh +++ b/toolbox/reports/project-disk-use.sh @@ -63,7 +63,8 @@ is_listed_proj() { } inuse="$(get_use_k "$cfg_reporoot")" -binned="$(get_use_k "$cfg_reporoot-recyclebin")" +binned="$(get_use_k "$cfg_reporoot/_recyclebin")" +inuse="$(( $inuse - $binned ))" cd "$cfg_reporoot" total=0 @@ -100,7 +101,7 @@ while IFS='' read -r proj; do line="$usek $repokpct $mirror $proj$x$nl" results="$results$line" done </dev/null) +$(find . -type d \( -path ./_recyclebin -o -name '*.git' -print \) -prune 2>/dev/null) EOT kpct=$(( ( $ktotal * 100 + $inuse / 2 ) / $inuse )) @@ -112,21 +113,21 @@ domail=cat Project Disk Use Report ======================= - Start Time: $startdate - End Time: $enddate + Start Time: $startdate + End Time: $enddate - Repository Root: $cfg_reporoot - Disk Use: $(fmtcomma "$inuse") (1024-byte blocks) - reposizek Total: $(fmtcomma "$ktotal") ($kpct%) + Repository Root: $cfg_reporoot +Unbinned Disk Use: $(fmtcomma "$inuse") (1024-byte blocks) + reposizek Total: $(fmtcomma "$ktotal") ($kpct%) -Recycle Bin Root: $cfg_reporoot-recyclebin - Disk Use: $(fmtcomma "$binned") (1024-byte blocks) + Recycle Bin Root: $cfg_reporoot/_recyclebin + Binned Disk Use: $(fmtcomma "$binned") (1024-byte blocks) - Total Disk Use: $(fmtcomma "$(( $inuse + $binned ))") (1024-byte blocks) + Total Disk Use: $(fmtcomma "$(( $inuse + $binned ))") (1024-byte blocks) -Repository Count: $(fmtcomma "$howmany") - Orphaned: $(fmtcomma "$orphans") -Repository Total: $(fmtcomma "$total") (1024-byte blocks) + Repository Count: $(fmtcomma "$howmany") + Orphaned: $(fmtcomma "$orphans") + Repository Total: $(fmtcomma "$total") (1024-byte blocks) $(df -h "$cfg_reporoot") EOT diff --git a/toolbox/trash-project.pl b/toolbox/trash-project.pl index 8c55a75..ed5e407 100755 --- a/toolbox/trash-project.pl +++ b/toolbox/trash-project.pl @@ -18,7 +18,7 @@ sub mydie undef(*CORE::GLOBAL::die); *CORE::GLOBAL::die = \&mydie; -my $bin = $Girocco::Config::reporoot.'-recyclebin'; +my $bin = $Girocco::Config::reporoot.'/_recyclebin'; mkdir $bin; my $project = shift @ARGV || die "Please give project name on command line."; -- 2.11.4.GIT