comparison cgit/git-bare @ 5:19a4c3672796 default tip

RE:重新新增Cgit配置文件
author Franklin Schmit <meokcin@gmail.com>
date Wed, 04 Sep 2024 08:15:23 +0800
parents
children
comparison
equal deleted inserted replaced
4:4977c0f8b002 5:19a4c3672796
1 #!/bin/bash
2
3 set -eu
4
5 # /usr/local/bin/git-bare
6
7 echo "1.make sure you are running with root user or sudo privileged"
8 echo "2.make sure you have installed cURL and Git"
9 echo ""
10 echo "Press Enter to continue..."
11 read
12
13 # Check if the running user is root or sudo user
14 if [ "$(id -u)" -ne 0 ]; then
15 if ! sudo -v &> /dev/null; then
16 echo "Please run the script as root or with sudo privileged!"
17 exit 1
18 fi
19 fi
20
21 # Check if cURL is installed
22 if ! command -v curl &> /dev/null; then
23 echo "cURL is not installed, please install curl first."
24 echo "sudo apt update && sudo apt install -y curl"
25 exit 1
26 fi
27
28 # Check if Git is installed
29 if ! command -v git &> /dev/null; then
30 echo "Git is not installed, please install git first."
31 echo "sudo apt update && sudo apt install -y git"
32 exit 1
33 fi
34
35 read -p "Please enter the repository name (without .git)." reponame
36
37 if [ -d "/home/git/${reponame}.git" ]; then
38 echo "Repository ${reponame} already exists"
39 exit 1
40 else
41 git init --bare "/home/git/${reponame}.git"
42 cd "/home/git/${reponame}.git"
43
44 read -p "Please enter the repository description:" description
45 echo "${description}." | sudo tee "description" > /dev/null
46
47 # Update the Git repository info
48 if ! git update-server-info &> /dev/null; then
49 echo "Failed to update Git repository information, exiting..."
50 exit 1
51 fi
52
53 # Set up the new repository's post-receive
54 curl -s https://git.xvo.es/self-hosted/plain/cgit/post-receive.agefile -o hooks/post-receive
55 chmod +x hooks/post-receive
56
57 # Set user groups and permissions for the repository
58 chown -R git:www-data "/home/git/${reponame}.git"
59 chmod -R ug+rwx,o-rwx "/home/git/${reponame}.git"
60 echo "New bare repository ${reponame} initialized successfully."
61 fi
备案号:苏ICP备2024087954号-2 | 渝公网安备50010402001513