From 9b9bda8bb3700b25007a1b78958a2a4ac7c2f9cb Mon Sep 17 00:00:00 2001 From: dweller Date: Sat, 9 Mar 2024 02:50:22 +0200 Subject: Initial commit --- git-shell-commands/setdesc | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 git-shell-commands/setdesc (limited to 'git-shell-commands/setdesc') 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 +# +# 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) " + 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 -- cgit v1.2.3