blob: bb0707e887edb7a39b1fc7232be6088bf2c24687 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
```
sudo adduser --system --shell /bin/bash --group --disabled-password git
# Переключаемся на пользователя git
sudo -u git -i
# Создаем структуру папок
mkdir -p ~/repositories/public
mkdir -p ~/repositories/private
mkdir ~/.ssh
# Задаем жесткие права доступа (чтение/запись только для владельца)
chmod 700 ~/.ssh
```
```
ssh-keygen -t ed25519 -f ~/.ssh/id_git_server -C "git-admin"
cat ~/.ssh/id_git_server.pub
Host my-git-server
HostName IP_ВАШЕГО_СЕРВЕРА
User git
IdentityFile ~/.ssh/id_git_server
```
```
nano ~/.ssh/authorized_keys
```
```
sudo nano /usr/local/bin/git-create
sudo chmod +x /usr/local/bin/git-create
```
```
sudo -u git mkdir -p /home/git/repositories/private/new.git
sudo -u git git init --bare /home/git/repositories/private/new.git
```
```
git remote remove origin
git remote add origin git@IP_ВАШЕГО_СЕРВЕРА:/home/git/repositories/private/api.git
git push -u origin --all
```
```cd /var/www/new
git init
git add .
git commit -m "Initial commit"
git-create private new
git push -u origin --all
```
## Установка cgit
```
sudo apt update
sudo apt install cgit spawn-fcgi fcgiwrap
sudo systemctl status fcgiwrap.socket
```
```
sudo chown -R git:www-data /home/git/repositories/public
sudo find /home/git/repositories/public -type d -exec chmod 750 {} \;
sudo find /home/git/repositories/public -type f -exec chmod 640 {} \;
sudo chmod +x /home/git
sudo chmod +x /home/git/repositories
sudo chmod +x /home/git/repositories/public
```
Для запуска из корня:
```
sudo nano /etc/cgitrc
virtual-root=/
css=/cgit-css/cgit.css
logo=/cgit-css/cgit.png
favicon=/cgit-css/favicon.ico
enable-git-config=1
remove-suffix=1
scan-path=/home/git/repositories/public
main-title=Asustem.ru
snapshots=tar.gz zip
sudo chmod -R 755 /usr/share/cgit/
```
Тест:
```
CGIT_CONFIG=/etc/cgitrc /usr/lib/cgit/cgit.cgi
```
Конфигурация nginx:
```
location /cgit-css/ {
alias /usr/share/cgit/;
try_files $uri =404;
}
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
```
```
.git/config
[gitweb]
description = Мой тестовый репозиторий
owner = user
```
|