gitserver

self-hosted git server tooling
git clone https://git.ryansepassi.com/git/gitserver.git
Log | Files | Refs | README

remove-repo (1032B)


      1 #!/bin/sh
      2 # Permanently delete a repo: bare dir, stagit HTML (public + private),
      3 # public git mirror, archive tarballs, stagit caches. Regenerates indexes
      4 # and prunes Bunny orphans afterward.
      5 # Usage: remove-repo <name>
      6 set -eu
      7 
      8 REPOS=$HOME/repos
      9 name=${1:-}
     10 [ -n "$name" ] || { echo "usage: remove-repo <name>" >&2; exit 2; }
     11 
     12 dir=$REPOS/$name.git
     13 [ -d "$dir" ] || { echo "no such repo: $dir" >&2; exit 1; }
     14 
     15 printf "Permanently delete %s and all derived HTML/archives.\nType '%s' to confirm: " "$dir" "$name"
     16 IFS= read -r confirm
     17 [ "$confirm" = "$name" ] || { echo "aborted"; exit 1; }
     18 
     19 rm -rf "$dir"
     20 rm -rf "$REPOS/www/$name"
     21 rm -rf "$REPOS/www-public/$name"
     22 rm -rf "$REPOS/www-public/git/$name.git"
     23 rm -f  "$REPOS/.stagit-cache/$name.priv.cache"
     24 rm -f  "$REPOS/.stagit-cache/$name.pub.cache"
     25 
     26 # Rebuild indexes (and, via its tail call, re-run publish-public).
     27 "$REPOS/bin/stagit-update"
     28 
     29 # Clean orphans off Bunny.
     30 [ -x "$REPOS/bin/publish-public-prune" ] && "$REPOS/bin/publish-public-prune" || true
     31 
     32 echo "ok: removed $name"