MinimalistGit

Project to automate creating git repos on a minimal 'git daemon' server.
Log | Files | Refs | README | LICENSE

rmrepo (1385B)


      1 #!/bin/sh
      2 
      3 # This script will automate the removal of git repositories
      4 # arguments available for this script are:
      5 
      6 # -h, --help: Prints a help screen
      7 # -n, --name: The name of the repo to delete
      8 # -z, --fzf: Enables fzf support for the selection of repo to be deleted (Must have fzf installed on system)
      9 
     10 # I should come up with some sort of confirmation for deleting the repo as well
     11 
     12 REPODIR="/usr/local/www/git"
     13 FZF=0
     14 
     15 help()
     16 {
     17     echo "-h: Prints this help menu"
     18     echo "-n: Name of repository to be deleted"
     19     echo "-r: Remote server"
     20     echo "-z: Enables FZF support for selecting repo, must have fzf installed (not implemented yet)"
     21 
     22     exit 0;
     23 }
     24 
     25 repoSelect()
     26 {
     27     if [ -z ${NAME} ]; then
     28         rm -r ${REPODIR}/${NAME}.git
     29     fi
     30 
     31     echo "Which repo would you like to delete?"
     32     NUM=1
     33     for i in $( ls ${REPODIR} ); do
     34         echo "${NUM}: $i"
     35         NUM=$(expr ${NUM} + 1)
     36     done
     37     read INPUT
     38     echo ${INPUT}
     39 }
     40 
     41 deleteRepo()
     42 {
     43     EXT=".git"
     44     rm -rf ${REPODIR}/${NAME}${EXT}
     45     /usr/local/bin/stagit-index /usr/local/www/git/*git > /usr/local/www/git/index.html
     46 }
     47 
     48 if [ "$#" -eq 0 ]; then
     49     help
     50 fi
     51 
     52 while getopts ":hzr:n:" f; do
     53     case $f in
     54         n) NAME=${OPTARG};;
     55         r) REMOTE=${OPTARG};;
     56         z) FZF=1;;
     57         h | *) help
     58                exit
     59                ;;
     60     esac
     61 done
     62 shift `expr $OPTIND - 1`
     63 
     64 deleteRepo $NAME $REMOTE