diff options
Diffstat (limited to 'git-shell-commands')
-rwxr-xr-x | git-shell-commands/help | 12 | ||||
-rwxr-xr-x | git-shell-commands/mkrepo | 42 | ||||
-rwxr-xr-x | git-shell-commands/setdesc | 37 |
3 files changed, 91 insertions, 0 deletions
diff --git a/git-shell-commands/help b/git-shell-commands/help new file mode 100755 index 0000000..292cb97 --- /dev/null +++ b/git-shell-commands/help @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (C) 2024 dwlr <dweller@cabin.digital> +# +# BSD 3-Clause License (BSD-3-Clause) +# See LICENSE for details + +set -e + + +echo "Available: commands:" +ls "$HOME/git-shell-commands" +echo "exit" diff --git a/git-shell-commands/mkrepo b/git-shell-commands/mkrepo new file mode 100755 index 0000000..356cafa --- /dev/null +++ b/git-shell-commands/mkrepo @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright (C) 2024 dwlr <dweller@cabin.digital> +# +# BSD 3-Clause License (BSD-3-Clause) +# See LICENSE for details + +set -e + +#FIXME: this is wide open for exploits by using crafted paths like ../../../etc/passwd or something +# But we should be okay since this is behind ssh, right? r- right..? + + +PREFIX="$HOME/repos" + +if [ $# -lt 1 ]; then + echo "Usage: $(basename $0) <repo name> [description]" + exit 1; +fi + +case "$1" in + *.git) reponame="$1" ;; + *) reponame="$1.git" ;; +esac + +netname=$(echo "$PREFIX/$reponame" | sed "s|$HOME|:|") +reponame="$PREFIX/$reponame" + + +if [ ! -e "$reponame" ]; +then + mkdir -p "$reponame" + cd "$reponame" + git init -q --bare && echo "$netname" || echo "Failed to create repo '$netname' :(" + + if [ $# -gt 1 ]; then + shift + echo "$@" > description + fi +else + echo "$netname exists!" + exit 1 +fi diff --git a/git-shell-commands/setdesc b/git-shell-commands/setdesc new file mode 100755 index 0000000..651b170 --- /dev/null +++ b/git-shell-commands/setdesc @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright (C) 2024 dwlr <dweller@cabin.digital> +# +# BSD 3-Clause License (BSD-3-Clause) +# See LICENSE for details + +set -e + +#FIXME: this is wide open for exploits by using crafted paths like ../../../etc/passwd or something +# But we should be okay since this is behind ssh, right? r- right..? + + +PREFIX="$HOME/repos" + +if [ $# -lt 2 ]; then + echo "Usage: $(basename $0) <repo name> <description>" + exit 1; +fi + +case "$1" in + *.git) reponame="$1" ;; + *) reponame="$1.git" ;; +esac + +netname=$(echo "$PREFIX/$reponame" | sed "s|$HOME|:|") +reponame="$PREFIX/$reponame" + + +if [ -e "$reponame" ]; +then + cd "$reponame" + shift + echo "$@" > description +else + echo "$netname doesn't exists!" + exit 1 +fi |