diff CGIT/git-bare @ 3:8e515a52c7a9

add:Cgit File
author Pluto <meokcin@gmail.com>
date Tue, 03 Sep 2024 17:14:28 +0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CGIT/git-bare	Tue Sep 03 17:14:28 2024 +0800
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+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 privileged!"
+        exit 1
+    fi
+fi
+
+# 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 "sudo apt update && sudo apt install -y git"
+    exit 1
+fi
+
+read -p "Please enter the repository name (without .git)." reponame
+
+if [ -d "/home/git/${reponame}.git" ]; then
+    echo "Repository ${reponame} already exists"
+    exit 1
+else
+    git init --bare "/home/git/${reponame}.git"
+    cd "/home/git/${reponame}.git"
+
+    read -p "Please enter the repository description:" description
+    echo "${description}." | sudo tee "description" > /dev/null
+
+    # Update the Git repository info
+    if ! git update-server-info &> /dev/null; then
+        echo "Failed to update Git repository information, exiting..."
+        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 "New bare repository ${reponame} initialized successfully."
+fi
\ No newline at end of file
备案号:苏ICP备2024087954号-2 | 渝公网安备50010402001513