#! /usr/bin/env sh set -euo pipefail if ! id -nG | grep -qwF "gitadm"; then echo $'\e[31myou are not an admin\e[0m' exit 13 fi if [ $# -lt 1 ]; then echo $'\e[31mrepository name is required\e[0m' exit 1 fi name="$1" path="$(echo "$1" | sed 's/ /-/' | tr '[:upper:]' '[:lower:]').git" read -p $'\e[33mare you sure you want to delete the repo '"\"$name\" at \"$path\""$'\e[0m \e[1m[no]\e[0m: ' confirm delete="false" case "$(echo "$confirm" | tr '[:upper:]' '[:lower:]')" in y|yes|ye) delete="true" ;; esac if [ "$delete" = "true" ]; then echo -n "deleting repository \"$name\"..." rm -rf "$path" echo "done!" fi # delete the dir if empty dir=$(dirname "$path") find "$dir" -maxdepth 0 -type d -delete