Compare commits
6 Commits
gitea-draf
...
19ec4e82f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 19ec4e82f3 | |||
| a9a446d8b7 | |||
| 7db0de6eda | |||
| db68076181 | |||
| c0b936f792 | |||
| dd903276f7 |
@@ -1,39 +1,147 @@
|
|||||||
# Кастомизация Gitea
|
# Кастомизация Gitea
|
||||||
|
|
||||||
```sh
|
Во всех командах подразумевается, что Gitea [установлена из бинарника](https://docs.gitea.com/installation/install-from-binary) и [запускается как `systemd` сервис](https://docs.gitea.com/installation/linux-service).
|
||||||
sudo su - git
|
|
||||||
cd /var/lib/gitea/custom
|
В документации есть страница, посвящённая [кастомизации Gitea](https://docs.gitea.com/administration/customizing-gitea).
|
||||||
```
|
|
||||||
|
|
||||||
|
## Свой `css`
|
||||||
|
|
||||||
|
Добавляем ссылку на свой файл со стилями.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mkdir -p /var/lib/gitea/custom/public/css
|
# Путь по умолчанию
|
||||||
mkdir -p /var/lib/gitea/custom/templates/custom
|
export GITEA_CUSTOM=/var/lib/gitea/custom
|
||||||
|
|
||||||
|
sudo -u git mkdir -p $GITEA_CUSTOM/templates/custom
|
||||||
|
sudo -u git nano $GITEA_CUSTOM/templates/custom/header.tmpl
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh
|
=== "header.tmpl"
|
||||||
sudo nano /var/lib/gitea/custom/templates/custom
|
|
||||||
```
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="/custom/css/custom.css">
|
<link rel="stylesheet" href="/assets/css/custom.css">
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Создаём файл со стилями.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo -u git mkdir css
|
sudo -u git mkdir -p $GITEA_CUSTOM/public/assets/css
|
||||||
sudo -u git nano css/custom.css
|
sudo -u git nano $GITEA_CUSTOM/public/assets/css/custom.css
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "Пример custom.css"
|
||||||
|
|
||||||
|
```css
|
||||||
|
/* Стили для git.tishenko.dev */
|
||||||
|
* {
|
||||||
|
transition: all 0.125s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Список переменных и их значения по умолчанию
|
||||||
|
*
|
||||||
|
* Для светлой темы
|
||||||
|
* https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-gitea-light.css
|
||||||
|
*
|
||||||
|
* Для тёмной темы
|
||||||
|
* https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/theme-gitea-dark.css
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Переопределения переменных для светлой и тёмной темы одновременно */
|
||||||
|
:root {
|
||||||
|
/* Основной цвет */
|
||||||
|
--color-primary: #6674c4;
|
||||||
|
--color-primary-contrast: #ffffff;
|
||||||
|
|
||||||
|
/* https://maketintsandshades.com/#4051B5 */
|
||||||
|
--color-primary-dark-1: #7985cb;
|
||||||
|
--color-primary-dark-2: #8c97d3;
|
||||||
|
--color-primary-dark-3: #a0a8da;
|
||||||
|
--color-primary-dark-4: #b3b9e1;
|
||||||
|
--color-primary-dark-5: #c6cbe9;
|
||||||
|
--color-primary-dark-6: #d9dcf0;
|
||||||
|
--color-primary-dark-7: #eceef8;
|
||||||
|
|
||||||
|
--color-primary-light-1: #5362bc;
|
||||||
|
--color-primary-light-2: #4051b5;
|
||||||
|
--color-primary-light-3: #3a49a3;
|
||||||
|
--color-primary-light-4: #334191;
|
||||||
|
--color-primary-light-5: #2d397f;
|
||||||
|
--color-primary-light-6: #26316d;
|
||||||
|
--color-primary-light-7: #20295b;
|
||||||
|
|
||||||
|
--color-primary-alpha-10: #6674c419;
|
||||||
|
--color-primary-alpha-20: #6674c433;
|
||||||
|
--color-primary-alpha-30: #6674c44b;
|
||||||
|
--color-primary-alpha-40: #6674c466;
|
||||||
|
--color-primary-alpha-50: #6674c480;
|
||||||
|
--color-primary-alpha-60: #6674c499;
|
||||||
|
--color-primary-alpha-70: #6674c4b3;
|
||||||
|
--color-primary-alpha-80: #6674c4cc;
|
||||||
|
--color-primary-alpha-90: #6674c4e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Переопределения переменных для светлой темы */
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {}
|
||||||
|
|
||||||
|
#navbar-logo {
|
||||||
|
padding: 5px !important;
|
||||||
|
background: #14151A;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-logo img {
|
||||||
|
width: 27px !important;
|
||||||
|
height: 27px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#navbar-logo:hover {
|
||||||
|
background: #14151A !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Переопределения переменных для тёмной темы */
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
/* Шапка */
|
||||||
|
--color-nav-bg: #14151A;
|
||||||
|
--color-secondary-nav-bg: #14151A;
|
||||||
|
--color-nav-text: #BEC1C6;
|
||||||
|
--color-nav-hover-bg: #272A35;
|
||||||
|
|
||||||
|
/* Тёмно-серый фон основной */
|
||||||
|
--color-body: #1E2129;
|
||||||
|
|
||||||
|
--color-input-background: #14151A;
|
||||||
|
--color-menu: #14151A;
|
||||||
|
--color-card: #14151A;
|
||||||
|
--color-button: #14151A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
```sh
|
```sh
|
||||||
sudo systemctl restart gitea
|
sudo systemctl restart gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
После изменения стилей, страницу в браузере нужно обновить с помощью `ctrl + f5`.
|
||||||
|
|
||||||
|
## Настройка `app.ini`
|
||||||
|
|
||||||
|
Перечень всех возможных настроек представлен в [документации](https://docs.gitea.com/administration/config-cheat-sheet).
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
```sh
|
```sh
|
||||||
sudo nano /etc/gitea/app.ini
|
sudo nano /etc/gitea/app.ini
|
||||||
```
|
```
|
||||||
https://docs.gitea.com/administration/customizing-gitea
|
|
||||||
https://docs.gitea.com/administration/config-cheat-sheet
|
|
||||||
|
|
||||||
```ini title="app.ini"
|
=== "Пример параметров app.ini"
|
||||||
|
```ini
|
||||||
[server]
|
[server]
|
||||||
LANDING_PAGE = explore
|
LANDING_PAGE = explore
|
||||||
|
|
||||||
@@ -56,31 +164,30 @@ DESCRIPTION = A personal hub for managing Git repositories by Artem Tishenko.
|
|||||||
KEYWORDS = Artem Tishenko, Artyom Tishchenko, Git, self-hosted, personal projects, repositories, Gitea
|
KEYWORDS = Artem Tishenko, Artyom Tishchenko, Git, self-hosted, personal projects, repositories, Gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
```sh
|
```sh
|
||||||
mkdir -p /var/lib/gitea/custom/templates/base
|
sudo systemctl restart gitea
|
||||||
cd /var/lib/gitea/custom/templates/base
|
|
||||||
# перейти туда
|
|
||||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v1.22.3/templates/base/footer_content.tmpl
|
|
||||||
|
|
||||||
# remove help - https://docs.gitea.com
|
|
||||||
# remove explore - explore.repos
|
|
||||||
# remove sign_in (just visit /user/login)
|
|
||||||
wget https://github.com/go-gitea/gitea/raw/refs/tags/v1.22.3/templates/base/head_navbar.tmpl
|
|
||||||
|
|
||||||
|
|
||||||
mkdir -p /var/lib/gitea/custom/templates/repo
|
|
||||||
cd /var/lib/gitea/custom/templates/repo
|
|
||||||
# remove packages
|
|
||||||
# remove wiki
|
|
||||||
# remove repo.activity
|
|
||||||
# remove repo.issues
|
|
||||||
# remove repo.pulls
|
|
||||||
# remove watch, fork
|
|
||||||
wget https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/v1.22.3/templates/repo/header.tmpl
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Изменение шаблонов страниц
|
||||||
|
|
||||||
|
Ищем шаблон для нужной версии в [репозитории Gitea](https://github.com/go-gitea/gitea/tree/main/templates), загружаем с помощью `wget` по такому же пути в `$GITEA_CUSTOM/templates` и редактируем.
|
||||||
|
|
||||||
|
Так, например, можно убрать пункт "Помощь" с ссылкой на `https://docs.gitea.com` из основного меню.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# <a class="item" href="https://kb.tishenko.dev/" target="_blank">Knowledge base</a>
|
# Путь по умолчанию
|
||||||
/var/lib/gitea/custom/templates/custom/extra_links.tmpl
|
export GITEA_CUSTOM=/var/lib/gitea/custom
|
||||||
|
|
||||||
|
# gitea --version
|
||||||
|
export GITEA_VERSION=v1.22.3
|
||||||
|
|
||||||
|
sudo -u git mkdir -p $GITEA_CUSTOM/templates/base
|
||||||
|
wget -P $GITEA_CUSTOM/templates/base https://raw.githubusercontent.com/go-gitea/gitea/refs/tags/$GITEA_VERSION/templates/base/head_navbar.tmpl
|
||||||
|
sudo -u git nano $GITEA_CUSTOM/templates/base/head_navbar.tmpl
|
||||||
|
```
|
||||||
|
|
||||||
|
Перезапускаем Gitea.
|
||||||
|
```sh
|
||||||
|
sudo systemctl restart gitea
|
||||||
```
|
```
|
||||||
14
docs/python/django.md
Normal file
14
docs/python/django.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## Отслеживание SQL запросов
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django.db import connection, reset_queries
|
||||||
|
|
||||||
|
# Сбрасываем счетчик запросов
|
||||||
|
reset_queries()
|
||||||
|
|
||||||
|
# Код, который работает с БД
|
||||||
|
|
||||||
|
# Теперь выводим все запросы, которые были зафиксированы
|
||||||
|
for query in connection.queries:
|
||||||
|
print(query)
|
||||||
|
```
|
||||||
82
docs/servers/grafana.md
Normal file
82
docs/servers/grafana.md
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
## Запуск Prometheus с помощью systemd
|
||||||
|
|
||||||
|
Ссылку на последнюю версию `Prometheus` можно найти на [странице загрузок](https://prometheus.io/download/).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Скачиваем и распаковываем релиз
|
||||||
|
wget <link>
|
||||||
|
tar xvf prometheus-*.*-amd64.tar.gz
|
||||||
|
cd prometheus-*.*
|
||||||
|
|
||||||
|
# Создаём отдельного пользователя и группу для запуска prometheus
|
||||||
|
sudo adduser --system --no-create-home --group prometheus
|
||||||
|
|
||||||
|
# Конфиг
|
||||||
|
sudo mkdir /etc/prometheus
|
||||||
|
sudo cp prometheus.yml /etc/prometheus/
|
||||||
|
sudo chown -R prometheus:prometheus /etc/prometheus
|
||||||
|
|
||||||
|
# Папка для данных
|
||||||
|
sudo mkdir /var/lib/prometheus
|
||||||
|
sudo chown -R prometheus:prometheus /var/lib/prometheus
|
||||||
|
|
||||||
|
# Бинарники prometheus и promtool
|
||||||
|
sudo cp prometheus /usr/local/bin/
|
||||||
|
sudo chown prometheus:prometheus /usr/local/bin/prometheus
|
||||||
|
sudo cp promtool /usr/local/bin/
|
||||||
|
sudo chown prometheus:prometheus /usr/local/bin/promtool
|
||||||
|
```
|
||||||
|
|
||||||
|
Создаём `systemd` сервис. Список возможных параметров запуска `Prometheus` представлен в [документации](https://prometheus.io/docs/prometheus/latest/command-line/prometheus/).
|
||||||
|
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
```sh
|
||||||
|
sudo nano /etc/systemd/system/prometheus.service
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "prometheus.service"
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus Server
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=prometheus
|
||||||
|
Group=prometheus
|
||||||
|
Restart=on-failure
|
||||||
|
ExecStart=/usr/local/bin/prometheus \
|
||||||
|
--config.file=/etc/prometheus/prometheus.yml \
|
||||||
|
--storage.tsdb.path=/var/lib/prometheus
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
```
|
||||||
|
|
||||||
|
Добавляем `Prometheus` в автозагрузку и запускаем.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl enable prometheus
|
||||||
|
sudo systemctl start prometheus
|
||||||
|
sudo systemctl status prometheus
|
||||||
|
```
|
||||||
|
|
||||||
|
При обновлении конфига, нужно будет перезапустить сервис.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl restart prometheus
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Node Exporter
|
||||||
|
|
||||||
|
Устанавливаем `Node Exporter` по инструкции из [документации](https://prometheus.io/docs/guides/node-exporter/). Сервис в `systemd` для `Node Exporter` будет создан автоматически.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo systemctl status node_exporter.service
|
||||||
|
```
|
||||||
|
|
||||||
|
[Пример](https://grafana.com/grafana/dashboards/1860-node-exporter-full/) дашборда `Grafana` для `Node Exporter`.
|
||||||
@@ -1,10 +1,41 @@
|
|||||||
|
## Добавление сайта
|
||||||
|
|
||||||
|
Создаём конфиг.
|
||||||
|
|
||||||
|
=== "Терминал"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo nano /etc/nginx/sites-available/new-site.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "Пример конфига"
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
server {
|
||||||
|
server_name example.com www.example.com;
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
root /var/www/new-site;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Активируем конфиг.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo ln -s /etc/nginx/sites-available/new-site.conf /etc/nginx/sites-enabled/
|
||||||
|
sudo systemctl reload nginx.service
|
||||||
|
```
|
||||||
|
|
||||||
## SSL-сертификат с certbot
|
## SSL-сертификат с certbot
|
||||||
|
|
||||||
!!! tip "Актуальная версия Python"
|
!!! tip "Актуальная версия Python"
|
||||||
|
|
||||||
Обычно системый `Python` достаточно старый. Для установки `certbot` может потребоваться более новая версия. Минимальные требования можно узнать на [pypi](https://pypi.org/project/certbot/).
|
Обычно системный `Python` достаточно старый. Для установки `certbot` может потребоваться более новая версия. Минимальные требования можно узнать на [pypi](https://pypi.org/project/certbot/).
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt update
|
sudo apt update
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ ssh root@<IPv4>
|
|||||||
```sh { .code-wrap }
|
```sh { .code-wrap }
|
||||||
# Создаём пользователя и наделяем правом использовать `sudo`.
|
# Создаём пользователя и наделяем правом использовать `sudo`.
|
||||||
adduser <user>
|
adduser <user>
|
||||||
adduser <username> sudo
|
adduser <user> sudo
|
||||||
|
|
||||||
# Переключаемся на нового пользователя
|
# Переключаемся на нового пользователя
|
||||||
su - <user>
|
su - <user>
|
||||||
@@ -156,7 +156,7 @@ sudo ufw status verbose
|
|||||||
|
|
||||||
## Настройка Fail2Ban
|
## Настройка Fail2Ban
|
||||||
|
|
||||||
[Fail2Ban](https://github.com/fail2ban/fail2ban) - базовая защита сервера от brute-force аттак.
|
[Fail2Ban](https://github.com/fail2ban/fail2ban) - базовая защита сервера от brute-force атак.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt update
|
sudo apt update
|
||||||
Reference in New Issue
Block a user