diff options
author | Dylan Bolger <dylan.bolger00@gmail.com> | 2022-03-06 17:52:20 -0600 |
---|---|---|
committer | Dylan Bolger <dylan.bolger00@gmail.com> | 2024-01-23 22:41:41 -0600 |
commit | eebad0abb9f2dffa4d170887fa4bbc50892c99aa (patch) | |
tree | 1155756b8d1445a6d62ee45099e2c55f55bbffe3 | |
download | repo-eebad0abb9f2dffa4d170887fa4bbc50892c99aa.tar.xz repo-eebad0abb9f2dffa4d170887fa4bbc50892c99aa.zip |
Initial commit
-rwxr-xr-x | repo.sh | 65 |
1 files changed, 65 insertions, 0 deletions
@@ -0,0 +1,65 @@ +#!/bin/bash +reposDirectory=/home/git/repositories +reposList=/home/git/repos.list + +echo "1) Create a new repo" +echo "2) Delete a repo" +read -p "Choose an option: " option + +if [[ $option == 1 ]]; +then + read -p "What's the repo name? " repoName + read -p "What's the repo description? [default: ''] " repoDesc + # chronic hides output + if chronic git config user.name && chronic git config user.email; + then + username=$(git config user.name) + email="<$(git config user.email)>" + echo "Your git configuration has a username and email set:" + echo "Username: $username" + echo "Email: $email" + read -p "Set owner to your git config? [default: 'y'] (y/n) " usegc + if [[ $usegc == [yY] ]] || [[ -z $usegc ]]; + then + repoOwner="$username $email" + echo "Author set to \"$repoOwner\"" + fi + fi + if [[ $usegc == [nN] ]]; + then + read -p "What's the owner name? [default: ''] " repoOwner + fi + echo "Performing magic wizardry..." + + echo "Adding repo to list..." + echo $repoName >> $reposList + + echo "Creating $repoName directory and setting permissions..." + mkdir $reposDirectory/$repoName + chown git $reposDirectory/$repoName + + echo "Initializing bare repository..." + git init --bare $reposDirectory/$repoName + + echo "Setting repository owner..." + echo [gitweb] >> $reposDirectory/$repoName/config + echo "owner = $repoOwner" >> $reposDirectory/$repoName/config + + echo "Setting repository description..." + echo -n "" > $reposDirectory/$repoName/description + if [[ -n "$repoDesc" ]]; + then + echo "$repoDesc" >> $reposDirectory/$repoName/description + fi + echo "$repoName magically appeared!" + +elif [[ $option == 2 ]]; +then + read -p "What's the repo name? " repoName + echo "Performing magic wizardry..." + echo "Finding line in list..." + sed -i "/$repoName/d" $reposList + echo "Deleting $repoName directory..." + rm -rf $reposDirectory/$repoName + echo "$repoName has vanished!" +fi |