summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDejavu Moe <[email protected]>2023-05-12 23:05:51 +0800
committerDejavu Moe <[email protected]>2023-05-12 23:05:51 +0800
commitbed65e4c9c89ecf7d57a4f8a8c27e39cafdbbee0 (patch)
tree5f15feb30bd07faafc2d4555ede141836ad88eb2
parent376c6ad51d787b3f759b233fc1ed1553702880ef (diff)
downloadself-hosted-bed65e4c9c89ecf7d57a4f8a8c27e39cafdbbee0.tar.gz
self-hosted-bed65e4c9c89ecf7d57a4f8a8c27e39cafdbbee0.zip
update cgit/git-bare
add hooks/post-receive snippet
-rw-r--r--cgit/git-bare27
1 files changed, 23 insertions, 4 deletions
diff --git a/cgit/git-bare b/cgit/git-bare
index a4f757a..0716fcd 100644
--- a/cgit/git-bare
+++ b/cgit/git-bare
@@ -4,17 +4,31 @@ set -eu
# /usr/local/bin/git-bare
+echo "1.make sure you are running with root user or sudo privileged"
+echo "2.make sure you have installed cURL and Git"
+echo ""
+echo "Press Enter to continue..."
+read
+
# Check if the running user is root or sudo user
if [ "$(id -u)" -ne 0 ]; then
if ! sudo -v &> /dev/null; then
- echo "Please run the script as root or with sudo user"
+ echo "Please run the script as root or with sudo privileged!"
exit 1
fi
fi
-# Check if git is installed
+# Check if cURL is installed
+if ! command -v curl &> /dev/null; then
+ echo "cURL is not installed, please install curl first."
+ echo "sudo apt update && sudo apt install -y curl"
+ exit 1
+fi
+
+# Check if Git is installed
if ! command -v git &> /dev/null; then
- echo "Git is not installed, please install Git first."
+ echo "Git is not installed, please install git first."
+ echo "sudo apt update && sudo apt install -y git"
exit 1
fi
@@ -36,7 +50,12 @@ else
exit 1
fi
+ # Set up the new repository's post-receive
+ curl -s https://git.xvo.es/self-hosted/plain/cgit/post-receive.agefile -o hooks/post-receive
+ chmod +x hooks/post-receive
+
+ # Set user groups and permissions for the repository
chown -R git:www-data "/home/git/${reponame}.git"
chmod -R ug+rwx,o-rwx "/home/git/${reponame}.git"
- echo "The repository was created successfully."
+ echo "New bare repository ${reponame} initialized successfully."
fi \ No newline at end of file