DeleteRepo (1316B)
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 "-z: Enables FZF support for selecting repo, must have fzf installed (not implemented yet)" 20 21 exit 0; 22 } 23 24 repoSelect() 25 { 26 if [ -z ${NAME} ]; then 27 rm -r ${REPODIR}/${NAME}.git 28 fi 29 30 echo "Which repo would you like to delete?" 31 NUM=1 32 for i in $( ls ${REPODIR} ); do 33 echo "${NUM}: $i" 34 NUM=$(expr ${NUM} + 1) 35 done 36 read INPUT 37 echo ${INPUT} 38 } 39 40 deleteRepo() 41 { 42 EXT=".git" 43 rm -rf ${REPODIR}/${NAME}${EXT} 44 /usr/local/bin/stagit-index /usr/local/www/git/*git > /usr/local/www/git/index.html 45 } 46 47 if [ "$#" -eq 0 ]; then 48 help 49 fi 50 51 while getopts ":hzn:" f; do 52 case $f in 53 n) NAME=${OPTARG};; 54 z) FZF=1;; 55 h | *) help 56 exit 57 ;; 58 esac 59 done 60 shift `expr $OPTIND - 1` 61 62 deleteRepo $NAME