From: mivirl <> Date: Sun, 24 Sep 2023 04:18:51 +0000 (+0000) Subject: Initial commit X-Git-Url: http://mivirl.dev/git/?a=commitdiff_plain;h=7cd61a356201040889aad9cc6c1b1d3f318d6d36;p=git-shell-commands.git Initial commit --- 7cd61a356201040889aad9cc6c1b1d3f318d6d36 diff --git a/README.md b/README.md new file mode 100644 index 0000000..71a0952 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +This is a collection of commands for use in the restricted git-shell. These +scripts allow users to log in as the `git` user and add/modify/delete +repositories. Note that there is no access control--any user who can login can +change any repo! diff --git a/create-repo b/create-repo new file mode 100755 index 0000000..b0fa26f --- /dev/null +++ b/create-repo @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit +fi + +REPO="${1}.git" + +if [ -d "/srv/git/$REPO" ]; then + echo "Repo $REPO already exists" + exit +fi + +cd /srv/git +mkdir "$REPO" +cd "$REPO" +git init --bare +echo "#!/bin/sh" >> hooks/post-receive +echo 'git cat-file blob HEAD:README.md | markdown > $GIT_DIR/README.html' >> hooks/post-receive +chmod +x hooks/post-receive +touch git-daemon-export-ok +echo "Created $REPO" +echo "Add it to your project with: git remote add origin git@:/srv/git/${REPO}" diff --git a/delete-repo b/delete-repo new file mode 100755 index 0000000..43de00e --- /dev/null +++ b/delete-repo @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit +fi + +REPO="${1}.git" + +if [ ! -d "/srv/git/$REPO" ]; then + echo "Repo $REPO does not exist" + exit +fi + +mkdir -p /tmp/git-trash/ +cd /srv/git +mv "$REPO" /tmp/git-trash/ +echo "Moved $REPO to /tmp/git-trash/" diff --git a/help b/help new file mode 100755 index 0000000..3505082 --- /dev/null +++ b/help @@ -0,0 +1,3 @@ +#!/bin/sh +echo "Available commands:" +ls /home/git/git-shell-commands diff --git a/list-repos b/list-repos new file mode 100755 index 0000000..94d150d --- /dev/null +++ b/list-repos @@ -0,0 +1,2 @@ +#!/bin/sh +ls /srv/git diff --git a/set-description b/set-description new file mode 100755 index 0000000..c19acb7 --- /dev/null +++ b/set-description @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ -z "$2" ]; then + echo "Usage: $0 " + exit +fi + +REPO="${1}.git" + +if [ ! -d "/srv/git/$REPO" ]; then + echo "Repo $REPO does not exist" + exit +fi + +cd "/srv/git/$REPO" +echo "Old description:" +cat description + +echo "$2" > description +echo +echo "New description:" +cat description