From bed65e4c9c89ecf7d57a4f8a8c27e39cafdbbee0 Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Fri, 12 May 2023 23:05:51 +0800 Subject: update cgit/git-bare add hooks/post-receive snippet --- cgit/git-bare | 27 +++++++++++++++++++++++---- 1 file 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 -- cgit v1.2.3-54-g00ecf