diff options
author | Mark Powers <markppowers0@gmail.com> | 2020-10-30 19:42:09 -0500 |
---|---|---|
committer | Mark Powers <markppowers0@gmail.com> | 2020-10-30 19:42:09 -0500 |
commit | 6a44af285fe054440d7c81485dce187f42e00cc2 (patch) | |
tree | 1505127f83674647a685aad37178f26d66861d0e /repo.sh |
Initial commit
Diffstat (limited to 'repo.sh')
-rwxr-xr-x | repo.sh | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +repo_location="/srv/git/" + +trimmed_repos="" +get_repos () { + trimmed_repos=() + repos=$(ssh marks.kitchen "ls -d $repo_location*.git") + for repo in $repos + do + repo_trim=$(basename $repo | cut -f 1 -d '.') + trimmed_repos+="$repo_trim " + done +} + +create_repo () { + dir="$repo_location$1.git" + ssh git@marks.kitchen "mkdir $dir" + ssh git@marks.kitchen "cd \"$dir\"; git init --bare; touch git-daemon-export-ok" +} + +case $1 in + create) # init a git repo here and create one on the server + create_repo $2 + dir="$repo_location$2.git" + printf "git init\n" + printf "git remote add origin git@marks.kitchen:/srv/git/$dir\n" + printf "git push origin master\n" + ;; + list) # list repos on the server + get_repos + for repo in $trimmed_repos + do + printf "$repo\n" + done + ;; + clone) # clone a repo from the list + dir="$repo_location$2.git" + git clone git@marks.kitchen:/srv/git/$dir + cd $dir + ;; + *) + printf "usage: ./repo [create|list|clone] args\n" + ;; +esac + |