]> _ Git - git-shell-commands.git/commitdiff
Initial commit
authormivirl <>
Sun, 24 Sep 2023 04:18:51 +0000 (04:18 +0000)
committermivirl <>
Sun, 24 Sep 2023 04:18:51 +0000 (04:18 +0000)
README.md [new file with mode: 0644]
create-repo [new file with mode: 0755]
delete-repo [new file with mode: 0755]
help [new file with mode: 0755]
list-repos [new file with mode: 0755]
set-description [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
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 (executable)
index 0000000..b0fa26f
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+       echo "Usage: $0 <reponame>"
+       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@<server>:/srv/git/${REPO}"
diff --git a/delete-repo b/delete-repo
new file mode 100755 (executable)
index 0000000..43de00e
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ -z "$1" ]; then
+       echo "Usage: $0 <reponame>"
+        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 (executable)
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 (executable)
index 0000000..94d150d
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+ls /srv/git
diff --git a/set-description b/set-description
new file mode 100755 (executable)
index 0000000..c19acb7
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ -z "$2" ]; then
+       echo "Usage: $0 <reponame> <description>"
+       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