commit f62d6e7fc0356e679214da9a088a8fbfdf22df83 Author: ascet-tomsk <118526659+ascet-tomsk@users.noreply.github.com> Date: Sun Jan 11 00:49:37 2026 +0700 first commit diff --git a/1.1-setup.sh b/1.1-setup.sh new file mode 100644 index 0000000..e8a1fd1 --- /dev/null +++ b/1.1-setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# 1.1 Обновление системы + +sudo apt update && sudo apt upgrade -y +sudo apt install -y curl wget git nano htop ufw \ No newline at end of file diff --git a/1.2-setup.sh b/1.2-setup.sh new file mode 100644 index 0000000..cd155d4 --- /dev/null +++ b/1.2-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# 1.2 Настройка firewall + +sudo ufw default deny incoming +sudo ufw default allow outgoing +sudo ufw allow ssh +sudo ufw allow 3000/tcp # порт Gitea +sudo ufw --force enable diff --git a/1.3-setup.sh b/1.3-setup.sh new file mode 100644 index 0000000..915ca57 --- /dev/null +++ b/1.3-setup.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# 1.3 Создание пользователей + +# Пользователь для Gitea +sudo adduser --system --group --disabled-password \ + --shell /bin/bash --home /home/git \ + --gecos 'Git Version Control' git + +# Пользователь для runner +sudo useradd -r -s /bin/bash -d /var/lib/act_runner -m act_runner \ No newline at end of file diff --git a/1.4-setup.sh b/1.4-setup.sh new file mode 100644 index 0000000..53913a5 --- /dev/null +++ b/1.4-setup.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# 1.4 Создание директорий + +# Директории Gitea +sudo mkdir -p /var/lib/gitea/{custom,data,log} +sudo mkdir -p /etc/gitea + +# Директории runner +sudo mkdir -p /var/lib/act_runner/{workspace,cache} +sudo mkdir -p /etc/act_runner + +# Права доступа +sudo chown -R git:git /var/lib/gitea +sudo chmod -R 750 /var/lib/gitea +sudo chown -R act_runner:act_runner /var/lib/act_runner +sudo chmod -R 755 /var/lib/act_runner +sudo chown root:git /etc/gitea +sudo chmod 770 /etc/gitea +sudo chown -R act_runner:act_runner /etc/act_runner \ No newline at end of file diff --git a/2.1-setup.sh b/2.1-setup.sh new file mode 100644 index 0000000..cfda1f4 --- /dev/null +++ b/2.1-setup.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# 2.1 Скачивание Gitea + +# Получаем последнюю версию +GITEA_VERSION=$(curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') +echo "Устанавливаем Gitea версии: $GITEA_VERSION" + +# Скачиваем +sudo wget -O /usr/local/bin/gitea \ +"https://github.com/go-gitea/gitea/releases/download/${GITEA_VERSION}/gitea-${GITEA_VERSION:1}-linux-amd64" + +# Права на выполнение +sudo chmod +x /usr/local/bin/gitea \ No newline at end of file diff --git a/2.2-app.ini b/2.2-app.ini new file mode 100644 index 0000000..34d1f9f --- /dev/null +++ b/2.2-app.ini @@ -0,0 +1,47 @@ +# 2.2 Конфигурационный файл Gitea +# /etc/gitea/app.ini + +APP_NAME = Gitea +RUN_USER = git +RUN_MODE = prod + +[server] +APP_DATA_PATH = /var/lib/gitea/data +HTTP_PORT = 3000 +ROOT_URL = https://git.ahtamov.ru/ +DOMAIN = localhost +SSH_DOMAIN = localhost +SSH_PORT = 22 +DISABLE_SSH = false +OFFLINE_MODE = false + +[database] +DB_TYPE = sqlite3 +PATH = /var/lib/gitea/data/gitea.db + +[repository] +ROOT = /var/lib/gitea/data/gitea-repositories + +[session] +PROVIDER = file +PROVIDER_CONFIG = /var/lib/gitea/data/sessions + +[picture] +AVATAR_UPLOAD_PATH = /var/lib/gitea/data/avatars + +[attachment] +PATH = /var/lib/gitea/data/attachments + +[log] +ROOT_PATH = /var/lib/gitea/log +MODE = file +LEVEL = Info + +[security] +INSTALL_LOCK = true +SECRET_KEY = ваш_секретный_ключ_сюда + +[actions] +ENABLED = true +STORAGE_TYPE = local +MINIO_BASE_PATH = /var/lib/gitea/actions \ No newline at end of file diff --git a/2.3-gitea.service b/2.3-gitea.service new file mode 100644 index 0000000..e635667 --- /dev/null +++ b/2.3-gitea.service @@ -0,0 +1,20 @@ +# 2.3 Systemd служба для Gitea +# /etc/systemd/system/gitea.service + +[Unit] +Description=Gitea (Git with a cup of tea) +After=network.target +Requires=network.target + +[Service] +Type=simple +User=git +Group=git +WorkingDirectory=/var/lib/gitea +ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini +Restart=always +RestartSec=2s +Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/2.4-setup.sh b/2.4-setup.sh new file mode 100644 index 0000000..e82d9bf --- /dev/null +++ b/2.4-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# 2.4 Запуск Gitea + +sudo systemctl daemon-reload +sudo systemctl enable gitea +sudo systemctl start gitea +sudo systemctl status gitea diff --git a/3.1-setup.sh b/3.1-setup.sh new file mode 100644 index 0000000..0a838d2 --- /dev/null +++ b/3.1-setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# 3.1 Создание директории для артефактов + +sudo mkdir -p /var/lib/gitea/actions +sudo chown -R git:git /var/lib/gitea/actions +sudo chmod 750 /var/lib/gitea/actions \ No newline at end of file diff --git a/3.2-setup.sh b/3.2-setup.sh new file mode 100644 index 0000000..f759f76 --- /dev/null +++ b/3.2-setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# 3.2 Перезапуск Gitea + +sudo systemctl restart gitea \ No newline at end of file diff --git a/4.1-setup.sh b/4.1-setup.sh new file mode 100644 index 0000000..3d8bb67 --- /dev/null +++ b/4.1-setup.sh @@ -0,0 +1,10 @@ + +#!/bin/bash + +# 4.1 Скачивание act_runner + +# Важно: правильное имя файла - act_runner (с подчеркиванием) +sudo wget -O /usr/local/bin/act_runner \ +https://gitea.com/gitea/act_runner/releases/download/v0.2.13/act_runner-0.2.13-linux-amd64 + +sudo chmod +x /usr/local/bin/act_runner \ No newline at end of file diff --git a/4.2-setup.sh b/4.2-setup.sh new file mode 100644 index 0000000..243c2ff --- /dev/null +++ b/4.2-setup.sh @@ -0,0 +1,6 @@ + +#!/bin/bash + +# 4.2 Проверка установки + +act_runner --version \ No newline at end of file diff --git a/4.3-config.yaml b/4.3-config.yaml new file mode 100644 index 0000000..870f92d --- /dev/null +++ b/4.3-config.yaml @@ -0,0 +1,27 @@ +runner: + capacity: 2 + labels: + - "ubuntu-24.04:host" + - "linux:host" + - "self-hosted" + - "linux-amd64" + + fetch_timeout: 5s + fetch_interval: 2s + +container: + network_mode: "host" + workdir_parent: /var/lib/act_runner/workspace + +host: + workdir_parent: /var/lib/act_runner/workspace + +cache: + enabled: true + dir: /var/lib/act_runner/cache + cleanup_interval: 24h + +# 4.3 Конфигурационный файл act_runner +# /etc/act_runner/config.yaml + + \ No newline at end of file diff --git a/5.1-setup.sh b/5.1-setup.sh new file mode 100644 index 0000000..694ae83 --- /dev/null +++ b/5.1-setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# 5.1 Установка Node.js + +curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - +sudo apt install -y nodejs +node --version \ No newline at end of file diff --git a/5.2-setup.sh b/5.2-setup.sh new file mode 100644 index 0000000..dd11592 --- /dev/null +++ b/5.2-setup.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# 5.2 Установка Python и инструментов + +sudo apt install -y \ +python3 python3-pip python3-venv \ +build-essential \ +git curl wget \ +jq yq \ +unzip zip \ No newline at end of file diff --git a/5.3-setup.sh b/5.3-setup.sh new file mode 100644 index 0000000..fc84e48 --- /dev/null +++ b/5.3-setup.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# 5.3 Настройка PATH для пользователя act_runner + +sudo -u act_runner bash -c 'cat > ~/.bashrc << EOF +export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:\$PATH +EOF' \ No newline at end of file diff --git a/6.1-act_runner.service b/6.1-act_runner.service new file mode 100644 index 0000000..e59d06b --- /dev/null +++ b/6.1-act_runner.service @@ -0,0 +1,22 @@ +# 6.1 Создание службы для act_runner +# /etc/systemd/system/act_runner.service + +[Unit] +Description=Gitea Actions Runner +After=network.target gitea.service +Requires=gitea.service + +[Service] +Type=simple +User=act_runner +Group=act_runner +WorkingDirectory=/var/lib/act_runner +ExecStart=/usr/local/bin/act_runner daemon --config /etc/act_runner/config.yaml +Restart=always +RestartSec=10 +Environment="PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" +Environment="HOME=/var/lib/act_runner" +Environment="USER=act_runner" + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/6.2-setup.sh b/6.2-setup.sh new file mode 100644 index 0000000..8a8668c --- /dev/null +++ b/6.2-setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# 6.2 Запуск службы + +sudo systemctl daemon-reload +sudo systemctl enable act_runner \ No newline at end of file diff --git a/7.1-setup.sh b/7.1-setup.sh new file mode 100644 index 0000000..a9e9957 --- /dev/null +++ b/7.1-setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# 7.1 Регистрация act_runner + +# Остановите службу перед регистрацией +sudo systemctl stop act_runner + +# Выполните регистрацию (замените ВАШ_ТОКЕН на реальный токен) +sudo -u act_runner /usr/local/bin/act_runner register \ +--config /etc/act_runner/config.yaml \ +--instance http://localhost:3000 \ +--token ВАШ_ТОКЕН \ +--name "Ubuntu 24.04 Runner" \ +--labels "ubuntu-24.04:host,linux:host,self-hosted,linux-amd64" \ +--no-interactive \ No newline at end of file diff --git a/7.2-setup.sh b/7.2-setup.sh new file mode 100644 index 0000000..2a39bb6 --- /dev/null +++ b/7.2-setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# 7.2 Запуск runner после регистрации + +sudo systemctl start act_runner +sudo systemctl status act_runner \ No newline at end of file diff --git a/8.2-test.yml b/8.2-test.yml new file mode 100644 index 0000000..eaba078 --- /dev/null +++ b/8.2-test.yml @@ -0,0 +1,21 @@ +name: Test Runner +on: [push] + +jobs: + test: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Show info + run: | + echo "🎉 Runner работает!" + echo "OS: $(lsb_release -ds)" + echo "Runner: $(whoami)" + echo "Node: $(node --version)" + + - name: Create file + run: | + echo "Hello from Gitea Actions!" > test.txt + ls -la \ No newline at end of file diff --git a/complete-install-action.sh b/complete-install-action.sh new file mode 100644 index 0000000..30d37fd --- /dev/null +++ b/complete-install-action.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Полный сброс act_runner + +echo "=== Полный сброс и переустановка ===" + +# 1. Останавливаем службы +sudo systemctl stop act_runner +sudo systemctl disable act_runner + +# 2. Удаляем все файлы runner +sudo rm -f /usr/local/bin/act_runner +sudo rm -rf /etc/act_runner +sudo rm -rf /var/lib/act_runner/{.*,*} 2>/dev/null + +# 3. Создаем заново структуру +sudo mkdir -p /etc/act_runner +sudo mkdir -p /var/lib/act_runner/{workspace,cache} +sudo chown -R act_runner:act_runner /etc/act_runner /var/lib/act_runner + +# 4. Устанавливаем act_runner +sudo wget -O /usr/local/bin/act_runner \ +https://gitea.com/gitea/act_runner/releases/download/v0.2.13/act_runner-0.2.13-linux-amd64 +sudo chmod +x /usr/local/bin/act_runner + +# 5. Регистрируем (работаем из домашней директории пользователя) +cd /var/lib/act_runner +sudo -u act_runner /usr/local/bin/act_runner register \ +--instance http://localhost:3000 \ +--token ВАШ_ТОКЕН \ +--no-interactive + +# 6. Создаем конфиг +sudo cat > /etc/act_runner/config.yaml << 'EOF' +runner: + capacity: 2 + labels: ["self-hosted", "ubuntu-24.04:host"] +EOF + +# 7. Запускаем +sudo systemctl daemon-reload +sudo systemctl enable act_runner +sudo systemctl start act_runner + +echo "Готово!" \ No newline at end of file diff --git a/gitea setup.code-workspace b/gitea setup.code-workspace new file mode 100644 index 0000000..876a149 --- /dev/null +++ b/gitea setup.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} \ No newline at end of file