diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-07 21:06:35 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-11 18:36:50 -0700 |
| commit | f60e2a723c744628823cad6344a8d3d0dd4c32e4 (patch) | |
| tree | 02201b37edbe05070aac9c5f2c2335dbe25c22bc /roles/obsd_git/templates/git-shell-commands | |
| parent | Retab file (diff) | |
| download | site-configs-f60e2a723c744628823cad6344a8d3d0dd4c32e4.zip | |
Update configs
Diffstat (limited to 'roles/obsd_git/templates/git-shell-commands')
| -rw-r--r-- | roles/obsd_git/templates/git-shell-commands/create | 71 | ||||
| -rw-r--r-- | roles/obsd_git/templates/git-shell-commands/no-interactive-login | 10 |
2 files changed, 81 insertions, 0 deletions
diff --git a/roles/obsd_git/templates/git-shell-commands/create b/roles/obsd_git/templates/git-shell-commands/create new file mode 100644 index 0000000..9ac25a5 --- /dev/null +++ b/roles/obsd_git/templates/git-shell-commands/create @@ -0,0 +1,71 @@ +#!/bin/sh +set -e + +REPO="" +DESC="" +PROJ="" +VISIBILITY="public" + +main() { + parse_args "$@" + + repo_name=$(basename "$REPO" .git) + if [ -n "$PROJ" ]; then + proj_dir="{{ git_home }}/$VISIBILITY/$PROJ" + if [ ! -d "$proj_dir" ]; then + mkdir "$proj_dir" + fi + repo_path="$proj_dir/$repo_name.git" + else + repo_path="{{ git_home }}/$VISIBILITY/$repo_name.git" + fi + + if [ ! -d "$repo_path" ]; then + echo "Creating bare repository: $repo_name.git" + git init --bare --initial-branch=main "$repo_path" + chown -R git:git "$repo_path" + if [ -n "$DESC" ]; then + echo "$DESC" >>"$repo_path/description" + fi + fi +} + +parse_args() { + while [ $# -gt 0 ]; do + case "$1" in + --visibility) + VISIBILITY="$2" + case "$VISIBILITY" in public | private) ;; *) usage ;; esac + shift 2 + ;; + --description) + DESC="$2" + shift 2 + ;; + --project) + PROJ="$2" + shift 2 + ;; + -*) + echo "Unknown option: $1" >&2 + exit 1 + ;; + *) + if [ -n "$REPO" ]; then + echo "Unexpected argument: $1" >&2 + usage + fi + REPO="$1" + shift + ;; + esac + done + [ -n "$REPO" ] || usage +} + +usage() { + echo "Usage: $0 [--visibility public|private] [--description DESC] [--project PROJ] <repo>" >&2 + exit 1 +} + +main "$@" diff --git a/roles/obsd_git/templates/git-shell-commands/no-interactive-login b/roles/obsd_git/templates/git-shell-commands/no-interactive-login new file mode 100644 index 0000000..7c774ca --- /dev/null +++ b/roles/obsd_git/templates/git-shell-commands/no-interactive-login @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +main() { + printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not" + printf '%s\n' "provide interactive shell access." + exit 128 +} + +main "$@" |