Compare commits
81 Commits
lint/full
...
fe0c7067b6
| Author | SHA1 | Date | |
|---|---|---|---|
| fe0c7067b6 | |||
| d0f0843774 | |||
| 81a5b207ac | |||
| e3d5970ae3 | |||
| 85f05c26cb | |||
| 68630eb773 | |||
| dad9cf2104 | |||
| 60886e8be2 | |||
| 4528321225 | |||
| b246a3dea1 | |||
| 4c59a2d2fe | |||
| fcc7b0d611 | |||
| 9633fe3a10 | |||
| d9f1c8325a | |||
| 861d89d36a | |||
| 71cddd6a91 | |||
| 30e6f05584 | |||
| bc8d74fd28 | |||
| d2d4efb0d7 | |||
| b752bf88bd | |||
| 587611ca88 | |||
| ace23ad1f9 | |||
| 92aa731e44 | |||
|
87ca3fd40c
|
|||
|
82bcd30ed8
|
|||
| 620262d98c | |||
| 831f3a46b0 | |||
|
f7902e74e8
|
|||
|
eb8d1b361e
|
|||
|
6e2cafb206
|
|||
|
67b0c0824f
|
|||
|
8e72e0a920
|
|||
| 73a1132beb | |||
| a128523c24 | |||
| ee881acd0e | |||
| bacb2f4b9f | |||
| 91211e7b78 | |||
|
9b3a7aadb4
|
|||
|
b123621ead
|
|||
|
a2df8504f5
|
|||
|
fb43306571
|
|||
|
f424d91405
|
|||
|
88a8f2987f
|
|||
|
17027b232b
|
|||
|
6ecbbb39b4
|
|||
|
175cbc8860
|
|||
|
6363d050b0
|
|||
|
c855764bc6
|
|||
|
7d92b85e21
|
|||
| 9364392bc0 | |||
| 4355f451d4 | |||
| 3eaef5dc90 | |||
| 69ffd3682e | |||
| 1930600c40 | |||
|
d74a705d53
|
|||
|
3c383db9a7
|
|||
| 7fb0a0e179 | |||
|
227e5fda27
|
|||
| 20bce5b31c | |||
|
70d7855f06
|
|||
| c905bbd039 | |||
| 7ba6bc44f2 | |||
| 95cec59263 | |||
| 20b8c93275 | |||
| bb821e138a | |||
| b7854447af | |||
| 444bb97f8e | |||
| 4f01cdac31 | |||
| cb40b10ecf | |||
| bed58c84ef | |||
| 56e5d79e3e | |||
| cd0ce06246 | |||
| a699ceb935 | |||
| ce66a546f1 | |||
| a30bda4940 | |||
| b722467991 | |||
| 5f8fd05266 | |||
| 1c7afe5bb3 | |||
| 4ff80c07b0 | |||
| 3a5652daa7 | |||
| 4e18cd0eb3 |
@@ -0,0 +1,191 @@
|
|||||||
|
# Инструкция: Анализ хранилища Kubernetes и настройка NFS
|
||||||
|
|
||||||
|
## Цель
|
||||||
|
Проанализировать текущую конфигурацию хранилища Kubernetes и подготовить план внедрения NFS StorageClass для сохранения данных при удалении namespace.
|
||||||
|
|
||||||
|
## 1. Собрать информацию о кластере
|
||||||
|
|
||||||
|
### 1.1. Версия Kubernetes и тип дистрибутива
|
||||||
|
```bash
|
||||||
|
kubectl version --short
|
||||||
|
# или
|
||||||
|
kubectl version
|
||||||
|
```
|
||||||
|
|
||||||
|
Определить, используется ли k3s, k8s, microk8s и т.д.:
|
||||||
|
```bash
|
||||||
|
# Проверить наличие k3s
|
||||||
|
which k3s
|
||||||
|
# Проверить процесс
|
||||||
|
ps aux | grep -E 'kube|k3s'
|
||||||
|
```
|
||||||
|
|
||||||
|
### 1.2. StorageClass
|
||||||
|
```bash
|
||||||
|
kubectl get storageclass -o wide
|
||||||
|
```
|
||||||
|
|
||||||
|
Запомнить:
|
||||||
|
- `PROVISIONER` — какой драйвер используется
|
||||||
|
- `RECLAIMPOLICY` — Delete или Retain
|
||||||
|
- Какой StorageClass помечен как `(default)`
|
||||||
|
|
||||||
|
### 1.3. Существующие PV и PVC
|
||||||
|
```bash
|
||||||
|
kubectl get pv -o wide
|
||||||
|
kubectl get pvc --all-namespaces
|
||||||
|
```
|
||||||
|
|
||||||
|
Посмотреть, какие PVC привязаны к каким PV, и какой reclaimPolicy у PV.
|
||||||
|
|
||||||
|
### 1.4. Нода и диски
|
||||||
|
```bash
|
||||||
|
# Список нод
|
||||||
|
kubectl get nodes -o wide
|
||||||
|
|
||||||
|
# На каждой ноде (через ssh или локально):
|
||||||
|
lsblk
|
||||||
|
df -h
|
||||||
|
cat /etc/fstab
|
||||||
|
```
|
||||||
|
|
||||||
|
Определить:
|
||||||
|
- Есть ли отдельный раздел/диск для данных
|
||||||
|
- Куда смонтированы разделы
|
||||||
|
- Сколько свободного места
|
||||||
|
- Есть ли монтирование NTFS-разделов (как `/media/forust/Programs`)
|
||||||
|
|
||||||
|
### 1.5. Где local-path хранит данные (для k3s)
|
||||||
|
```bash
|
||||||
|
ls -la /var/lib/rancher/k3s/storage/ 2>/dev/null
|
||||||
|
# или для microk8s
|
||||||
|
ls -la /var/snap/microk8s/common/ 2>/dev/null
|
||||||
|
```
|
||||||
|
|
||||||
|
## 2. Анализ: сохраняются ли данные при удалении namespace?
|
||||||
|
|
||||||
|
| Сценарий | Результат |
|
||||||
|
|---|---|
|
||||||
|
| `kubectl delete ns <ns>` | Все PVC в namespace удаляются |
|
||||||
|
| PVC → PV c `reclaimPolicy: Delete` | PV и данные удалены |
|
||||||
|
| PVC → PV c `reclaimPolicy: Retain` | PV остаётся (статус Released), данные целы |
|
||||||
|
|
||||||
|
**Вывод:** Если reclaimPolicy в StorageClass = `Delete`, то данные **пропадут**. Если `Retain` — сохранятся.
|
||||||
|
|
||||||
|
## 3. План внедрения NFS
|
||||||
|
|
||||||
|
### 3.1. Проверить, установлен ли NFS
|
||||||
|
```bash
|
||||||
|
which nfsstat exportfs mount.nfs
|
||||||
|
systemctl status nfs-server 2>/dev/null || systemctl status nfs-kernel-server 2>/dev/null
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.2. Выбрать директорию для NFS-экспорта
|
||||||
|
|
||||||
|
Варианты (выбрать подходящий):
|
||||||
|
- `/var/lib/k8s-nfs/` — на корневом разделе
|
||||||
|
- `<путь к отдельному разделу>/k8s-nfs/` — если есть отдельный диск/раздел
|
||||||
|
- Не рекомендуется использовать NTFS-раздел (проблемы с правами и производительностью)
|
||||||
|
|
||||||
|
Требования:
|
||||||
|
- Файловая система: ext4 или xfs (не ntfs!)
|
||||||
|
- Достаточно свободного места
|
||||||
|
- Права: `755`, владелец root
|
||||||
|
|
||||||
|
### 3.3. Установить NFS-сервер
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Debian/Ubuntu
|
||||||
|
apt update && apt install -y nfs-kernel-server
|
||||||
|
|
||||||
|
# RHEL/Fedora
|
||||||
|
dnf install -y nfs-utils
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.4. Настроить экспорт
|
||||||
|
|
||||||
|
Создать директорию:
|
||||||
|
```bash
|
||||||
|
mkdir -p /var/lib/k8s-nfs
|
||||||
|
chmod 755 /var/lib/k8s-nfs
|
||||||
|
```
|
||||||
|
|
||||||
|
Добавить в `/etc/exports`:
|
||||||
|
```
|
||||||
|
/var/lib/k8s-nfs *(rw,sync,no_subtree_check,no_root_squash)
|
||||||
|
```
|
||||||
|
|
||||||
|
Применить:
|
||||||
|
```bash
|
||||||
|
exportfs -rav
|
||||||
|
```
|
||||||
|
|
||||||
|
Проверить:
|
||||||
|
```bash
|
||||||
|
showmount -e localhost
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.5. Выбрать способ интеграции с Kubernetes
|
||||||
|
|
||||||
|
#### Вариант A: nfs-subdir-external-provisioner (проще)
|
||||||
|
```bash
|
||||||
|
helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
|
||||||
|
helm install nfs-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
|
||||||
|
--namespace kube-system \
|
||||||
|
--set nfs.server=127.0.0.1 \
|
||||||
|
--set nfs.path=/var/lib/k8s-nfs \
|
||||||
|
--set storageClass.name=nfs \
|
||||||
|
--set storageClass.defaultClass=false \
|
||||||
|
--set storageClass.reclaimPolicy=Retain
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Вариант B: NFS CSI Driver
|
||||||
|
```bash
|
||||||
|
helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
|
||||||
|
helm install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system
|
||||||
|
```
|
||||||
|
|
||||||
|
После установки CSI драйвера создать StorageClass:
|
||||||
|
```yaml
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
name: nfs
|
||||||
|
provisioner: nfs.csi.k8s.io
|
||||||
|
parameters:
|
||||||
|
server: 127.0.0.1
|
||||||
|
share: /var/lib/k8s-nfs
|
||||||
|
reclaimPolicy: Retain
|
||||||
|
volumeBindingMode: Immediate
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.6. Проверить результат
|
||||||
|
```bash
|
||||||
|
kubectl get storageclass
|
||||||
|
kubectl get pods -n kube-system | grep -E 'nfs|provisioner'
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Итоговая конфигурация
|
||||||
|
|
||||||
|
После внедрения в кластере будет два StorageClass:
|
||||||
|
|
||||||
|
| Имя | Provisioner | ReclaimPolicy | Назначение |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `local-path` (default) | rancher.io/local-path | Delete | Временные данные, stateless |
|
||||||
|
| `nfs` | nfs-subdir-external-provisioner или nfs.csi.k8s.io | Retain | Данные, которые нужно сохранять |
|
||||||
|
|
||||||
|
**Главное преимущество:** PVC c `storageClassName: nfs` при удалении namespace сохраняют данные на диске, так как NFS-провизор использует `reclaimPolicy: Retain` или файлы физически остаются в NFS-экспорте.
|
||||||
|
|
||||||
|
## 5. Ответы на частые вопросы
|
||||||
|
|
||||||
|
**В:** Не упадёт ли local-path при установке NFS?
|
||||||
|
**О:** Нет, они независимы. local-path продолжает работать как обычно.
|
||||||
|
|
||||||
|
**В:** Данные NFS и local-path будут на одном диске?
|
||||||
|
**О:** Да, можно настроить оба на одном разделе, в разных каталогах.
|
||||||
|
|
||||||
|
**В:** Что если у меня несколько нод?
|
||||||
|
**О:** NFS сервер нужно поднять на одной ноде, а с других нод должна быть доступна шари. Для multi-node лучше использовать отдельный сервер или distributed storage (Longhorn, Rook/Ceph).
|
||||||
|
|
||||||
|
**В:** Можно ли использовать существующий NTFS-раздел для NFS?
|
||||||
|
**О:** Не рекомендуется — NTFS не поддерживает права Linux (no_root_squash не сработает корректно), возможны проблемы с блокировками и производительностью.
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: gcr.forust.xyz
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-prettier:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check formatting with Prettier
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t prettier_files < <(
|
||||||
|
git ls-files \
|
||||||
|
| grep -E '\.(md|json|ya?ml|html|css)$' \
|
||||||
|
| grep -Ev '^(\.docs/|\.zed/|errorpages/html/|homepages/(forust_files|xdfnx_files)/)'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#prettier_files[@]}" -eq 0 ]; then
|
||||||
|
echo "No Prettier-managed files found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
node:22-alpine \
|
||||||
|
sh -lc 'npx --yes prettier@3 --check --ignore-unknown "$@"' sh "${prettier_files[@]}"
|
||||||
|
|
||||||
|
lint-ruff:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint Python with Ruff
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
ghcr.io/astral-sh/ruff:latest \
|
||||||
|
check .
|
||||||
|
|
||||||
|
lint-yaml:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint YAML syntax
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
cytopia/yamllint:latest \
|
||||||
|
-c .yamllint .
|
||||||
|
|
||||||
|
lint-dockerfiles:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint Dockerfiles
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t dockerfiles < <(
|
||||||
|
git ls-files ':(glob)**/Dockerfile' ':(glob)**/Dockerfile.*'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#dockerfiles[@]}" -eq 0 ]; then
|
||||||
|
echo "No Dockerfiles found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
--entrypoint hadolint \
|
||||||
|
hadolint/hadolint:latest-debian \
|
||||||
|
-c .hadolint.yaml "${dockerfiles[@]}"
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Kubernetes manifests
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t manifests < <(
|
||||||
|
git ls-files ':(glob)**/k8s/**/*.yaml' ':(glob)**/k8s/**/*.yml' \
|
||||||
|
| grep -Ev '(^|/)(kustomization\.ya?ml|.*\.example\.ya?ml|.*values\.ya?ml|patch-.*\.ya?ml)$'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#manifests[@]}" -eq 0 ]; then
|
||||||
|
echo "No Kubernetes manifests found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
ghcr.io/yannh/kubeconform:latest \
|
||||||
|
-strict \
|
||||||
|
-ignore-missing-schemas \
|
||||||
|
-summary \
|
||||||
|
"${manifests[@]}"
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: [lint-prettier, lint-ruff, lint-yaml, lint-dockerfiles, validate]
|
||||||
|
if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'dev')
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
outputs:
|
||||||
|
services: ${{ steps.services.outputs.services }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Detect changed docker-built services
|
||||||
|
id: services
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
base="${{ github.event.before }}"
|
||||||
|
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
|
||||||
|
base="$(git rev-list --max-parents=0 HEAD)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mapfile -t changed_files < <(git diff --name-only "$base" "${GITHUB_SHA}")
|
||||||
|
|
||||||
|
services=()
|
||||||
|
|
||||||
|
add_service() {
|
||||||
|
local name="$1"
|
||||||
|
local seen=0
|
||||||
|
for existing in "${services[@]}"; do
|
||||||
|
if [ "$existing" = "$name" ]; then
|
||||||
|
seen=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$seen" -eq 0 ]; then
|
||||||
|
services+=("$name")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for file in "${changed_files[@]}"; do
|
||||||
|
case "$file" in
|
||||||
|
dtek_notif/*)
|
||||||
|
add_service dtek_notif
|
||||||
|
;;
|
||||||
|
errorpages/*)
|
||||||
|
add_service errorpages
|
||||||
|
;;
|
||||||
|
userbot/*)
|
||||||
|
add_service userbot
|
||||||
|
;;
|
||||||
|
homepages/*)
|
||||||
|
add_service homepages
|
||||||
|
;;
|
||||||
|
edu_master/phpsessid-bot/*|edu_master/webinar-checker/*|edu_master/compose.yaml)
|
||||||
|
add_service edu_master
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "${#services[@]}" -eq 0 ]; then
|
||||||
|
echo "No docker-built services changed."
|
||||||
|
echo "services=" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s\n' "${services[@]}" | tee /tmp/services.txt
|
||||||
|
echo "services=$(paste -sd, /tmp/services.txt)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
if: steps.services.outputs.services != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \
|
||||||
|
-u "${{ secrets.REGISTRY_USERNAME }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
|
- name: Build and push changed images
|
||||||
|
if: steps.services.outputs.services != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
IFS=, read -r -a services <<< "${{ steps.services.outputs.services }}"
|
||||||
|
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
case "$service" in
|
||||||
|
dtek_notif)
|
||||||
|
image="${REGISTRY}/forust/dtek-notif"
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" dtek_notif
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
errorpages)
|
||||||
|
image="${REGISTRY}/forust/error-pages"
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" errorpages
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
userbot)
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
for target in runtime panel; do
|
||||||
|
case "$target" in
|
||||||
|
runtime)
|
||||||
|
context="userbot"
|
||||||
|
image="${REGISTRY}/forust/userbot"
|
||||||
|
;;
|
||||||
|
panel)
|
||||||
|
context="userbot/panel"
|
||||||
|
image="${REGISTRY}/forust/userbot-panel"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" "$context"
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
homepages)
|
||||||
|
for service in forust xdfnx; do
|
||||||
|
case "$service" in
|
||||||
|
forust)
|
||||||
|
image="${REGISTRY}/forust/forust-homepage"
|
||||||
|
;;
|
||||||
|
xdfnx)
|
||||||
|
image="${REGISTRY}/forust/xdfnx-homepage"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" -f "homepages/Dockerfile.${service}" homepages
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
edu_master)
|
||||||
|
for service in session-keeper webinar-checker; do
|
||||||
|
case "$service" in
|
||||||
|
session-keeper)
|
||||||
|
context="edu_master/phpsessid-bot"
|
||||||
|
image="${REGISTRY}/forust/session-keeper"
|
||||||
|
;;
|
||||||
|
webinar-checker)
|
||||||
|
context="edu_master/webinar-checker"
|
||||||
|
image="${REGISTRY}/forust/webinar-checker"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" "$context"
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
deploy-userbot-panel:
|
||||||
|
needs: build
|
||||||
|
if: github.ref_name == 'main' && contains(needs.build.outputs.services, 'userbot')
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab, prod]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Apply and roll out userbot panel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
kubectl apply -f userbot/k8s/base/panel.yaml
|
||||||
|
kubectl get secret userbot-common-secrets -n default -o json \
|
||||||
|
| jq 'del(.metadata.annotations,.metadata.creationTimestamp,.metadata.resourceVersion,.metadata.uid,.metadata.managedFields) | .metadata.namespace = "userbot"' \
|
||||||
|
| kubectl apply -f -
|
||||||
|
# Keep legacy deployments (forust/anna) in sync with manifests; they have no replicas field, so apply leaves scaling to the user manager only.
|
||||||
|
kubectl apply -f userbot/k8s/base/userbots.yaml
|
||||||
|
kubectl rollout restart deployment/userbot-panel -n userbot
|
||||||
|
kubectl rollout status deployment/userbot-panel -n userbot --timeout=180s
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
name: deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: deploy-main
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
redeploy:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab, prod]
|
||||||
|
steps:
|
||||||
|
- name: Redeploy workstation
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||||
|
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
# Set APPLY_PRUNE=true to enable kubectl apply --prune. Requires every
|
||||||
|
# manifest to carry label app.kubernetes.io/managed-by=homelab-deploy,
|
||||||
|
# otherwise previously applied resources get deleted on the next run.
|
||||||
|
APPLY_PRUNE: ${{ vars.APPLY_PRUNE }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${DEPLOY_HOST:?missing DEPLOY_HOST}"
|
||||||
|
: "${DEPLOY_USER:?missing DEPLOY_USER}"
|
||||||
|
: "${DEPLOY_KEY:?missing DEPLOY_SSH_KEY}"
|
||||||
|
|
||||||
|
deploy_port="${DEPLOY_PORT:-22}"
|
||||||
|
deploy_path="${DEPLOY_PATH:-/srv/homelab}"
|
||||||
|
|
||||||
|
ssh_key="$RUNNER_TEMP/deploy_key"
|
||||||
|
mkdir -p "$RUNNER_TEMP"
|
||||||
|
printf '%s\n' "$DEPLOY_KEY" > "$ssh_key"
|
||||||
|
chmod 600 "$ssh_key"
|
||||||
|
|
||||||
|
ssh_opts=(
|
||||||
|
-i "$ssh_key"
|
||||||
|
-p "$deploy_port"
|
||||||
|
-o BatchMode=yes
|
||||||
|
-o StrictHostKeyChecking=accept-new
|
||||||
|
)
|
||||||
|
|
||||||
|
ssh "${ssh_opts[@]}" "${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||||
|
"DEPLOY_PATH=$(printf '%q' \"$deploy_path\") APPLY_PRUNE=$(printf '%q' \"${APPLY_PRUNE:-false}\") bash -se" <<'EOF'
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repo="${DEPLOY_PATH:-/srv/homelab}"
|
||||||
|
|
||||||
|
if [ ! -d "$repo/.git" ]; then
|
||||||
|
echo "Repository not found at $repo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git -C "$repo" fetch origin main
|
||||||
|
git -C "$repo" reset --hard origin/main
|
||||||
|
|
||||||
|
# Runtime selection: a service is k8s-managed when $SERVICE/k8s/active
|
||||||
|
# exists. Otherwise it is compose-managed, and only k8s/routing/*
|
||||||
|
# manifests (external Services / EndpointSlices / ServersTransport /
|
||||||
|
# Ingresses that route to docker backends) are applied.
|
||||||
|
# migrate: touch SERVICE/k8s/active (+ move routing files up)
|
||||||
|
# rollback: rm SERVICE/k8s/active
|
||||||
|
collect_k8s() {
|
||||||
|
find "$1" -type f \( -name '*.yaml' -o -name '*.yml' \) \
|
||||||
|
! -path '*/routing/*' ! -path '*/overlays/*' \
|
||||||
|
! -name 'kustomization.y*ml' ! -name '*.example.y*ml' \
|
||||||
|
! -name '*values.y*ml' ! -name 'patch-*.y*ml' \
|
||||||
|
| sort
|
||||||
|
}
|
||||||
|
|
||||||
|
collect_k8s_inactive() {
|
||||||
|
find "$1" -type f \( -name '*.yaml' -o -name '*.yml' \) \
|
||||||
|
\( -name 'namespace.y*ml' -o -path '*/routing/*' \) \
|
||||||
|
! -path '*/overlays/*' ! -name '*.example.y*ml' \
|
||||||
|
| sort
|
||||||
|
}
|
||||||
|
|
||||||
|
mapfile -t compose_stacks < <(
|
||||||
|
find "$repo" -type f \( -name 'compose.yaml' -o -name 'compose.yml' \) | sort
|
||||||
|
)
|
||||||
|
|
||||||
|
mapfile -t k8s_manifests < <(
|
||||||
|
for kd in $(find "$repo" -type d -name k8s ! -path '*/.git/*' | sort); do
|
||||||
|
if [ -f "$kd/active" ]; then
|
||||||
|
collect_k8s "$kd"
|
||||||
|
else
|
||||||
|
collect_k8s_inactive "$kd"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "== Validate compose stacks =="
|
||||||
|
for cf in "${compose_stacks[@]}"; do
|
||||||
|
dir=$(dirname "$cf")
|
||||||
|
if [ -f "$dir/k8s/active" ]; then
|
||||||
|
echo " skip (k8s-managed): $dir"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo " config: $cf"
|
||||||
|
docker compose -f "$cf" config --quiet
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "== Validate k8s manifests (kubectl dry-run) =="
|
||||||
|
for m in "${k8s_manifests[@]}"; do
|
||||||
|
echo " apply --dry-run=client $m"
|
||||||
|
kubectl apply --dry-run=client -f "$m" >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "== Applying Kubernetes manifests =="
|
||||||
|
ns_files=()
|
||||||
|
other_files=()
|
||||||
|
for m in "${k8s_manifests[@]}"; do
|
||||||
|
case "$m" in
|
||||||
|
*/namespace.y?ml) ns_files+=("$m") ;;
|
||||||
|
*) other_files+=("$m") ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
prune_opts=()
|
||||||
|
if [ "${APPLY_PRUNE:-false}" = "true" ]; then
|
||||||
|
prune_opts=(--prune -l app.kubernetes.io/managed-by=homelab-deploy)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#ns_files[@]}" -gt 0 ]; then
|
||||||
|
echo " namespaces first: ${ns_files[*]}"
|
||||||
|
kubectl apply -f "${ns_files[@]}"
|
||||||
|
fi
|
||||||
|
if [ "${#other_files[@]}" -gt 0 ]; then
|
||||||
|
echo " resources: ${other_files[*]}"
|
||||||
|
kubectl apply "${prune_opts[@]}" -f "${other_files[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== Redeploying docker compose stacks =="
|
||||||
|
for cf in "${compose_stacks[@]}"; do
|
||||||
|
dir=$(dirname "$cf")
|
||||||
|
if [ -f "$dir/k8s/active" ]; then
|
||||||
|
echo " skip (k8s-managed): $dir"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo " compose: $dir"
|
||||||
|
if grep -Eq '^\s+pull_policy:\s*build\b' "$cf"; then
|
||||||
|
docker compose -f "$cf" build
|
||||||
|
docker compose -f "$cf" push
|
||||||
|
fi
|
||||||
|
docker compose -f "$cf" up -d --pull always --remove-orphans
|
||||||
|
done
|
||||||
|
EOF
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
name: Deploy to Server
|
|
||||||
run-name: Deploying to ${{ runner.os}} server on ${{ gitea.ref }}
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- ci/gitea-actions
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: prod
|
|
||||||
steps:
|
|
||||||
- name: Fetch and Diff Analysis
|
|
||||||
id: diff
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
git fetch origin main
|
|
||||||
CHANGES=$(git diff --name-only HEAD origin/main | cut -d/ -f1 | sort -u | tr '\n' ' ')
|
|
||||||
echo "dirs=$CHANGES" >> $GITHUB_OUTPUT
|
|
||||||
echo "Changed dirs: $CHANGES"
|
|
||||||
|
|
||||||
- name: Sync Server Files
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
git reset --hard origin/main
|
|
||||||
echo "Server files synced with origin/main"
|
|
||||||
|
|
||||||
- name: Deploy Services
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
for dir in ${{ steps.diff.outputs.dirs }}; do
|
|
||||||
if [ -d "$dir" ] && ([ -f "$dir/compose.yaml" ] || [ -f "$dir/docker-compose.yaml" ]); then
|
|
||||||
echo ">>> Deploying $dir"
|
|
||||||
cd "$dir"
|
|
||||||
DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=plain docker compose up -d --build --no-color
|
|
||||||
cd ..
|
|
||||||
else
|
|
||||||
echo ">>> Skipping $dir: no compose file found"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "**"
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: gcr.forust.xyz
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint-prettier:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check formatting with Prettier
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t prettier_files < <(
|
||||||
|
git ls-files \
|
||||||
|
| grep -E '\.(md|json|ya?ml|html|css)$' \
|
||||||
|
| grep -Ev '^(\.docs/|\.zed/|errorpages/html/|homepages/(forust_files|xdfnx_files)/)'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#prettier_files[@]}" -eq 0 ]; then
|
||||||
|
echo "No Prettier-managed files found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
node:22-alpine \
|
||||||
|
sh -lc 'npx --yes prettier@3 --check --ignore-unknown "$@"' sh "${prettier_files[@]}"
|
||||||
|
|
||||||
|
lint-ruff:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint Python with Ruff
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
ghcr.io/astral-sh/ruff:latest \
|
||||||
|
check .
|
||||||
|
|
||||||
|
lint-yaml:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint YAML syntax
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
cytopia/yamllint:latest \
|
||||||
|
-c .yamllint .
|
||||||
|
|
||||||
|
lint-dockerfiles:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Lint Dockerfiles
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t dockerfiles < <(
|
||||||
|
git ls-files ':(glob)**/Dockerfile' ':(glob)**/Dockerfile.*'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#dockerfiles[@]}" -eq 0 ]; then
|
||||||
|
echo "No Dockerfiles found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
--entrypoint hadolint \
|
||||||
|
hadolint/hadolint:latest-debian \
|
||||||
|
-c .hadolint.yaml "${dockerfiles[@]}"
|
||||||
|
|
||||||
|
validate:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate Kubernetes manifests
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mapfile -t manifests < <(
|
||||||
|
git ls-files ':(glob)**/k8s/**/*.yaml' ':(glob)**/k8s/**/*.yml' \
|
||||||
|
| grep -Ev '(^|/)(kustomization\.ya?ml|.*\.example\.ya?ml|.*values\.ya?ml|patch-.*\.ya?ml)$'
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ "${#manifests[@]}" -eq 0 ]; then
|
||||||
|
echo "No Kubernetes manifests found."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
-v "$PWD:/work" \
|
||||||
|
-w /work \
|
||||||
|
ghcr.io/yannh/kubeconform:latest \
|
||||||
|
-strict \
|
||||||
|
-ignore-missing-schemas \
|
||||||
|
-summary \
|
||||||
|
"${manifests[@]}"
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: [lint-prettier, lint-ruff, lint-yaml, lint-dockerfiles, validate]
|
||||||
|
if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'dev')
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab]
|
||||||
|
outputs:
|
||||||
|
services: ${{ steps.services.outputs.services }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Detect changed docker-built services
|
||||||
|
id: services
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
base="${{ github.event.before }}"
|
||||||
|
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then
|
||||||
|
base="$(git rev-list --max-parents=0 HEAD)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mapfile -t changed_files < <(git diff --name-only "$base" "${GITHUB_SHA}")
|
||||||
|
|
||||||
|
services=()
|
||||||
|
|
||||||
|
add_service() {
|
||||||
|
local name="$1"
|
||||||
|
local seen=0
|
||||||
|
for existing in "${services[@]}"; do
|
||||||
|
if [ "$existing" = "$name" ]; then
|
||||||
|
seen=1
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$seen" -eq 0 ]; then
|
||||||
|
services+=("$name")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for file in "${changed_files[@]}"; do
|
||||||
|
case "$file" in
|
||||||
|
dtek_notif/*)
|
||||||
|
add_service dtek_notif
|
||||||
|
;;
|
||||||
|
errorpages/*)
|
||||||
|
add_service errorpages
|
||||||
|
;;
|
||||||
|
userbot/*)
|
||||||
|
add_service userbot
|
||||||
|
;;
|
||||||
|
homepages/*)
|
||||||
|
add_service homepages
|
||||||
|
;;
|
||||||
|
edu_master/phpsessid-bot/*|edu_master/webinar-checker/*|edu_master/compose.yaml)
|
||||||
|
add_service edu_master
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "${#services[@]}" -eq 0 ]; then
|
||||||
|
echo "No docker-built services changed."
|
||||||
|
echo "services=" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
printf '%s\n' "${services[@]}" | tee /tmp/services.txt
|
||||||
|
echo "services=$(paste -sd, /tmp/services.txt)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
if: steps.services.outputs.services != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \
|
||||||
|
-u "${{ secrets.REGISTRY_USERNAME }}" \
|
||||||
|
--password-stdin
|
||||||
|
|
||||||
|
- name: Build and push changed images
|
||||||
|
if: steps.services.outputs.services != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
IFS=, read -r -a services <<< "${{ steps.services.outputs.services }}"
|
||||||
|
|
||||||
|
for service in "${services[@]}"; do
|
||||||
|
case "$service" in
|
||||||
|
dtek_notif)
|
||||||
|
image="${REGISTRY}/forust/dtek-notif"
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" dtek_notif
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
errorpages)
|
||||||
|
image="${REGISTRY}/forust/error-pages"
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" errorpages
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
userbot)
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
for target in runtime panel; do
|
||||||
|
case "$target" in
|
||||||
|
runtime)
|
||||||
|
context="userbot"
|
||||||
|
image="${REGISTRY}/forust/userbot"
|
||||||
|
;;
|
||||||
|
panel)
|
||||||
|
context="userbot/panel"
|
||||||
|
image="${REGISTRY}/forust/userbot-panel"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" "$context"
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
homepages)
|
||||||
|
for service in forust xdfnx; do
|
||||||
|
case "$service" in
|
||||||
|
forust)
|
||||||
|
image="${REGISTRY}/forust/forust-homepage"
|
||||||
|
;;
|
||||||
|
xdfnx)
|
||||||
|
image="${REGISTRY}/forust/xdfnx-homepage"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" -f "homepages/Dockerfile.${service}" homepages
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
edu_master)
|
||||||
|
for service in session-keeper webinar-checker; do
|
||||||
|
case "$service" in
|
||||||
|
session-keeper)
|
||||||
|
context="edu_master/phpsessid-bot"
|
||||||
|
image="${REGISTRY}/forust/session-keeper"
|
||||||
|
;;
|
||||||
|
webinar-checker)
|
||||||
|
context="edu_master/webinar-checker"
|
||||||
|
image="${REGISTRY}/forust/webinar-checker"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
tags=("latest")
|
||||||
|
case "${GITHUB_REF_NAME}" in
|
||||||
|
main)
|
||||||
|
tags+=("main" "prod")
|
||||||
|
;;
|
||||||
|
dev)
|
||||||
|
tags+=("dev")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
build_args=()
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
build_args+=(-t "${image}:${tag}")
|
||||||
|
done
|
||||||
|
docker build "${build_args[@]}" "$context"
|
||||||
|
for tag in "${tags[@]}"; do
|
||||||
|
docker push "${image}:${tag}"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
deploy-userbot-panel:
|
||||||
|
needs: build
|
||||||
|
if: github.ref_name == 'main' && contains(needs.build.outputs.services, 'userbot')
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab, prod]
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Apply and roll out userbot panel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
kubectl apply -f userbot/k8s/base/panel.yaml
|
||||||
|
kubectl get secret userbot-common-secrets -n default -o json \
|
||||||
|
| jq 'del(.metadata.annotations,.metadata.creationTimestamp,.metadata.resourceVersion,.metadata.uid,.metadata.managedFields) | .metadata.namespace = "userbot"' \
|
||||||
|
| kubectl apply -f -
|
||||||
|
# Keep legacy deployments (forust/anna) in sync with manifests; they have no replicas field, so apply leaves scaling to the user manager only.
|
||||||
|
kubectl apply -f userbot/k8s/base/userbots.yaml
|
||||||
|
kubectl rollout restart deployment/userbot-panel -n userbot
|
||||||
|
kubectl rollout status deployment/userbot-panel -n userbot --timeout=180s
|
||||||
@@ -0,0 +1,152 @@
|
|||||||
|
name: deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: deploy-main
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
redeploy:
|
||||||
|
runs-on: [self-hosted, linux, arch, homelab, prod]
|
||||||
|
steps:
|
||||||
|
- name: Redeploy workstation
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
|
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
|
||||||
|
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||||
|
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||||
|
DEPLOY_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||||
|
# Set APPLY_PRUNE=true to enable kubectl apply --prune. Requires every
|
||||||
|
# manifest to carry label app.kubernetes.io/managed-by=homelab-deploy,
|
||||||
|
# otherwise previously applied resources get deleted on the next run.
|
||||||
|
APPLY_PRUNE: ${{ vars.APPLY_PRUNE }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${DEPLOY_HOST:?missing DEPLOY_HOST}"
|
||||||
|
: "${DEPLOY_USER:?missing DEPLOY_USER}"
|
||||||
|
: "${DEPLOY_KEY:?missing DEPLOY_SSH_KEY}"
|
||||||
|
|
||||||
|
deploy_port="${DEPLOY_PORT:-22}"
|
||||||
|
deploy_path="${DEPLOY_PATH:-/srv/homelab}"
|
||||||
|
|
||||||
|
ssh_key="$RUNNER_TEMP/deploy_key"
|
||||||
|
mkdir -p "$RUNNER_TEMP"
|
||||||
|
printf '%s\n' "$DEPLOY_KEY" > "$ssh_key"
|
||||||
|
chmod 600 "$ssh_key"
|
||||||
|
|
||||||
|
ssh_opts=(
|
||||||
|
-i "$ssh_key"
|
||||||
|
-p "$deploy_port"
|
||||||
|
-o BatchMode=yes
|
||||||
|
-o StrictHostKeyChecking=accept-new
|
||||||
|
)
|
||||||
|
|
||||||
|
ssh "${ssh_opts[@]}" "${DEPLOY_USER}@${DEPLOY_HOST}" \
|
||||||
|
"DEPLOY_PATH=$(printf '%q' \"$deploy_path\") APPLY_PRUNE=$(printf '%q' \"${APPLY_PRUNE:-false}\") bash -se" <<'EOF'
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repo="${DEPLOY_PATH:-/srv/homelab}"
|
||||||
|
|
||||||
|
if [ ! -d "$repo/.git" ]; then
|
||||||
|
echo "Repository not found at $repo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git -C "$repo" fetch origin main
|
||||||
|
git -C "$repo" reset --hard origin/main
|
||||||
|
|
||||||
|
# Runtime selection: a service is k8s-managed when $SERVICE/k8s/active
|
||||||
|
# exists. Otherwise it is compose-managed, and only k8s/routing/*
|
||||||
|
# manifests (external Services / EndpointSlices / ServersTransport /
|
||||||
|
# Ingresses that route to docker backends) are applied.
|
||||||
|
# migrate: touch SERVICE/k8s/active (+ move routing files up)
|
||||||
|
# rollback: rm SERVICE/k8s/active
|
||||||
|
collect_k8s() {
|
||||||
|
find "$1" -type f \( -name '*.yaml' -o -name '*.yml' \) \
|
||||||
|
! -path '*/routing/*' ! -path '*/overlays/*' \
|
||||||
|
! -name 'kustomization.y*ml' ! -name '*.example.y*ml' \
|
||||||
|
! -name '*values.y*ml' ! -name 'patch-*.y*ml' \
|
||||||
|
| sort
|
||||||
|
}
|
||||||
|
|
||||||
|
collect_k8s_inactive() {
|
||||||
|
find "$1" -type f \( -name '*.yaml' -o -name '*.yml' \) \
|
||||||
|
\( -name 'namespace.y*ml' -o -path '*/routing/*' \) \
|
||||||
|
! -path '*/overlays/*' ! -name '*.example.y*ml' \
|
||||||
|
| sort
|
||||||
|
}
|
||||||
|
|
||||||
|
mapfile -t compose_stacks < <(
|
||||||
|
find "$repo" -type f \( -name 'compose.yaml' -o -name 'compose.yml' \) | sort
|
||||||
|
)
|
||||||
|
|
||||||
|
mapfile -t k8s_manifests < <(
|
||||||
|
for kd in $(find "$repo" -type d -name k8s ! -path '*/.git/*' | sort); do
|
||||||
|
if [ -f "$kd/active" ]; then
|
||||||
|
collect_k8s "$kd"
|
||||||
|
else
|
||||||
|
collect_k8s_inactive "$kd"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "== Validate compose stacks =="
|
||||||
|
for cf in "${compose_stacks[@]}"; do
|
||||||
|
dir=$(dirname "$cf")
|
||||||
|
if [ -f "$dir/k8s/active" ]; then
|
||||||
|
echo " skip (k8s-managed): $dir"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo " config: $cf"
|
||||||
|
docker compose -f "$cf" config --quiet
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "== Validate k8s manifests (kubectl dry-run) =="
|
||||||
|
for m in "${k8s_manifests[@]}"; do
|
||||||
|
echo " apply --dry-run=client $m"
|
||||||
|
kubectl apply --dry-run=client -f "$m" >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "== Applying Kubernetes manifests =="
|
||||||
|
ns_files=()
|
||||||
|
other_files=()
|
||||||
|
for m in "${k8s_manifests[@]}"; do
|
||||||
|
case "$m" in
|
||||||
|
*/namespace.y?ml) ns_files+=("$m") ;;
|
||||||
|
*) other_files+=("$m") ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
prune_opts=()
|
||||||
|
if [ "${APPLY_PRUNE:-false}" = "true" ]; then
|
||||||
|
prune_opts=(--prune -l app.kubernetes.io/managed-by=homelab-deploy)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${#ns_files[@]}" -gt 0 ]; then
|
||||||
|
echo " namespaces first: ${ns_files[*]}"
|
||||||
|
kubectl apply -f "${ns_files[@]}"
|
||||||
|
fi
|
||||||
|
if [ "${#other_files[@]}" -gt 0 ]; then
|
||||||
|
echo " resources: ${other_files[*]}"
|
||||||
|
kubectl apply "${prune_opts[@]}" -f "${other_files[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== Redeploying docker compose stacks =="
|
||||||
|
for cf in "${compose_stacks[@]}"; do
|
||||||
|
dir=$(dirname "$cf")
|
||||||
|
if [ -f "$dir/k8s/active" ]; then
|
||||||
|
echo " skip (k8s-managed): $dir"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo " compose: $dir"
|
||||||
|
if grep -Eq '^\s+pull_policy:\s*build\b' "$cf"; then
|
||||||
|
docker compose -f "$cf" build
|
||||||
|
docker compose -f "$cf" push
|
||||||
|
fi
|
||||||
|
docker compose -f "$cf" up -d --pull always --remove-orphans
|
||||||
|
done
|
||||||
|
EOF
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
## BINARY MODE, USE WITH THE GITHUB RUNNER BINARY INSTALLED ON THE SERVER
|
|
||||||
|
|
||||||
name: Deploy to Server
|
|
||||||
run-name: Deploying onto server on ${{ github.ref }}
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- ci/actions
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: [prod, self-hosted]
|
|
||||||
steps:
|
|
||||||
- name: Fetch and Diff Analysis
|
|
||||||
id: diff
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
git fetch origin main
|
|
||||||
CHANGES=$(git diff --name-only HEAD origin/main | cut -d/ -f1 | sort -u | tr '\n' ' ')
|
|
||||||
echo "dirs=$CHANGES" >> $GITHUB_OUTPUT
|
|
||||||
echo "Changed dirs: $CHANGES"
|
|
||||||
|
|
||||||
- name: Sync Server Files
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
git reset --hard origin/main
|
|
||||||
echo "Server files synced with origin/main"
|
|
||||||
|
|
||||||
- name: Deploy Services
|
|
||||||
run: |
|
|
||||||
cd ${{ secrets.PROD_DIR }}
|
|
||||||
for dir in ${{ steps.diff.outputs.dirs }}; do
|
|
||||||
if [ -d "$dir" ] && ([ -f "$dir/compose.yaml" ] || [ -f "$dir/docker-compose.yaml" ]); then
|
|
||||||
echo ">>> Deploying $dir"
|
|
||||||
cd "$dir"
|
|
||||||
DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=plain docker compose up -d --build --no-color
|
|
||||||
cd ..
|
|
||||||
else
|
|
||||||
echo ">>> Skipping $dir: no compose file found"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
+1
-2
@@ -40,7 +40,7 @@ traefik/letsencrypt/acme.json
|
|||||||
traefik/dynamic/fileservers.yml
|
traefik/dynamic/fileservers.yml
|
||||||
traefik/dynamic/*.local.y*ml.*
|
traefik/dynamic/*.local.y*ml.*
|
||||||
traefik/dynamic/*.external.y*ml
|
traefik/dynamic/*.external.y*ml
|
||||||
|
traefik/k8s/fileservers.y*ml
|
||||||
|
|
||||||
traefik/logs/*
|
traefik/logs/*
|
||||||
|
|
||||||
@@ -106,4 +106,3 @@ temp/*
|
|||||||
traefik/k8s/local-tls.yaml
|
traefik/k8s/local-tls.yaml
|
||||||
converters/k8s/config.yaml
|
converters/k8s/config.yaml
|
||||||
convertx/k8s/config.yaml
|
convertx/k8s/config.yaml
|
||||||
traefik/k8s/crowdsec-middleware.yaml
|
|
||||||
|
|||||||
+13
-12
@@ -9,31 +9,32 @@
|
|||||||
"hard_tabs": false,
|
"hard_tabs": false,
|
||||||
"format_on_save": "on",
|
"format_on_save": "on",
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"language_server": { "name": "yaml-language-server" }
|
"language_server": { "name": "yaml-language-server" },
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"Python": {
|
"Python": {
|
||||||
"tab_size": 4,
|
"tab_size": 4,
|
||||||
"format_on_save": "on",
|
"format_on_save": "on",
|
||||||
|
"language_servers": ["pyright", "ruff"],
|
||||||
"formatter": {
|
"formatter": {
|
||||||
"language_server": { "name": "ruff" }
|
"language_server": { "name": "ruff" },
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
"lsp": {
|
"lsp": {
|
||||||
"yaml-language-server": {
|
"yaml-language-server": {
|
||||||
"settings": {
|
"settings": {
|
||||||
"yaml": {
|
"yaml": {
|
||||||
"schemas": {
|
"schemas": {
|
||||||
"kubernetes": ["**/k8s/*.yaml", "**/k8s/*.yml"]
|
"kubernetes": ["**/k8s/*.yaml", "**/k8s/*.yml"],
|
||||||
},
|
},
|
||||||
"validate": true,
|
"validate": true,
|
||||||
"completion": true,
|
"completion": true,
|
||||||
"format": {
|
"format": {
|
||||||
"enable": true
|
"enable": true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,11 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`adguard.forust.xyz`) || Host(`dns.forust.xyz`)
|
- match: Host(`adguard.forust.xyz`) || Host(`dns.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
services:
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
- name: adguard-service
|
||||||
|
port: 3000
|
||||||
|
- match: (Host(`adguard.forust.xyz`) || Host(`dns.forust.xyz`)) && PathPrefix(`/dns-query`)
|
||||||
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: adguard-service
|
- name: adguard-service
|
||||||
port: 3000
|
port: 3000
|
||||||
@@ -31,22 +34,8 @@ spec:
|
|||||||
services:
|
services:
|
||||||
- name: adguard-service
|
- name: adguard-service
|
||||||
port: 3000
|
port: 3000
|
||||||
---
|
- match: (Host(`adguard.workstation.internal`) || Host(`dns.workstation.internal`) || Host(`adguard.gigaforust.internal`) || Host(`dns.gigaforust.internal`)) && PathPrefix(`/dns-query`)
|
||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: IngressRoute
|
|
||||||
metadata:
|
|
||||||
name: adguard-doh
|
|
||||||
namespace: adguard
|
|
||||||
spec:
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
|
||||||
- match: (Host(`adguard.forust.xyz`) || Host(`dns.forust.xyz`)) && PathPrefix(`/dns-query`)
|
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: adguard-service
|
- name: adguard-service
|
||||||
port: 3000
|
port: 3000
|
||||||
tls:
|
|
||||||
certResolver: letsencrypt
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`auth.forust.xyz`)
|
- match: Host(`auth.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: authentik-server-service
|
- name: authentik-server-service
|
||||||
port: 9000
|
port: 9000
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"api_key": {
|
"api_key": {
|
||||||
"api_key": "api_key_here",
|
"api_key": "api_key_here",
|
||||||
"account_email": "your_email_here"
|
"account_email": "your_email_here"
|
||||||
}
|
},
|
||||||
"zone_id": "your_zone-id",
|
"zone_id": "your_zone-id",
|
||||||
"subdomains": [
|
"subdomains": [
|
||||||
{ "name": "", "proxied": true },
|
{ "name": "", "proxied": true },
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`cmk.forust.xyz`)
|
- match: Host(`cmk.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: checkmk-service
|
- name: checkmk-service
|
||||||
port: 5000
|
port: 5000
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: Middleware
|
|
||||||
metadata:
|
|
||||||
name: crowdsec-bouncer
|
|
||||||
namespace: crowdsec
|
|
||||||
spec:
|
|
||||||
plugin:
|
|
||||||
crowdsec-bouncer:
|
|
||||||
enabled: true
|
|
||||||
LogLevel: INFO
|
|
||||||
CrowdsecMode: live
|
|
||||||
CrowdsecLapiScheme: http
|
|
||||||
CrowdsecLapiHost: crowdsec-service.crowdsec.svc.cluster.local:8080
|
|
||||||
CrowdsecLapiKeyFile: "/etc/traefik/secrets/traefik-api-key"
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
container_runtime: containerd
|
|
||||||
agent:
|
|
||||||
env:
|
|
||||||
- name: COLLECTIONS
|
|
||||||
value: "crowdsecurity/traefik crowdsecurity/base-http-scenarios crowdsecurity/sshd"
|
|
||||||
extraVolumes:
|
|
||||||
- name: journal-dir
|
|
||||||
hostPath:
|
|
||||||
path: /var/log/journal
|
|
||||||
type: DirectoryOrCreate
|
|
||||||
- name: run-journal-dir
|
|
||||||
hostPath:
|
|
||||||
path: /run/log/journal
|
|
||||||
type: DirectoryOrCreate
|
|
||||||
extraVolumeMounts:
|
|
||||||
- name: journal-dir
|
|
||||||
mountPath: /var/log/journal
|
|
||||||
readOnly: true
|
|
||||||
- name: run-journal-dir
|
|
||||||
mountPath: /run/log/journal
|
|
||||||
readOnly: true
|
|
||||||
|
|
||||||
acquisition:
|
|
||||||
- namespace: traefik
|
|
||||||
podName: "*traefik*"
|
|
||||||
program: traefik
|
|
||||||
poll_without_inotify: true
|
|
||||||
|
|
||||||
acquisitionCustom: |
|
|
||||||
- source: journalctl
|
|
||||||
journalctl_filter:
|
|
||||||
- _SYSTEMD_UNIT=sshd.service
|
|
||||||
labels:
|
|
||||||
type: syslog
|
|
||||||
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 100Mi
|
|
||||||
limits:
|
|
||||||
cpu: 200m
|
|
||||||
memory: 500Mi
|
|
||||||
|
|
||||||
lapi:
|
|
||||||
env:
|
|
||||||
- name: COLLECTIONS
|
|
||||||
value: "crowdsecurity/traefik crowdsecurity/base-http-scenarios crowdsecurity/sshd"
|
|
||||||
service:
|
|
||||||
type: NodePort
|
|
||||||
nodePort: 30011
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 150Mi
|
|
||||||
limits:
|
|
||||||
cpu: 200m
|
|
||||||
memory: 500Mi
|
|
||||||
@@ -18,7 +18,6 @@ spec:
|
|||||||
- match: Host(`dockmon.forust.xyz`)
|
- match: Host(`dockmon.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
- name: security-headers@file
|
- name: security-headers@file
|
||||||
services:
|
services:
|
||||||
- name: dockmon-service
|
- name: dockmon-service
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ spec:
|
|||||||
- match: Host(`downtify.forust.xyz`)
|
- match: Host(`downtify.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
- name: security-chain@file
|
- name: security-chain@file
|
||||||
services:
|
services:
|
||||||
- name: downtify-service
|
- name: downtify-service
|
||||||
|
|||||||
+284
-314
File diff suppressed because it is too large
Load Diff
@@ -9,5 +9,6 @@ WEBINAR_CHECK_INTERVAL=60
|
|||||||
REDIS_HOST=redis
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
PLAYWRIGHT_WS=ws://playwright-service:3000/ws
|
PLAYWRIGHT_WS=ws://playwright-service:3000/ws
|
||||||
|
TZ=Europe/Kyiv
|
||||||
WEBINAR_TELEGRAM_TOKEN=your_telegram_bot_token_here
|
WEBINAR_TELEGRAM_TOKEN=your_telegram_bot_token_here
|
||||||
WEBINAR_ADMIN_ID=123456789
|
WEBINAR_ADMIN_ID=123456789
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: edu-master
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: playwright-service
|
||||||
|
namespace: edu-master
|
||||||
|
labels:
|
||||||
|
app: edu-master-playwright
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: edu-master-playwright
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: edu-master-playwright
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: playwright
|
||||||
|
image: mcr.microsoft.com/playwright:v1.56.0-jammy
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- npx
|
||||||
|
- -y
|
||||||
|
- playwright@1.56.0
|
||||||
|
- run-server
|
||||||
|
- --port
|
||||||
|
- "3000"
|
||||||
|
- --path
|
||||||
|
- /ws
|
||||||
|
ports:
|
||||||
|
- containerPort: 3000
|
||||||
|
readinessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 3000
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 3000
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 20
|
||||||
|
timeoutSeconds: 3
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: playwright-service
|
||||||
|
namespace: edu-master
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: edu-master-playwright
|
||||||
|
ports:
|
||||||
|
- name: ws
|
||||||
|
port: 3000
|
||||||
|
targetPort: 3000
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: redis
|
||||||
|
namespace: edu-master
|
||||||
|
labels:
|
||||||
|
app: edu-master-redis
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: edu-master-redis
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: edu-master-redis
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: redis:alpine
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- containerPort: 6379
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: /data
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 25m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 256Mi
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["redis-cli", "ping"]
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
timeoutSeconds: 3
|
||||||
|
livenessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["redis-cli", "ping"]
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
volumes:
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: redis-data-pvc
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: redis-data-pvc
|
||||||
|
namespace: edu-master
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 1Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: redis
|
||||||
|
namespace: edu-master
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app: edu-master-redis
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
port: 6379
|
||||||
|
targetPort: 6379
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
# One-time Job to migrate redis state from docker compose to k8s (maintenance window).
|
||||||
|
# The .example file is not applied by the deploy pipeline (mask *.example.yaml).
|
||||||
|
#
|
||||||
|
# Runbook:
|
||||||
|
# 1. docker compose -f <repo>/edu_master/compose.yaml stop # SIGTERM -> redis will flush dump.rdb
|
||||||
|
# 2. docker run --rm -v edu_master_redis-data:/data \
|
||||||
|
# -v /tmp/edu-master-backup:/backup \
|
||||||
|
# redis:alpine sh -c "cp /data/dump.rdb /backup/ && ls -la /backup"
|
||||||
|
# 3. kubectl apply -f edu_master/k8s/namespace.yaml
|
||||||
|
# 4. kubectl apply -f <only the PVC from redis.yaml> # seed must come BEFORE redis pod starts
|
||||||
|
# 5. kubectl apply -f edu_master/k8s/restore-seed-job.yaml.example
|
||||||
|
# kubectl wait --for=condition=complete job/redis-restore-seed -n edu-master --timeout=120s
|
||||||
|
# 6. kubectl delete job redis-restore-seed -n edu-master
|
||||||
|
# 7. kubectl apply -f edu_master/k8s/ -R # apply remaining manifests
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: redis-restore-seed
|
||||||
|
namespace: edu-master
|
||||||
|
spec:
|
||||||
|
backoffLimit: 2
|
||||||
|
ttlSecondsAfterFinished: 3600
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: seed
|
||||||
|
image: redis:alpine
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
ls -la /backup
|
||||||
|
cp /backup/dump.rdb /data/dump.rdb
|
||||||
|
chmod 644 /data/dump.rdb
|
||||||
|
ls -la /data
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: /data
|
||||||
|
- name: backup
|
||||||
|
mountPath: /backup
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: redis-data-pvc
|
||||||
|
- name: backup
|
||||||
|
hostPath:
|
||||||
|
path: /tmp/edu-master-backup
|
||||||
|
type: DirectoryOrCreate
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: edu-master-secrets
|
||||||
|
namespace: edu-master
|
||||||
|
type: Opaque
|
||||||
|
stringData:
|
||||||
|
# Session keeper credentials
|
||||||
|
KEEPER_LOGIN: ""
|
||||||
|
KEEPER_PASSWORD: ""
|
||||||
|
KEEPER_INTERVAL: "10"
|
||||||
|
# EDU links
|
||||||
|
EDU_URL_BASE: "https://edu.edu.vn.ua"
|
||||||
|
EDU_URL_LOGIN: "/user/login"
|
||||||
|
EDU_URL_COURSES: "/course/userlist"
|
||||||
|
EDU_URL_WEBINAR: "/webinar/useractive"
|
||||||
|
# Playwright
|
||||||
|
USER_AGENT: ""
|
||||||
|
PLAYWRIGHT_WS: "ws://playwright-service:3000/ws"
|
||||||
|
# Webinar-checker
|
||||||
|
WEBINAR_TELEGRAM_TOKEN: ""
|
||||||
|
WEBINAR_ADMIN_ID: ""
|
||||||
|
WEBINAR_CHECK_INTERVAL: "60"
|
||||||
|
# Database
|
||||||
|
REDIS_HOST: "redis"
|
||||||
|
REDIS_PORT: "6379"
|
||||||
|
TZ: "Europe/Kyiv"
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: session-keeper
|
||||||
|
namespace: edu-master
|
||||||
|
labels:
|
||||||
|
app: edu-master-session-keeper
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: edu-master-session-keeper
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: edu-master-session-keeper
|
||||||
|
spec:
|
||||||
|
initContainers:
|
||||||
|
- name: wait-redis
|
||||||
|
image: redis:alpine
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
i=0
|
||||||
|
until redis-cli -h redis ping | grep -q PONG; do
|
||||||
|
i=$((i+1))
|
||||||
|
[ "$i" -ge 300 ] && echo "TIMEOUT: redis not ready" && exit 1
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "redis is ready"
|
||||||
|
containers:
|
||||||
|
- name: session-keeper
|
||||||
|
image: gcr.forust.xyz/forust/session-keeper:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: edu-master-secrets
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 25m
|
||||||
|
memory: 96Mi
|
||||||
|
limits:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 256Mi
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["/bin/sh", "-ec", "redis-cli -h redis EXISTS EDU_PHPSESSID | grep -q 1"]
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 10
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: webinar-checker
|
||||||
|
namespace: edu-master
|
||||||
|
labels:
|
||||||
|
app: edu-master-webinar-checker
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: edu-master-webinar-checker
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: edu-master-webinar-checker
|
||||||
|
spec:
|
||||||
|
# Enforces dependency order like compose depends_on:
|
||||||
|
# redis healthy -> session-keeper healthy (EXISTS EDU_PHPSESSID) -> playwright started
|
||||||
|
initContainers:
|
||||||
|
- name: wait-deps
|
||||||
|
image: redis:alpine
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
i=0
|
||||||
|
until redis-cli -h redis ping | grep -q PONG; do
|
||||||
|
i=$((i+1))
|
||||||
|
[ "$i" -ge 300 ] && echo "TIMEOUT: redis not ready" && exit 1
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "redis ok"
|
||||||
|
until [ "$(redis-cli -h redis EXISTS EDU_PHPSESSID)" = "1" ]; do
|
||||||
|
i=$((i+1))
|
||||||
|
[ "$i" -ge 300 ] && echo "TIMEOUT: no PHPSESSID (session-keeper down?)" && exit 1
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "PHPSESSID ok"
|
||||||
|
until nc -z playwright-service 3000; do
|
||||||
|
i=$((i+1))
|
||||||
|
[ "$i" -ge 300 ] && echo "TIMEOUT: playwright-service not reachable" && exit 1
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "playwright ok"
|
||||||
|
containers:
|
||||||
|
- name: webinar-checker
|
||||||
|
image: gcr.forust.xyz/forust/webinar-checker:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: edu-master-secrets
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: "Europe/Kyiv"
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 25m
|
||||||
|
memory: 128Mi
|
||||||
|
limits:
|
||||||
|
cpu: 300m
|
||||||
|
memory: 384Mi
|
||||||
@@ -3,10 +3,10 @@ FROM python:3.11-slim
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install system dependencies
|
# Install system dependencies
|
||||||
RUN apt-get update && apt-get install -y redis-tools && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y --no-install-recommends redis-tools && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pip install requests redis
|
RUN pip install --no-cache-dir requests==2.32.3 redis==5.2.1
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import requests
|
|
||||||
import logging
|
|
||||||
import redis
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import redis
|
||||||
|
import requests
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||||
level=logging.INFO,
|
|
||||||
format='%(asctime)s - %(levelname)s - %(message)s'
|
|
||||||
)
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# Load configuration (adapted to .env keys)
|
# Load configuration (adapted to .env keys)
|
||||||
def _env(key, default=None):
|
def _env(key, default=None):
|
||||||
v = os.getenv(key, default)
|
v = os.getenv(key, default)
|
||||||
@@ -19,21 +18,26 @@ def _env(key, default=None):
|
|||||||
return v[1:-1]
|
return v[1:-1]
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
LOGIN = _env('KEEPER_LOGIN')
|
LOGIN = _env('KEEPER_LOGIN')
|
||||||
PASSWORD = _env('KEEPER_PASSWORD')
|
PASSWORD = _env('KEEPER_PASSWORD')
|
||||||
|
|
||||||
EDU_BASE = _env('EDU_URL_BASE', 'https://edu.edu.vn.ua')
|
EDU_BASE = _env('EDU_URL_BASE', 'https://edu.edu.vn.ua')
|
||||||
EDU_LOGIN_PATH = _env('EDU_URL_LOGIN', '/user/login')
|
EDU_LOGIN_PATH = _env('EDU_URL_LOGIN', '/user/login')
|
||||||
EDU_COURSES_PATH = _env('EDU_URL_COURSES', '/course/userlist')
|
EDU_COURSES_PATH = _env('EDU_URL_COURSES', '/course/userlist')
|
||||||
URL_LOGIN = f"{EDU_BASE.rstrip('/')}/{EDU_LOGIN_PATH.lstrip('/')}"
|
URL_LOGIN = f'{EDU_BASE.rstrip("/")}/{EDU_LOGIN_PATH.lstrip("/")}'
|
||||||
URL_VERIFY = f"{EDU_BASE.rstrip('/')}/{EDU_COURSES_PATH.lstrip('/')}"
|
URL_VERIFY = f'{EDU_BASE.rstrip("/")}/{EDU_COURSES_PATH.lstrip("/")}'
|
||||||
|
|
||||||
INTERVAL = int(_env('KEEPER_INTERVAL', 10))
|
INTERVAL = int(_env('KEEPER_INTERVAL', 10))
|
||||||
USER_AGENT = _env('USER_AGENT', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36')
|
USER_AGENT = _env(
|
||||||
|
'USER_AGENT',
|
||||||
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
|
||||||
|
)
|
||||||
REDIS_HOST = _env('REDIS_HOST', 'redis')
|
REDIS_HOST = _env('REDIS_HOST', 'redis')
|
||||||
REDIS_PORT = int(_env('REDIS_PORT', 6379))
|
REDIS_PORT = int(_env('REDIS_PORT', 6379))
|
||||||
|
|
||||||
SUCCESS_FILE = '/tmp/last_success'
|
SUCCESS_FILE = '/tmp/last_success' # noqa: S108
|
||||||
|
|
||||||
|
|
||||||
def touch_success_file():
|
def touch_success_file():
|
||||||
"""Updates the timestamp of the success file for healthchecks."""
|
"""Updates the timestamp of the success file for healthchecks."""
|
||||||
@@ -41,18 +45,19 @@ def touch_success_file():
|
|||||||
with open(SUCCESS_FILE, 'w') as f:
|
with open(SUCCESS_FILE, 'w') as f:
|
||||||
f.write(str(datetime.now().timestamp()))
|
f.write(str(datetime.now().timestamp()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to touch success file: {e}")
|
logger.error(f'Failed to touch success file: {e}')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logger.info("Starting Session Keeper Bot")
|
logger.info('Starting Session Keeper Bot')
|
||||||
|
|
||||||
# Connect to Redis
|
# Connect to Redis
|
||||||
try:
|
try:
|
||||||
redis_client = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, decode_responses=True)
|
redis_client = redis.Redis(host=REDIS_HOST, port=REDIS_PORT, decode_responses=True)
|
||||||
redis_client.ping()
|
redis_client.ping()
|
||||||
logger.info(f"Connected to Redis at {REDIS_HOST}:{REDIS_PORT}")
|
logger.info(f'Connected to Redis at {REDIS_HOST}:{REDIS_PORT}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to connect to Redis: {e}")
|
logger.error(f'Failed to connect to Redis: {e}')
|
||||||
return
|
return
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
@@ -72,19 +77,16 @@ def main():
|
|||||||
'Sec-Ch-Ua-Mobile': '?0',
|
'Sec-Ch-Ua-Mobile': '?0',
|
||||||
'Sec-Ch-Ua-Platform': '"Linux"',
|
'Sec-Ch-Ua-Platform': '"Linux"',
|
||||||
'Accept-Encoding': 'gzip, deflate, br',
|
'Accept-Encoding': 'gzip, deflate, br',
|
||||||
'Priority': 'u=0, i'
|
'Priority': 'u=0, i',
|
||||||
}
|
}
|
||||||
session.headers.update(headers)
|
session.headers.update(headers)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
logger.info("Attempting login...")
|
logger.info('Attempting login...')
|
||||||
|
|
||||||
# Login payload
|
# Login payload
|
||||||
payload = {
|
payload = {'login': LOGIN, 'password': PASSWORD}
|
||||||
'login': LOGIN,
|
|
||||||
'password': PASSWORD
|
|
||||||
}
|
|
||||||
|
|
||||||
# Perform Login
|
# Perform Login
|
||||||
# Note: The user request shows a POST to /user/login with form data
|
# Note: The user request shows a POST to /user/login with form data
|
||||||
@@ -93,17 +95,17 @@ def main():
|
|||||||
|
|
||||||
login_response = session.post(URL_LOGIN, data=payload, allow_redirects=True)
|
login_response = session.post(URL_LOGIN, data=payload, allow_redirects=True)
|
||||||
|
|
||||||
logger.info(f"Login Response Status: {login_response.status_code}")
|
logger.info(f'Login Response Status: {login_response.status_code}')
|
||||||
logger.info(f"Cookies after login: {session.cookies.get_dict()}")
|
logger.info(f'Cookies after login: {session.cookies.get_dict()}')
|
||||||
|
|
||||||
# Verify Session
|
# Verify Session
|
||||||
logger.info("Verifying session...")
|
logger.info('Verifying session...')
|
||||||
verify_response = session.get(URL_VERIFY, allow_redirects=False)
|
verify_response = session.get(URL_VERIFY, allow_redirects=False)
|
||||||
|
|
||||||
logger.info(f"Verify Response Status: {verify_response.status_code}")
|
logger.info(f'Verify Response Status: {verify_response.status_code}')
|
||||||
|
|
||||||
if verify_response.status_code == 200:
|
if verify_response.status_code == 200:
|
||||||
logger.info("Session verification SUCCESS (200 OK).")
|
logger.info('Session verification SUCCESS (200 OK).')
|
||||||
touch_success_file()
|
touch_success_file()
|
||||||
|
|
||||||
# Save PHPSESSID to Redis
|
# Save PHPSESSID to Redis
|
||||||
@@ -111,19 +113,20 @@ def main():
|
|||||||
if phpsessid:
|
if phpsessid:
|
||||||
try:
|
try:
|
||||||
redis_client.set('EDU_PHPSESSID', phpsessid)
|
redis_client.set('EDU_PHPSESSID', phpsessid)
|
||||||
logger.info(f"Saved PHPSESSID to Redis: {phpsessid}")
|
logger.info(f'Saved PHPSESSID to Redis: {phpsessid}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Failed to save PHPSESSID to Redis: {e}")
|
logger.error(f'Failed to save PHPSESSID to Redis: {e}')
|
||||||
elif verify_response.status_code == 302:
|
elif verify_response.status_code == 302:
|
||||||
logger.warning("Session verification FAILED (302 Redirect). Session might be invalid.")
|
logger.warning('Session verification FAILED (302 Redirect). Session might be invalid.')
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Session verification returned unexpected status: {verify_response.status_code}")
|
logger.warning(f'Session verification returned unexpected status: {verify_response.status_code}')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"An error occurred: {e}")
|
logger.error(f'An error occurred: {e}')
|
||||||
|
|
||||||
logger.info(f"Sleeping for {INTERVAL} minutes...")
|
logger.info(f'Sleeping for {INTERVAL} minutes...')
|
||||||
time.sleep(INTERVAL * 60)
|
time.sleep(INTERVAL * 60)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ FROM python:3.11-slim
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
RUN pip install --upgrade pip && pip install playwright==1.56.0 redis requests "python-telegram-bot[job-queue]"
|
RUN pip install --no-cache-dir pip==25.0.1 && pip install --no-cache-dir playwright==1.56.0 redis==5.2.1 requests==2.32.3 "python-telegram-bot[job-queue]==21.10"
|
||||||
|
|
||||||
COPY checker.py .
|
COPY checker.py .
|
||||||
|
|
||||||
|
|||||||
+1087
-337
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,95 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: esp32
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: esp32
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: esp
|
||||||
|
namespace: esp32
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: esp32
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Endpoints
|
||||||
|
metadata:
|
||||||
|
name: esp
|
||||||
|
namespace: esp32
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: esp32
|
||||||
|
subsets:
|
||||||
|
- addresses:
|
||||||
|
- ip: 192.168.88.88
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 80
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: Middleware
|
||||||
|
metadata:
|
||||||
|
name: strip-esp-headers
|
||||||
|
namespace: esp32
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: esp32
|
||||||
|
spec:
|
||||||
|
headers:
|
||||||
|
customRequestHeaders:
|
||||||
|
Cookie: ""
|
||||||
|
Referer: ""
|
||||||
|
Origin: ""
|
||||||
|
User-Agent: ""
|
||||||
|
Accept: ""
|
||||||
|
Accept-Encoding: ""
|
||||||
|
Accept-Language: ""
|
||||||
|
Upgrade-Insecure-Requests: ""
|
||||||
|
Cache-Control: ""
|
||||||
|
Pragma: ""
|
||||||
|
Connection: ""
|
||||||
|
Te: ""
|
||||||
|
Sec-Fetch-Dest: ""
|
||||||
|
Sec-Fetch-Mode: ""
|
||||||
|
Sec-Fetch-Site: ""
|
||||||
|
Sec-Fetch-User: ""
|
||||||
|
Sec-CH-UA: ""
|
||||||
|
Sec-CH-UA-Mobile: ""
|
||||||
|
Sec-CH-UA-Platform: ""
|
||||||
|
X-Forwarded-For: ""
|
||||||
|
X-Forwarded-Host: ""
|
||||||
|
X-Forwarded-Port: ""
|
||||||
|
X-Forwarded-Proto: ""
|
||||||
|
X-Forwarded-Server: ""
|
||||||
|
Forwarded: ""
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: esp
|
||||||
|
namespace: esp32
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: esp32
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`esp.forust.xyz`)
|
||||||
|
kind: Rule
|
||||||
|
middlewares:
|
||||||
|
- name: strip-esp-headers
|
||||||
|
namespace: esp32
|
||||||
|
services:
|
||||||
|
- kind: Service
|
||||||
|
name: esp
|
||||||
|
namespace: esp32
|
||||||
|
port: 80
|
||||||
|
tls:
|
||||||
|
certResolver: letsencrypt
|
||||||
@@ -16,5 +16,7 @@ data:
|
|||||||
GITEA__security__REVERSE_PROXY_TRUSTED_PROXIES: "*"
|
GITEA__security__REVERSE_PROXY_TRUSTED_PROXIES: "*"
|
||||||
|
|
||||||
GITEA__mailer__ENABLED: "false"
|
GITEA__mailer__ENABLED: "false"
|
||||||
|
|
||||||
|
GITEA__log__logger__access__MODE: "console, file"
|
||||||
USER_UID: "1000"
|
USER_UID: "1000"
|
||||||
USER_GID: "1000"
|
USER_GID: "1000"
|
||||||
|
|||||||
+6
-15
@@ -9,8 +9,11 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`gitea.forust.xyz`)
|
- match: Host(`gitea.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
services:
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
- name: gitea-service
|
||||||
|
port: 3000
|
||||||
|
- match: Host(`gcr.forust.xyz`) && PathPrefix(`/v2`)
|
||||||
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: gitea-service
|
- name: gitea-service
|
||||||
port: 3000
|
port: 3000
|
||||||
@@ -31,23 +34,11 @@ spec:
|
|||||||
services:
|
services:
|
||||||
- name: gitea-service
|
- name: gitea-service
|
||||||
port: 3000
|
port: 3000
|
||||||
---
|
- match: (Host(`gcr.workstation.internal`) || Host(`gcr.gigaforust.internal`)) && PathPrefix(`/v2`)
|
||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: IngressRoute
|
|
||||||
metadata:
|
|
||||||
name: gitea-registry
|
|
||||||
namespace: gitea
|
|
||||||
spec:
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
|
||||||
- match: Host(`gcr.forust.xyz`) && PathPrefix(`/v2`)
|
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: gitea-service
|
- name: gitea-service
|
||||||
port: 3000
|
port: 3000
|
||||||
tls:
|
|
||||||
certResolver: letsencrypt
|
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRouteTCP
|
kind: IngressRouteTCP
|
||||||
|
|||||||
@@ -65,6 +65,40 @@ services:
|
|||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
networks:
|
networks:
|
||||||
- proxy
|
- proxy
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.services.headplane.loadbalancer.server.port=3000"
|
||||||
|
|
||||||
|
# Middleware: add /admin prefix for root requests
|
||||||
|
- "traefik.http.middlewares.headplane-prefix.addPrefix.prefix=/admin"
|
||||||
|
|
||||||
|
# Prod Root Router
|
||||||
|
- "traefik.http.routers.headplane-root.rule=Host(`hp.forust.xyz`)"
|
||||||
|
- "traefik.http.routers.headplane-root.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane-root.middlewares=headplane-prefix"
|
||||||
|
- "traefik.http.routers.headplane-root.tls.certresolver=letsencrypt"
|
||||||
|
# Prod Router
|
||||||
|
- "traefik.http.routers.headplane.rule=Host(`hp.forust.xyz`) && PathPrefix(`/admin`)"
|
||||||
|
- "traefik.http.routers.headplane.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane.tls.certresolver=letsencrypt"
|
||||||
|
# Local Root Router
|
||||||
|
- "traefik.http.routers.headplane-root-local.rule=Host(`hp.workstation.internal`)"
|
||||||
|
- "traefik.http.routers.headplane-root-local.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane-root-local.middlewares=headplane-prefix"
|
||||||
|
- "traefik.http.routers.headplane-root-local.tls=true"
|
||||||
|
# Local Router
|
||||||
|
- "traefik.http.routers.headplane-local.rule=Host(`hp.workstation.internal`) && PathPrefix(`/admin`)"
|
||||||
|
- "traefik.http.routers.headplane-local.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane-local.tls=true"
|
||||||
|
# Dev Root Router
|
||||||
|
- "traefik.http.routers.headplane-root-dev.rule=Host(`hp.gigaforust.internal`)"
|
||||||
|
- "traefik.http.routers.headplane-root-dev.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane-root-dev.middlewares=headplane-prefix"
|
||||||
|
- "traefik.http.routers.headplane-root-dev.tls=true"
|
||||||
|
# Dev Router
|
||||||
|
- "traefik.http.routers.headplane-dev.rule=Host(`hp.gigaforust.internal`) && PathPrefix(`/admin`)"
|
||||||
|
- "traefik.http.routers.headplane-dev.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.headplane-dev.tls=true"
|
||||||
web:
|
web:
|
||||||
image: goodieshq/headscale-admin:latest
|
image: goodieshq/headscale-admin:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -1,27 +1,21 @@
|
|||||||
{
|
{
|
||||||
"groups": {
|
"groups": {
|
||||||
"group:admin": [
|
"group:admin": ["admin@"],
|
||||||
"admin@"
|
"group:users": []
|
||||||
],
|
},
|
||||||
"group:users": []
|
"tagOwners": {},
|
||||||
},
|
"hosts": {},
|
||||||
"tagOwners": {},
|
"acls": [
|
||||||
"hosts": {},
|
{
|
||||||
"acls": [
|
"randomizeClientPort": false,
|
||||||
{
|
"#ha-meta": {
|
||||||
"randomizeClientPort": false,
|
"name": "users",
|
||||||
"#ha-meta": {
|
"open": true
|
||||||
"name": "users",
|
},
|
||||||
"open": true
|
"action": "accept",
|
||||||
},
|
"src": ["autogroup:member"],
|
||||||
"action": "accept",
|
"dst": ["autogroup:self:*"]
|
||||||
"src": [
|
}
|
||||||
"autogroup:member"
|
],
|
||||||
],
|
"ssh": []
|
||||||
"dst": [
|
|
||||||
"autogroup:self:*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"ssh": []
|
|
||||||
}
|
}
|
||||||
@@ -57,3 +57,30 @@ ports:
|
|||||||
endpoints:
|
endpoints:
|
||||||
- addresses:
|
- addresses:
|
||||||
- "192.168.88.100"
|
- "192.168.88.100"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: headplane-external
|
||||||
|
namespace: headscale
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 3000
|
||||||
|
targetPort: 13000
|
||||||
|
name: http
|
||||||
|
---
|
||||||
|
apiVersion: discovery.k8s.io/v1
|
||||||
|
kind: EndpointSlice
|
||||||
|
metadata:
|
||||||
|
name: headplane-external
|
||||||
|
namespace: headscale
|
||||||
|
labels:
|
||||||
|
kubernetes.io/service-name: headplane-external
|
||||||
|
addressType: IPv4
|
||||||
|
ports:
|
||||||
|
- port: 13000
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
endpoints:
|
||||||
|
- addresses:
|
||||||
|
- "192.168.88.100"
|
||||||
@@ -1,7 +1,16 @@
|
|||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: Middleware
|
||||||
|
metadata:
|
||||||
|
name: headplane-prefix
|
||||||
|
namespace: headscale
|
||||||
|
spec:
|
||||||
|
addPrefix:
|
||||||
|
prefix: "/admin"
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: headscale-server-prod
|
name: headscale-prod
|
||||||
namespace: headscale
|
namespace: headscale
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
entryPoints:
|
||||||
@@ -9,18 +18,50 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`hs.forust.xyz`)
|
- match: Host(`hs.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: headscale-server-external
|
- name: headscale-server-external
|
||||||
port: 8080
|
port: 8080
|
||||||
|
- match: Host(`hs.forust.xyz`) && PathPrefix(`/admin`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: headscale-ui-external
|
||||||
|
port: 80
|
||||||
|
- match: Host(`hs.forust.xyz`) && PathPrefix(`/metrics`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: headscale-server-external
|
||||||
|
port: 9090
|
||||||
tls:
|
tls:
|
||||||
certResolver: letsencrypt
|
certResolver: letsencrypt
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: headscale-server-local
|
name: headplane-prod
|
||||||
|
namespace: headscale
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`hp.forust.xyz`)
|
||||||
|
kind: Rule
|
||||||
|
middlewares:
|
||||||
|
- name: headplane-prefix
|
||||||
|
services:
|
||||||
|
- name: headplane-external
|
||||||
|
port: 3000
|
||||||
|
- match: Host(`hp.forust.xyz`) && PathPrefix(`/admin`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: headplane-external
|
||||||
|
port: 3000
|
||||||
|
tls:
|
||||||
|
certResolver: letsencrypt
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: headscale-local
|
||||||
namespace: headscale
|
namespace: headscale
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
entryPoints:
|
||||||
@@ -31,76 +72,33 @@ spec:
|
|||||||
services:
|
services:
|
||||||
- name: headscale-server-external
|
- name: headscale-server-external
|
||||||
port: 8080
|
port: 8080
|
||||||
|
- match: (Host(`hs.workstation.internal`) || Host(`hs.gigaforust.internal`)) && PathPrefix(`/admin`)
|
||||||
---
|
|
||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: IngressRoute
|
|
||||||
metadata:
|
|
||||||
name: headscale-ui-prod
|
|
||||||
namespace: headscale
|
|
||||||
spec:
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
|
||||||
- match: Host(`hs.forust.xyz`) && PathPrefix(`/admin`)
|
|
||||||
kind: Rule
|
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
- name: security-chain@file
|
|
||||||
services:
|
|
||||||
- name: headscale-ui-external
|
|
||||||
port: 80
|
|
||||||
tls:
|
|
||||||
certResolver: letsencrypt
|
|
||||||
---
|
|
||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: IngressRoute
|
|
||||||
metadata:
|
|
||||||
name: headscale-ui-local
|
|
||||||
namespace: headscale
|
|
||||||
spec:
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
|
||||||
- match: HostRegexp(`^hs\.(workstation|gigaforust)\.internal$`) && PathPrefix(`/admin`)
|
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: headscale-ui-external
|
- name: headscale-ui-external
|
||||||
port: 80
|
port: 80
|
||||||
|
- match: (Host(`hs.workstation.internal`) || Host(`hs.gigaforust.internal`)) && PathPrefix(`/metrics`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: headscale-server-external
|
||||||
|
port: 9090
|
||||||
---
|
---
|
||||||
apiVersion: traefik.io/v1alpha1
|
apiVersion: traefik.io/v1alpha1
|
||||||
kind: IngressRoute
|
kind: IngressRoute
|
||||||
metadata:
|
metadata:
|
||||||
name: headscale-metrics-prod
|
name: headplane-local
|
||||||
namespace: headscale
|
namespace: headscale
|
||||||
spec:
|
spec:
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
routes:
|
||||||
- match: Host(`hs.forust.xyz`) && PathPrefix(`/metrics`)
|
- match: Host(`hp.workstation.internal`) || Host(`hp.gigaforust.internal`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
- name: headplane-prefix
|
||||||
services:
|
services:
|
||||||
- name: headscale-server-external
|
- name: headplane-external
|
||||||
port: 9090
|
port: 3000
|
||||||
tls:
|
- match: (Host(`hp.workstation.internal`) || Host(`hp.gigaforust.internal`)) && PathPrefix(`/admin`)
|
||||||
certResolver: letsencrypt
|
|
||||||
domains:
|
|
||||||
- main: hs.forust.xyz
|
|
||||||
---
|
|
||||||
apiVersion: traefik.io/v1alpha1
|
|
||||||
kind: IngressRoute
|
|
||||||
metadata:
|
|
||||||
name: headscale-metrics-local
|
|
||||||
namespace: headscale
|
|
||||||
spec:
|
|
||||||
entryPoints:
|
|
||||||
- websecure
|
|
||||||
routes:
|
|
||||||
- match: HostRegexp(`^hs\.(workstation|gigaforust)\.internal$`) && PathPrefix(`/metrics`)
|
|
||||||
kind: Rule
|
kind: Rule
|
||||||
services:
|
services:
|
||||||
- name: headscale-server-external
|
- name: headplane-external
|
||||||
port: 9090
|
port: 3000
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 53 KiB |
+205
-192
@@ -1,212 +1,225 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
<head>
|
<meta charset="UTF-8" />
|
||||||
<meta charset="UTF-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>MrForust // XRock</title>
|
<title>MrForust // XRock</title>
|
||||||
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
|
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
|
||||||
<link rel="stylesheet" href="assets/css/style.css">
|
<link rel="stylesheet" href="assets/css/style.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<header>
|
<header>
|
||||||
<h1 class="glitch" data-text="MrForust">Mr-Forust</h1>
|
<h1 class="glitch" data-text="MrForust">Mr-Forust</h1>
|
||||||
<p class="subtitle">> CTF Player / XRock_Team / Just Signal.</p>
|
<p class="subtitle">> CTF Player / XRock_Team / Just Signal.</p>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<hr>
|
<hr />
|
||||||
|
|
||||||
|
<div class="grid-2">
|
||||||
|
<section id="contacts">
|
||||||
|
<h2>./contacts</h2>
|
||||||
|
<ul class="link-list">
|
||||||
|
<li>
|
||||||
|
<i class="fab fa-github"></i>
|
||||||
|
<a href="https://github.com/mr-forust" target="_blank">github/mr-forust</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fas fa-flag"></i>
|
||||||
|
<a href="https://tryhackme.com/p/MrForust" target="_blank">tryhackme/MrForust</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fab fa-telegram-plane"></i>
|
||||||
|
<a href="https://t.me/MrForust" target="_blank">telegram/MrForust</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fab fa-discord"></i>
|
||||||
|
<span>discord/mr.forust</span>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fas fa-envelope"></i>
|
||||||
|
<a href="mailto:contact@forust.xyz">mail/contact@forust.xyz</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fa-solid fa-key"></i>
|
||||||
|
<a href=".well-known/pgp-key.asc">security/PGP Key</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<p class="comment"># PGP Key Fingerprint: A777 7CB7 D9C4 0A97 443D CCF0 7A3D A455 F820 5B82</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="tools">
|
||||||
|
<h2>./tools</h2>
|
||||||
|
<ul class="link-list">
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-pie-chart"></i>
|
||||||
|
<a href="https://forust.xyz/glance" target="_blank">forust/dashboard</a>
|
||||||
|
<p class="comment"># Glance dashboard</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fa fa-refresh"></i>
|
||||||
|
<a href="https://forust.xyz/convert" target="_blank">forust/converter</a>
|
||||||
|
<p class="comment"># ConvertX instance</p>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<i class="fa-solid fa-file-pdf"></i>
|
||||||
|
<a href="https://pdf.forust.xyz" target="_blank">pdf.forust.xyz</a>
|
||||||
|
<p class="comment"># BentoPDF instance</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section id="stack">
|
||||||
|
<h2>./skills</h2>
|
||||||
<div class="grid-2">
|
<div class="grid-2">
|
||||||
<section id="socials">
|
<div>
|
||||||
<h2>./socials</h2>
|
<div class="skill-item">
|
||||||
<ul class="link-list">
|
<span>ArchLinux # btw</span>
|
||||||
<li>
|
<span class="level">[#######...]</span>
|
||||||
<i class="fab fa-github"></i>
|
</div>
|
||||||
<a href="https://github.com/mr-forust" target="_blank">github/mr-forust</a>
|
<div class="skill-item"><span>Kubernetes</span> <span class="level">[###.......]</span></div>
|
||||||
</li>
|
<div class="skill-item"><span>Docker</span> <span class="level">[####......]</span></div>
|
||||||
<li>
|
<div class="skill-item">
|
||||||
<i class="fas fa-flag"></i>
|
<span>Docker Compose</span>
|
||||||
<a href="https://tryhackme.com/p/MrForust" target="_blank">tryhackme/MrForust</a>
|
<span class="level">[#####.....]</span>
|
||||||
</li>
|
</div>
|
||||||
<li>
|
<div class="skill-item"><span>Web Pentest</span> <span class="level">[#####.....]</span></div>
|
||||||
<i class="fab fa-telegram-plane"></i>
|
<div class="skill-item"><span>Burpsuite</span> <span class="level">[#####.....]</span></div>
|
||||||
<a href="https://t.me/MrForust" target="_blank">telegram/MrForust</a>
|
<div class="skill-item"><span>Steganography</span> <span class="level">[####......]</span></div>
|
||||||
</li>
|
</div>
|
||||||
<li>
|
<div>
|
||||||
<i class="fab fa-discord"></i>
|
<div class="skill-item"><span>Cryptography</span> <span class="level">[####......]</span></div>
|
||||||
<span>discord/mr.forust</span>
|
<div class="skill-item"><span>OSINT</span> <span class="level">[####......]</span></div>
|
||||||
</li>
|
<div class="skill-item"><span>Python</span> <span class="level">[###.......]</span></div>
|
||||||
<li>
|
<div class="skill-item"><span>HTML</span> <span class="level">[###.......]</span></div>
|
||||||
<i class="fas fa-envelope"></i>
|
<div class="skill-item"><span>Bash</span> <span class="level">[##........]</span></div>
|
||||||
<a href="mailto:contact@forust.xyz">mail/contact@forust.xyz</a>
|
<div class="skill-item"><span>Golang</span> <span class="level">[#.........]</span></div>
|
||||||
</li>
|
</div>
|
||||||
<li>
|
|
||||||
<i class="fa-solid fa-key"></i>
|
|
||||||
<a href=".well-known/pgp-key.asc">security/PGP Key</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<p class="comment"># PGP Key Fingerprint: A777 7CB7 D9C4 0A97 443D CCF0 7A3D A455 F820 5B82</p>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="tools">
|
|
||||||
<h2>./tools</h2>
|
|
||||||
<ul class="link-list">
|
|
||||||
<li>
|
|
||||||
<i class="fa fa-pie-chart"></i>
|
|
||||||
<a href="https://forust.xyz/glance" target="_blank">forust/dashboard</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<i class="fa fa-refresh"></i>
|
|
||||||
<a href="https://forust.xyz/convert" target="_blank">forust/converter</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<i class="fa-solid fa-file-pdf"></i>
|
|
||||||
<a href="https://pdf.forust.xyz" target="_blank">pdf.forust.xyz</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="stack">
|
<section id="team">
|
||||||
<h2>./skills</h2>
|
<h2>./xrock_team</h2>
|
||||||
<div class="grid-2">
|
<p class="comment"># It's a select caste. Cybershamans. Cryptoanarchists. Shadows on the net..</p>
|
||||||
<div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>ArchLinux # btw</span>
|
|
||||||
<span class="level">[#######...]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Kubernetes</span> <span class="level">[###.......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Docker</span> <span class="level">[####......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Docker Compose</span> <span class="level">[#####.....]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Web Pentest</span> <span class="level">[#####.....]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Burpsuite</span> <span class="level">[#####.....]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Steganography</span> <span class="level">[####......]</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Cryptography</span> <span class="level">[####......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>OSINT</span> <span class="level">[####......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Python</span> <span class="level">[###.......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>HTML</span> <span class="level">[###.......]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Bash</span> <span class="level">[##........]</span>
|
|
||||||
</div>
|
|
||||||
<div class="skill-item">
|
|
||||||
<span>Golang</span> <span class="level">[#.........]</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section id="team">
|
<div class="team-grid">
|
||||||
<h2>./xrock_team</h2>
|
<div class="member">
|
||||||
<p class="comment"># It's a select caste. Cybershamans. Cryptoanarchists. Shadows on the net..</p>
|
<div
|
||||||
|
class="avatar"
|
||||||
|
style="
|
||||||
|
background-image: url("assets/images/team/mrforust.jpg");
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
<a href="https://github.com/mr-forust" target="_blank">MrForust</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="team-grid">
|
<div class="member">
|
||||||
<div class="member">
|
<div
|
||||||
<div class="avatar"
|
class="avatar"
|
||||||
style="background-image: url('assets/images/team/mrforust.jpg'); background-size: cover; background-position: center;">
|
style="
|
||||||
</div>
|
background-image: url("assets/images/team/anna.jpg");
|
||||||
<a href="https://github.com/mr-forust" target="_blank">MrForust</a>
|
background-size: cover;
|
||||||
</div>
|
background-position: center;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
<a href="./assets/images/love.png" target="_blank">Anna~</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="member">
|
<div class="member">
|
||||||
<div class="avatar"
|
<div
|
||||||
style="background-image: url('assets/images/team/anna.jpg'); background-size: cover; background-position: center;">
|
class="avatar"
|
||||||
</div>
|
style="
|
||||||
<a href="./assets/images/love.png" target="_blank">Anna~</a>
|
background-image: url("assets/images/team/chernuha.jpg");
|
||||||
</div>
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
<a href="https://chernuha.space" target="_blank">Chernuha</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="member">
|
<div class="member">
|
||||||
<div class="avatar"
|
<div
|
||||||
style="background-image: url('assets/images/team/chernuha.jpg'); background-size: cover; background-position: center;">
|
class="avatar"
|
||||||
</div>
|
style="
|
||||||
<a href="https://chernuha.space" target="_blank">Chernuha</a>
|
background-image: url("assets/images/team/hudan.jpg");
|
||||||
</div>
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
<a href="https://hudan.xyz" target="_blank">p1ngvi</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="member">
|
<div class="member">
|
||||||
<div class="avatar"
|
<div
|
||||||
style="background-image: url('assets/images/team/hudan.jpg'); background-size: cover; background-position: center;">
|
class="avatar"
|
||||||
</div>
|
style="
|
||||||
<a href="https://hudan.xyz" target="_blank">p1ngvi</a>
|
background-image: url("assets/images/team/xdfnx.jpg");
|
||||||
</div>
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
"
|
||||||
|
></div>
|
||||||
|
<a href="https://xdfnx.cfd" target="_blank">xdfnx</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="member">
|
<section id="projects">
|
||||||
<div class="avatar"
|
<h2>./projects</h2>
|
||||||
style="background-image: url('assets/images/team/xdfnx.jpg'); background-size: cover; background-position: center;">
|
<ul class="repo-list">
|
||||||
</div>
|
<li>
|
||||||
<a href="https://xdfnx.cfd" target="_blank">xdfnx</a>
|
<a href="https://gitea.forust.xyz/forust/gosleep" target="_blank">forust/gosleep</a>
|
||||||
</div>
|
<span class="comment">// linux sleep timer written in rust (originally in go)</span>
|
||||||
</div>
|
</li>
|
||||||
</section>
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="repos">
|
<section id="repos">
|
||||||
<h2>./favorite_repos</h2>
|
<h2>./favorite_repos</h2>
|
||||||
<ul class="repo-list">
|
<ul class="repo-list">
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/TDesktop-x64/tdesktop" target="_blank">TDesktop-x64/tdesktop</a>
|
<a href="https://github.com/TDesktop-x64/tdesktop" target="_blank">TDesktop-x64/tdesktop</a>
|
||||||
<span class="comment">// unofficial telegram client with some additions</span>
|
<span class="comment">// unofficial telegram client with some additions</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/traefik/traefik" target="_blank">traefik/traefik</a>
|
<a href="https://github.com/traefik/traefik" target="_blank">traefik/traefik</a>
|
||||||
<span class="comment">// beloved reverse-proxy</span>
|
<span class="comment">// beloved reverse-proxy</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/unhappychoice/gitlogue" target="_blank">unhappychoice/gitlogue</a>
|
<a href="https://github.com/unhappychoice/gitlogue" target="_blank">unhappychoice/gitlogue</a>
|
||||||
<span class="comment">// nice git log visualizer</span>
|
<span class="comment">// nice git log visualizer</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/tstack/lnav" target="_blank">tstack/lnav</a>
|
<a href="https://github.com/tstack/lnav" target="_blank">tstack/lnav</a>
|
||||||
<span class="comment">// powerful log reader</span>
|
<span class="comment">// powerful log reader</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/mountain-loop/yaak" target="_blank">mountain-loop/yaak</a>
|
<a href="https://github.com/mountain-loop/yaak" target="_blank">mountain-loop/yaak</a>
|
||||||
<span class="comment">// modern, fancy api client</span>
|
<span class="comment">// modern, fancy api client</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/pear-devs/pear-desktop" target="_blank">pear-devs/pear-desktop</a>
|
<a href="https://github.com/pear-devs/pear-desktop" target="_blank">pear-devs/pear-desktop</a>
|
||||||
<span class="comment">// music client with a lot of features</span>
|
<span class="comment">// music client with a lot of features</span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/epi052/feroxbuster" target="_blank">epi052/feroxbuster</a>
|
<a href="https://github.com/epi052/feroxbuster" target="_blank">epi052/feroxbuster</a>
|
||||||
<span class="comment">// directory discovery</span>
|
<span class="comment">// directory discovery</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<p>root@xrock:~$ cat <a href="miku.html">./miku</a></p>
|
<p>root@xrock:~$ cat <a href="miku.html">./miku</a></p>
|
||||||
<p>miku?</p>
|
<p>miku?</p>
|
||||||
<p>root@xrock:~$ shutdown -h now</p>
|
<p>root@xrock:~$ shutdown -h now</p>
|
||||||
<p>© XRock - Just Signal.</p>
|
<p>© XRock - Just Signal.</p>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
|
</body>
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`forust.xyz`) || Host(`www.forust.xyz`)
|
- match: Host(`forust.xyz`) || Host(`www.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
priority: 10
|
priority: 10
|
||||||
services:
|
services:
|
||||||
- name: forust-homepage-service
|
- name: forust-homepage-service
|
||||||
@@ -43,10 +41,8 @@ spec:
|
|||||||
entryPoints:
|
entryPoints:
|
||||||
- websecure
|
- websecure
|
||||||
routes:
|
routes:
|
||||||
- match: Host(`xdfnx.cfd`) || Host(`www.xdfnx.cfd`)
|
- match: Host(`xdfnx.cfd`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: xdfnx-homepage-service
|
- name: xdfnx-homepage-service
|
||||||
port: 80
|
port: 80
|
||||||
|
|||||||
+643
-1123
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`status.forust.xyz`)
|
- match: Host(`status.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: kener-service
|
- name: kener-service
|
||||||
port: 3000
|
port: 3000
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`n8n.forust.xyz`)
|
- match: Host(`n8n.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: n8n-service
|
- name: n8n-service
|
||||||
port: 5678
|
port: 5678
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`nm.forust.xyz`)
|
- match: Host(`nm.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: netronome-service
|
- name: netronome-service
|
||||||
port: 7575
|
port: 7575
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ spec:
|
|||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: nextcloud-chain@file
|
- name: nextcloud-chain@file
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: nextcloud-apache
|
- name: nextcloud-apache
|
||||||
port: 11000
|
port: 11000
|
||||||
@@ -31,7 +30,6 @@ spec:
|
|||||||
- match: Host(`nextcloud.workstation.internal`) || Host(`nextcloud.gigaforust.internal`)
|
- match: Host(`nextcloud.workstation.internal`) || Host(`nextcloud.gigaforust.internal`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
- name: nextcloud-chain@file
|
- name: nextcloud-chain@file
|
||||||
services:
|
services:
|
||||||
- name: nextcloud-apache
|
- name: nextcloud-apache
|
||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`portainer.forust.xyz`)
|
- match: Host(`portainer.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: portainer-service
|
- name: portainer-service
|
||||||
port: 9000
|
port: 9000
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ spec:
|
|||||||
- match: Host(`grafana.forust.xyz`)
|
- match: Host(`grafana.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
middlewares:
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
- name: "security-chain@file"
|
- name: "security-chain@file"
|
||||||
services:
|
services:
|
||||||
- name: prometheus-stack-grafana
|
- name: prometheus-stack-grafana
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"venvPath": "/home/forust/homelab/userbot",
|
||||||
|
"venv": ".venv"
|
||||||
|
}
|
||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`s.forust.xyz`) || Host(`search.forust.xyz`)
|
- match: Host(`s.forust.xyz`) || Host(`search.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: searxng-service
|
- name: searxng-service
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`termix.forust.xyz`)
|
- match: Host(`termix.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: termix-service
|
- name: termix-service
|
||||||
port: 8080
|
port: 8080
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
http:
|
||||||
|
routers:
|
||||||
|
fs1-public:
|
||||||
|
rule: "Host(`fs1.domain.xyz`)"
|
||||||
|
entrypoints:
|
||||||
|
- websecure
|
||||||
|
service: fs1
|
||||||
|
middlewares:
|
||||||
|
- security-chain@file
|
||||||
|
tls: {}
|
||||||
|
|
||||||
|
fs1-workstation:
|
||||||
|
rule: "Host(`fs1.workstation.internal`)"
|
||||||
|
entrypoints:
|
||||||
|
- websecure
|
||||||
|
service: fs1
|
||||||
|
tls: {}
|
||||||
|
|
||||||
|
services:
|
||||||
|
fs1:
|
||||||
|
loadBalancer:
|
||||||
|
servers:
|
||||||
|
- url: "http://127.0.0.1:3923" # Copyparty port example
|
||||||
@@ -10,8 +10,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`traefik.forust.xyz`)
|
- match: Host(`traefik.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: "crowdsec-crowdsec-bouncer@kubernetescrd"
|
|
||||||
services:
|
services:
|
||||||
- name: api@internal
|
- name: api@internal
|
||||||
kind: TraefikService
|
kind: TraefikService
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# Auto-generated by forust | See https://github.com/traefik/traefik-helm-chart/blob/master/values.yaml
|
# Auto-generated by forust | See https://github.com/traefik/traefik-helm-chart/blob/master/values.yaml
|
||||||
hostNetwork: false
|
hostNetwork: false
|
||||||
|
image:
|
||||||
|
registry: docker.io/library
|
||||||
|
repository: traefik
|
||||||
|
tag: v3.7.6
|
||||||
|
|
||||||
securityContext:
|
securityContext:
|
||||||
capabilities:
|
capabilities:
|
||||||
@@ -23,16 +27,7 @@ updateStrategy:
|
|||||||
type: Recreate
|
type: Recreate
|
||||||
|
|
||||||
deployment:
|
deployment:
|
||||||
initContainers:
|
enabled: true
|
||||||
- name: volume-permissions
|
|
||||||
image: busybox:latest
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- "mkdir -p /data/letsencrypt && touch /data/letsencrypt/acme.json && chmod 600 /data/letsencrypt/acme.json"
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
|
|
||||||
providers:
|
providers:
|
||||||
kubernetesIngress:
|
kubernetesIngress:
|
||||||
@@ -123,10 +118,6 @@ volumes:
|
|||||||
- name: traefik-dynamic
|
- name: traefik-dynamic
|
||||||
mountPath: /etc/traefik/dynamic
|
mountPath: /etc/traefik/dynamic
|
||||||
type: configMap
|
type: configMap
|
||||||
- name: crowdsec-bouncer-secrets
|
|
||||||
mountPath: /etc/traefik/secrets
|
|
||||||
type: secret
|
|
||||||
|
|
||||||
additionalArguments:
|
additionalArguments:
|
||||||
- "--providers.file.directory=/etc/traefik/dynamic"
|
- "--providers.file.directory=/etc/traefik/dynamic"
|
||||||
- "--providers.file.watch=true"
|
- "--providers.file.watch=true"
|
||||||
@@ -134,15 +125,8 @@ additionalArguments:
|
|||||||
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,192.168.1.1,192.168.1.0/24,192.168.88.0/24,192.168.88.1"
|
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,192.168.1.1,192.168.1.0/24,192.168.88.0/24,192.168.88.1"
|
||||||
- "--entryPoints.web.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,192.168.1.1,192.168.1.0/24,192.168.88.0/24,192.168.88.1"
|
- "--entryPoints.web.forwardedHeaders.trustedIPs=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22,192.168.1.1,192.168.1.0/24,192.168.88.0/24,192.168.88.1"
|
||||||
|
|
||||||
logs:
|
log:
|
||||||
general:
|
level: INFO
|
||||||
level: INFO
|
accessLog:
|
||||||
access:
|
enabled: true
|
||||||
enabled: true
|
format: common
|
||||||
format: common
|
|
||||||
|
|
||||||
experimental:
|
|
||||||
plugins:
|
|
||||||
crowdsec-bouncer:
|
|
||||||
moduleName: github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin
|
|
||||||
version: v1.3.3
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ spec:
|
|||||||
routes:
|
routes:
|
||||||
- match: Host(`uptime.forust.xyz`)
|
- match: Host(`uptime.forust.xyz`)
|
||||||
kind: Rule
|
kind: Rule
|
||||||
middlewares:
|
|
||||||
- name: crowdsec-crowdsec-bouncer@kubernetescrd
|
|
||||||
services:
|
services:
|
||||||
- name: uptime-kuma-service
|
- name: uptime-kuma-service
|
||||||
port: 3001
|
port: 3001
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
FROM python:3.11-slim AS builder
|
FROM python:3.11-slim AS builder
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir --user -r requirements.txt
|
RUN pip install --no-cache-dir --user -r requirements.txt
|
||||||
|
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
git \
|
git \
|
||||||
mediainfo \
|
mediainfo \
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import re
|
|||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from bs4 import BeautifulSoup as bs
|
from bs4 import BeautifulSoup
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from pyrogram.errors import RPCError
|
from pyrogram.errors import RPCError
|
||||||
from pyrogram.types import InputMediaPhoto, Message
|
from pyrogram.types import InputMediaPhoto, Message
|
||||||
@@ -12,7 +12,7 @@ from utils.misc import modules_help, prefix
|
|||||||
|
|
||||||
@Client.on_message(filters.command('icon', prefix) & filters.me)
|
@Client.on_message(filters.command('icon', prefix) & filters.me)
|
||||||
async def search_icon(_, message: Message):
|
async def search_icon(_, message: Message):
|
||||||
if not len(message.command) == 2:
|
if len(message.command) != 2:
|
||||||
return await message.edit_text('Please provide some text to search icons from Flaticon.com.')
|
return await message.edit_text('Please provide some text to search icons from Flaticon.com.')
|
||||||
query = message.text.split(maxsplit=1)[1]
|
query = message.text.split(maxsplit=1)[1]
|
||||||
|
|
||||||
@@ -21,8 +21,8 @@ async def search_icon(_, message: Message):
|
|||||||
url = f'https://www.flaticon.com/search?word={search_query}'
|
url = f'https://www.flaticon.com/search?word={search_query}'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
html_content = requests.get(url).text
|
html_content = requests.get(url, timeout=10).text
|
||||||
soup = bs(html_content, 'html.parser')
|
soup = BeautifulSoup(html_content, 'html.parser')
|
||||||
results = soup.find_all(
|
results = soup.find_all(
|
||||||
'img',
|
'img',
|
||||||
src=re.compile(r'https://cdn-icons-png.flaticon.com/128/[0-9]+/[0-9]+.png'),
|
src=re.compile(r'https://cdn-icons-png.flaticon.com/128/[0-9]+/[0-9]+.png'),
|
||||||
@@ -68,7 +68,7 @@ async def freepik_search(client: Client, message: Message):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
url = f'https://www.freepik.com/api/regular/search?locale=en&term={match}'
|
url = f'https://www.freepik.com/api/regular/search?locale=en&term={match}'
|
||||||
json_content = requests.get(url).json()
|
json_content = requests.get(url, timeout=10).json()
|
||||||
results = []
|
results = []
|
||||||
for i in json_content['items']:
|
for i in json_content['items']:
|
||||||
results.append(i['preview']['url'])
|
results.append(i['preview']['url'])
|
||||||
@@ -81,7 +81,7 @@ async def freepik_search(client: Client, message: Message):
|
|||||||
|
|
||||||
media_group = []
|
media_group = []
|
||||||
for img_url in img_urls:
|
for img_url in img_urls:
|
||||||
icon = requests.get(img_url)
|
icon = requests.get(img_url, timeout=10)
|
||||||
if icon.status_code == 200:
|
if icon.status_code == 200:
|
||||||
media_group.append(InputMediaPhoto(media=BytesIO(icon.content)))
|
media_group.append(InputMediaPhoto(media=BytesIO(icon.content)))
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ async def imgur(_, message: Message):
|
|||||||
url = 'https://api.imgur.com/3/image'
|
url = 'https://api.imgur.com/3/image'
|
||||||
headers = {'Authorization': 'Client-ID a10ad04550b0648'}
|
headers = {'Authorization': 'Client-ID a10ad04550b0648'}
|
||||||
# Upload image to Imgur and get URL
|
# Upload image to Imgur and get URL
|
||||||
response = requests.post(url, headers=headers, data={'image': base64_data})
|
response = requests.post(url, headers=headers, data={'image': base64_data}, timeout=10)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
await msg.edit_text(result['data']['link'])
|
await msg.edit_text(result['data']['link'])
|
||||||
elif message.reply_to_message and message.reply_to_message.animation:
|
elif message.reply_to_message and message.reply_to_message.animation:
|
||||||
@@ -35,7 +35,7 @@ async def imgur(_, message: Message):
|
|||||||
url = 'https://api.imgur.com/3/image'
|
url = 'https://api.imgur.com/3/image'
|
||||||
headers = {'Authorization': 'Client-ID a10ad04550b0648'}
|
headers = {'Authorization': 'Client-ID a10ad04550b0648'}
|
||||||
# Upload animation to Imgur and get URL
|
# Upload animation to Imgur and get URL
|
||||||
response = requests.post(url, headers=headers, data={'image': base64_data})
|
response = requests.post(url, headers=headers, data={'image': base64_data}, timeout=10)
|
||||||
result = response.json()
|
result = response.json()
|
||||||
await msg.edit_text(result['data']['link'])
|
await msg.edit_text(result['data']['link'])
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ def resize_image(image_bytes):
|
|||||||
|
|
||||||
async def download_image(url):
|
async def download_image(url):
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
img_bytes = BytesIO(response.content)
|
img_bytes = BytesIO(response.content)
|
||||||
return resize_image(img_bytes)
|
return resize_image(img_bytes)
|
||||||
@@ -40,7 +40,7 @@ async def download_image(url):
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command('pinterest', prefix) & filters.me)
|
@Client.on_message(filters.command('pinterest', prefix) & filters.me)
|
||||||
async def pinterest_search(client: Client, message: Message):
|
async def pinterest_search(_client: Client, message: Message):
|
||||||
if len(message.command) < 2:
|
if len(message.command) < 2:
|
||||||
await message.edit('Usage: `pinterest [number] <query>`', parse_mode=enums.ParseMode.MARKDOWN)
|
await message.edit('Usage: `pinterest [number] <query>`', parse_mode=enums.ParseMode.MARKDOWN)
|
||||||
return
|
return
|
||||||
@@ -52,7 +52,7 @@ async def pinterest_search(client: Client, message: Message):
|
|||||||
status_message = await message.edit('Searching for images...', parse_mode=enums.ParseMode.MARKDOWN)
|
status_message = await message.edit('Searching for images...', parse_mode=enums.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
url = f'{API_URL}{query}'
|
url = f'{API_URL}{query}'
|
||||||
response = requests.get(url)
|
response = requests.get(url, timeout=10)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def upload_image(photo_path):
|
|||||||
"""Uploads an image to tmpfiles.org and returns the direct download URL."""
|
"""Uploads an image to tmpfiles.org and returns the direct download URL."""
|
||||||
try:
|
try:
|
||||||
with open(photo_path, 'rb') as image_file:
|
with open(photo_path, 'rb') as image_file:
|
||||||
response = requests.post('https://tmpfiles.org/api/v1/upload', files={'file': image_file})
|
response = requests.post('https://tmpfiles.org/api/v1/upload', files={'file': image_file}, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
url = data['data']['url']
|
url = data['data']['url']
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ async def unsplash(client: Client, message: Message):
|
|||||||
for ia in range(len(images), count):
|
for ia in range(len(images), count):
|
||||||
img = data['results'][ia]['urls']['raw']
|
img = data['results'][ia]['urls']['raw']
|
||||||
if img.startswith('https://images.unsplash.com/photo'):
|
if img.startswith('https://images.unsplash.com/photo'):
|
||||||
image_content = requests.get(img).content
|
image_content = requests.get(img, timeout=10).content
|
||||||
with open(f'{unsplash_dir}/unsplash_{ia}.jpg', 'wb') as f:
|
with open(f'{unsplash_dir}/unsplash_{ia}.jpg', 'wb') as f:
|
||||||
f.write(image_content)
|
f.write(image_content)
|
||||||
imgr = f'{unsplash_dir}/unsplash_{ia}.jpg'
|
imgr = f'{unsplash_dir}/unsplash_{ia}.jpg'
|
||||||
@@ -77,7 +77,6 @@ async def unsplash(client: Client, message: Message):
|
|||||||
|
|
||||||
|
|
||||||
modules_help['unsplash'] = {
|
modules_help['unsplash'] = {
|
||||||
'unsplash': '[keyword]*',
|
|
||||||
'unsplash': '[keyword]* [number of results you want]*\n'
|
'unsplash': '[keyword]* [number of results you want]*\n'
|
||||||
'Makes a request to <code>unsplash.com</code> and sends the image with the keyword you provided.\n\n'
|
'Makes a request to <code>unsplash.com</code> and sends the image with the keyword you provided.\n\n'
|
||||||
'<b>Note:</b>\n1. The number of results you can get is limited to 10.\n'
|
'<b>Note:</b>\n1. The number of results you can get is limited to 10.\n'
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def resize_image(image_bytes):
|
|||||||
|
|
||||||
async def download_image(url):
|
async def download_image(url):
|
||||||
try:
|
try:
|
||||||
response = requests.get(url)
|
response = requests.get(url, timeout=10)
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
img_bytes = BytesIO(response.content)
|
img_bytes = BytesIO(response.content)
|
||||||
resized_img_bytes = resize_image(img_bytes)
|
resized_img_bytes = resize_image(img_bytes)
|
||||||
@@ -40,7 +40,7 @@ async def download_image(url):
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command(['unsplash2', 'usp2'], prefix) & filters.me)
|
@Client.on_message(filters.command(['unsplash2', 'usp2'], prefix) & filters.me)
|
||||||
async def imgsearch(client: Client, message: Message):
|
async def imgsearch(_client: Client, message: Message):
|
||||||
if len(message.command) < 2:
|
if len(message.command) < 2:
|
||||||
await message.edit('Usage: `img [number] <query>`', parse_mode=enums.ParseMode.MARKDOWN)
|
await message.edit('Usage: `img [number] <query>`', parse_mode=enums.ParseMode.MARKDOWN)
|
||||||
return
|
return
|
||||||
@@ -52,7 +52,7 @@ async def imgsearch(client: Client, message: Message):
|
|||||||
status_message = await message.edit('Searching for images...', parse_mode=enums.ParseMode.MARKDOWN)
|
status_message = await message.edit('Searching for images...', parse_mode=enums.ParseMode.MARKDOWN)
|
||||||
|
|
||||||
url = f'{API_URL}{query}'
|
url = f'{API_URL}{query}'
|
||||||
response = requests.get(url)
|
response = requests.get(url, timeout=10)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|||||||
@@ -3,7 +3,5 @@ kind: Kustomization
|
|||||||
|
|
||||||
resources:
|
resources:
|
||||||
- userbots.yaml
|
- userbots.yaml
|
||||||
- common-secret.yaml
|
- panel.yaml
|
||||||
- common-config.yaml
|
- common-config.yaml
|
||||||
- forust-secrets.yaml
|
|
||||||
- anna-secrets.yaml
|
|
||||||
|
|||||||
@@ -0,0 +1,264 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: userbot
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: userbot-runtime
|
||||||
|
namespace: userbot
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: userbot-common-config
|
||||||
|
namespace: userbot
|
||||||
|
data:
|
||||||
|
DATABASE_TYPE: ""
|
||||||
|
DATABASE_NAME: ""
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- apps
|
||||||
|
resources:
|
||||||
|
- deployments
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- create
|
||||||
|
- patch
|
||||||
|
- delete
|
||||||
|
- apiGroups:
|
||||||
|
- apps
|
||||||
|
resources:
|
||||||
|
- deployments/scale
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- pods
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- pods/log
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- persistentvolumeclaims
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- secrets
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- configmaps
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- apiGroups:
|
||||||
|
- metrics.k8s.io
|
||||||
|
resources:
|
||||||
|
- pods
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: userbot-panel
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel-legacy
|
||||||
|
namespace: default
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- apps
|
||||||
|
resources:
|
||||||
|
- deployments
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- patch
|
||||||
|
- apiGroups:
|
||||||
|
- apps
|
||||||
|
resources:
|
||||||
|
- deployments/scale
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- pods
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- pods/log
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- persistentvolumeclaims
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- apiGroups:
|
||||||
|
- metrics.k8s.io
|
||||||
|
resources:
|
||||||
|
- pods
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel-legacy
|
||||||
|
namespace: default
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: userbot-panel-legacy
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
labels:
|
||||||
|
app: userbot-panel
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: userbot-panel
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: userbot-panel
|
||||||
|
spec:
|
||||||
|
serviceAccountName: userbot-panel
|
||||||
|
containers:
|
||||||
|
- name: userbot-panel
|
||||||
|
image: gcr.forust.xyz/forust/userbot-panel:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 8080
|
||||||
|
env:
|
||||||
|
- name: USERBOT_NAMESPACE
|
||||||
|
value: userbot
|
||||||
|
- name: USERBOT_LEGACY_NAMESPACES
|
||||||
|
value: default
|
||||||
|
- name: USERBOT_IMAGE
|
||||||
|
value: gcr.forust.xyz/forust/userbot:latest
|
||||||
|
- name: USERBOT_STORAGE_CLASS
|
||||||
|
value: local-path-retain
|
||||||
|
- name: USERBOT_DOWNLOADS_HOST_PATH
|
||||||
|
value: /srv/homelab/userbot/Downloads
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 20m
|
||||||
|
memory: 96Mi
|
||||||
|
limits:
|
||||||
|
cpu: 300m
|
||||||
|
memory: 384Mi
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 3
|
||||||
|
periodSeconds: 10
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 10
|
||||||
|
periodSeconds: 30
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel
|
||||||
|
namespace: userbot
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: userbot-panel
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8080
|
||||||
|
targetPort: http
|
||||||
|
---
|
||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: userbot-panel-route
|
||||||
|
namespace: userbot
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`userbot.workstation.internal`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: userbot-panel
|
||||||
|
port: 8080
|
||||||
@@ -4,8 +4,14 @@ metadata:
|
|||||||
name: forust-userbot-deployment
|
name: forust-userbot-deployment
|
||||||
labels:
|
labels:
|
||||||
app: forust-userbot
|
app: forust-userbot
|
||||||
|
app.kubernetes.io/name: userbot
|
||||||
|
app.kubernetes.io/instance: forust
|
||||||
|
annotations:
|
||||||
|
userbot.forust.xyz/display-name: forust
|
||||||
|
userbot.forust.xyz/legacy: "true"
|
||||||
|
userbot.forust.xyz/credentials-secret: userbot-forust-secrets
|
||||||
|
userbot.forust.xyz/pvc: forust-pvc
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: forust-userbot
|
app: forust-userbot
|
||||||
@@ -13,6 +19,8 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: forust-userbot
|
app: forust-userbot
|
||||||
|
annotations:
|
||||||
|
kubectl.kubernetes.io/restartedAt: "2026-07-25T20:24:51+02:00"
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: forust-userbot
|
- name: forust-userbot
|
||||||
@@ -33,6 +41,8 @@ spec:
|
|||||||
- secretRef:
|
- secretRef:
|
||||||
name: userbot-forust-secrets
|
name: userbot-forust-secrets
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
- name: downloads
|
||||||
|
mountPath: /app/downloads
|
||||||
- name: forust-storage
|
- name: forust-storage
|
||||||
mountPath: /app/data
|
mountPath: /app/data
|
||||||
subPath: data
|
subPath: data
|
||||||
@@ -40,6 +50,10 @@ spec:
|
|||||||
mountPath: /app/logs
|
mountPath: /app/logs
|
||||||
subPath: logs
|
subPath: logs
|
||||||
volumes:
|
volumes:
|
||||||
|
- name: downloads
|
||||||
|
hostPath:
|
||||||
|
path: /srv/homelab/userbot/Downloads
|
||||||
|
type: DirectoryOrCreate
|
||||||
- name: forust-storage
|
- name: forust-storage
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: forust-pvc
|
claimName: forust-pvc
|
||||||
@@ -62,8 +76,14 @@ metadata:
|
|||||||
name: anna-userbot-deployment
|
name: anna-userbot-deployment
|
||||||
labels:
|
labels:
|
||||||
app: anna-userbot
|
app: anna-userbot
|
||||||
|
app.kubernetes.io/name: userbot
|
||||||
|
app.kubernetes.io/instance: anna
|
||||||
|
annotations:
|
||||||
|
userbot.forust.xyz/display-name: anna
|
||||||
|
userbot.forust.xyz/legacy: "true"
|
||||||
|
userbot.forust.xyz/credentials-secret: userbot-anna-secrets
|
||||||
|
userbot.forust.xyz/pvc: anna-pvc
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: anna-userbot
|
app: anna-userbot
|
||||||
@@ -71,6 +91,8 @@ spec:
|
|||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: anna-userbot
|
app: anna-userbot
|
||||||
|
annotations:
|
||||||
|
kubectl.kubernetes.io/restartedAt: "2026-07-25T20:24:51+02:00"
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: anna-userbot
|
- name: anna-userbot
|
||||||
@@ -91,6 +113,8 @@ spec:
|
|||||||
- secretRef:
|
- secretRef:
|
||||||
name: userbot-anna-secrets
|
name: userbot-anna-secrets
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
- name: downloads
|
||||||
|
mountPath: /app/downloads
|
||||||
- name: anna-storage
|
- name: anna-storage
|
||||||
mountPath: /app/data
|
mountPath: /app/data
|
||||||
subPath: data
|
subPath: data
|
||||||
@@ -98,6 +122,10 @@ spec:
|
|||||||
mountPath: /app/logs
|
mountPath: /app/logs
|
||||||
subPath: logs
|
subPath: logs
|
||||||
volumes:
|
volumes:
|
||||||
|
- name: downloads
|
||||||
|
hostPath:
|
||||||
|
path: /srv/homelab/userbot/Downloads
|
||||||
|
type: DirectoryOrCreate
|
||||||
- name: anna-storage
|
- name: anna-storage
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: anna-pvc
|
claimName: anna-pvc
|
||||||
|
|||||||
+4
-5
@@ -39,6 +39,7 @@
|
|||||||
# "pySmartDL",
|
# "pySmartDL",
|
||||||
# ]
|
# ]
|
||||||
# ///
|
# ///
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@@ -108,7 +109,7 @@ def load_missing_modules():
|
|||||||
module_path = f'{custom_modules_path}/{module_name}.py'
|
module_path = f'{custom_modules_path}/{module_name}.py'
|
||||||
if not os.path.exists(module_path) and module_name in modules_dict:
|
if not os.path.exists(module_path) and module_name in modules_dict:
|
||||||
url = f'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/{modules_dict[module_name]}.py'
|
url = f'https://raw.githubusercontent.com/The-MoonTg-project/custom_modules/main/{modules_dict[module_name]}.py'
|
||||||
resp = requests.get(url)
|
resp = requests.get(url, timeout=10)
|
||||||
if resp.ok:
|
if resp.ok:
|
||||||
with open(module_path, 'wb') as f:
|
with open(module_path, 'wb') as f:
|
||||||
f.write(resp.content)
|
f.write(resp.content)
|
||||||
@@ -130,7 +131,7 @@ async def main():
|
|||||||
except sqlite3.OperationalError as e:
|
except sqlite3.OperationalError as e:
|
||||||
if str(e) == 'database is locked' and os.name == 'posix':
|
if str(e) == 'database is locked' and os.name == 'posix':
|
||||||
logging.warning('Session file is locked. Trying to kill blocking process...')
|
logging.warning('Session file is locked. Trying to kill blocking process...')
|
||||||
subprocess.run(['fuser', '-k', 'my_account.session'], check=True)
|
subprocess.run(['fuser', '-k', 'my_account.session'], check=True) # noqa: S607
|
||||||
restart()
|
restart()
|
||||||
raise
|
raise
|
||||||
except (errors.NotAcceptable, errors.Unauthorized) as e:
|
except (errors.NotAcceptable, errors.Unauthorized) as e:
|
||||||
@@ -151,10 +152,8 @@ async def main():
|
|||||||
'restart': '<b>Restart completed!</b>',
|
'restart': '<b>Restart completed!</b>',
|
||||||
'update': '<b>Update process completed!</b>',
|
'update': '<b>Update process completed!</b>',
|
||||||
}[info['type']]
|
}[info['type']]
|
||||||
try:
|
with contextlib.suppress(errors.RPCError):
|
||||||
await app.edit_message_text(info['chat_id'], info['message_id'], text)
|
await app.edit_message_text(info['chat_id'], info['message_id'], text)
|
||||||
except errors.RPCError:
|
|
||||||
pass
|
|
||||||
db.remove('core.updater', 'restart_info')
|
db.remove('core.updater', 'restart_info')
|
||||||
|
|
||||||
# required for sessionkiller module
|
# required for sessionkiller module
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ def prettify(val: int) -> str:
|
|||||||
async def ghoul_counter(_, message: Message):
|
async def ghoul_counter(_, message: Message):
|
||||||
await message.delete()
|
await message.delete()
|
||||||
|
|
||||||
if len(message.command) > 1 and message.command[1].isdigit():
|
counter = int(message.command[1]) if len(message.command) > 1 and message.command[1].isdigit() else 1000
|
||||||
counter = int(message.command[1])
|
|
||||||
else:
|
|
||||||
counter = 1000
|
|
||||||
|
|
||||||
msg = await message.reply(prettify(counter), quote=False)
|
msg = await message.reply(prettify(counter), quote=False)
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ class Chat(Object):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
client: 'Client' = None,
|
client: 'Client' = None,
|
||||||
id: id,
|
id: id, # noqa: A002
|
||||||
type: type,
|
type: type, # noqa: A002
|
||||||
is_verified: bool = None,
|
is_verified: bool = None,
|
||||||
is_restricted: bool = None,
|
is_restricted: bool = None,
|
||||||
is_creator: bool = None,
|
is_creator: bool = None,
|
||||||
|
|||||||
@@ -47,10 +47,7 @@ async def afk_handler(_, message: types.Message):
|
|||||||
|
|
||||||
@Client.on_message(filters.command('afk', prefix) & filters.me)
|
@Client.on_message(filters.command('afk', prefix) & filters.me)
|
||||||
async def afk(_, message):
|
async def afk(_, message):
|
||||||
if len(message.text.split()) >= 2:
|
reason = message.text.split(' ', maxsplit=1)[1] if len(message.text.split()) >= 2 else 'None'
|
||||||
reason = message.text.split(' ', maxsplit=1)[1]
|
|
||||||
else:
|
|
||||||
reason = 'None'
|
|
||||||
|
|
||||||
afk_info['start'] = int(datetime.datetime.now().timestamp())
|
afk_info['start'] = int(datetime.datetime.now().timestamp())
|
||||||
afk_info['is_afk'] = True
|
afk_info['is_afk'] = True
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from utils.scripts import format_exc, import_library
|
|||||||
|
|
||||||
genai = import_library('google.generativeai', 'google-generativeai')
|
genai = import_library('google.generativeai', 'google-generativeai')
|
||||||
|
|
||||||
from utils.config import gemini_key
|
from utils.config import gemini_key # noqa: E402
|
||||||
|
|
||||||
genai.configure(api_key=gemini_key)
|
genai.configure(api_key=gemini_key)
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ async def amogus(client: Client, message: Message):
|
|||||||
parse_mode=enums.ParseMode.HTML,
|
parse_mode=enums.ParseMode.HTML,
|
||||||
)
|
)
|
||||||
|
|
||||||
clr = randint(1, 12)
|
clr = randint(1, 12) # noqa: S311
|
||||||
|
|
||||||
url = 'https://raw.githubusercontent.com/The-MoonTg-project/AmongUs/master/'
|
url = 'https://raw.githubusercontent.com/The-MoonTg-project/AmongUs/master/'
|
||||||
font = ImageFont.truetype(BytesIO(get(url + 'bold.ttf').content), 60)
|
font = ImageFont.truetype(BytesIO(get(url + 'bold.ttf', timeout=10).content), 60)
|
||||||
imposter = Image.open(BytesIO(get(f'{url}{clr}.png').content))
|
imposter = Image.open(BytesIO(get(f'{url}{clr}.png', timeout=10).content))
|
||||||
|
|
||||||
text_ = '\n'.join(['\n'.join(wrap(part, 30)) for part in text.split('\n')])
|
text_ = '\n'.join(['\n'.join(wrap(part, 30)) for part in text.split('\n')])
|
||||||
bbox = ImageDraw.Draw(Image.new('RGB', (1, 1))).multiline_textbbox((0, 0), text_, font, stroke_width=2)
|
bbox = ImageDraw.Draw(Image.new('RGB', (1, 1))).multiline_textbbox((0, 0), text_, font, stroke_width=2)
|
||||||
|
|||||||
+17
-19
@@ -10,18 +10,20 @@ from PIL import Image, ImageDraw, ImageFont
|
|||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from utils.misc import modules_help, prefix
|
from utils.misc import modules_help, prefix
|
||||||
from utils.scripts import ReplyCheck, edit_or_reply
|
from utils.scripts import edit_or_reply, reply_check
|
||||||
|
|
||||||
|
|
||||||
async def amongus_gen(text: str, clr: int) -> str:
|
async def amongus_gen(text: str, clr: int) -> str:
|
||||||
url = 'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/Amongus/'
|
url = 'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/Amongus/'
|
||||||
font = ImageFont.truetype(
|
font = ImageFont.truetype(
|
||||||
BytesIO(
|
BytesIO(
|
||||||
requests.get('https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf').content
|
requests.get(
|
||||||
|
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/bold.ttf', timeout=10
|
||||||
|
).content
|
||||||
),
|
),
|
||||||
60,
|
60,
|
||||||
)
|
)
|
||||||
imposter = Image.open(BytesIO(requests.get(f'{url}{clr}.png').content))
|
imposter = Image.open(BytesIO(requests.get(f'{url}{clr}.png', timeout=10).content))
|
||||||
text_ = '\n'.join('\n'.join(wrap(part, 30)) for part in text.split('\n'))
|
text_ = '\n'.join('\n'.join(wrap(part, 30)) for part in text.split('\n'))
|
||||||
bbox = ImageDraw.Draw(Image.new('RGB', (1, 1))).multiline_textbbox((0, 0), text_, font, stroke_width=2)
|
bbox = ImageDraw.Draw(Image.new('RGB', (1, 1))).multiline_textbbox((0, 0), text_, font, stroke_width=2)
|
||||||
w, h = bbox[2], bbox[3]
|
w, h = bbox[2], bbox[3]
|
||||||
@@ -42,10 +44,12 @@ async def amongus_gen(text: str, clr: int) -> str:
|
|||||||
|
|
||||||
async def get_imposter_img(text: str) -> BytesIO:
|
async def get_imposter_img(text: str) -> BytesIO:
|
||||||
background = requests.get(
|
background = requests.get(
|
||||||
f'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/imposter/impostor{randint(1, 22)}.png'
|
f'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/imposter/impostor{randint(1, 22)}.png', # noqa: S311
|
||||||
|
timeout=10,
|
||||||
).content
|
).content
|
||||||
font = requests.get(
|
font = requests.get(
|
||||||
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/roboto_regular.ttf'
|
'https://github.com/TgCatUB/CatUserbot-Resources/raw/master/Resources/fonts/roboto_regular.ttf',
|
||||||
|
timeout=10,
|
||||||
).content
|
).content
|
||||||
font = BytesIO(font)
|
font = BytesIO(font)
|
||||||
font = ImageFont.truetype(font, 30)
|
font = ImageFont.truetype(font, 30)
|
||||||
@@ -79,9 +83,9 @@ async def amongus_cmd(client: Client, message: Message):
|
|||||||
text = text.replace(f'-c{clr}', '')
|
text = text.replace(f'-c{clr}', '')
|
||||||
clr = int(clr)
|
clr = int(clr)
|
||||||
if clr > 12 or clr < 1:
|
if clr > 12 or clr < 1:
|
||||||
clr = randint(1, 12)
|
clr = randint(1, 12) # noqa: S311
|
||||||
except IndexError:
|
except IndexError:
|
||||||
clr = randint(1, 12)
|
clr = randint(1, 12) # noqa: S311
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
if not reply:
|
if not reply:
|
||||||
@@ -94,24 +98,21 @@ async def amongus_cmd(client: Client, message: Message):
|
|||||||
await client.send_sticker(
|
await client.send_sticker(
|
||||||
message.chat.id,
|
message.chat.id,
|
||||||
imposter_file,
|
imposter_file,
|
||||||
reply_to_message_id=ReplyCheck(message),
|
reply_to_message_id=reply_check(message),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command('imposter', prefix) & filters.me)
|
@Client.on_message(filters.command('imposter', prefix) & filters.me)
|
||||||
async def imposter_cmd(client: Client, message: Message):
|
async def imposter_cmd(client: Client, message: Message):
|
||||||
remain = randint(1, 2)
|
remain = randint(1, 2) # noqa: S311
|
||||||
imps = ["wasn't the impostor", 'was the impostor']
|
imps = ["wasn't the impostor", 'was the impostor']
|
||||||
|
|
||||||
if message.reply_to_message:
|
if message.reply_to_message:
|
||||||
user = message.reply_to_message.from_user
|
user = message.reply_to_message.from_user
|
||||||
text = f'{user.first_name} {choice(imps)}.'
|
text = f'{user.first_name} {choice(imps)}.' # noqa: S311
|
||||||
else:
|
else:
|
||||||
args = message.text.split()[1:]
|
args = message.text.split()[1:]
|
||||||
if args:
|
text = ' '.join(args) if args else f'{message.from_user.first_name} {choice(imps)}.' # noqa: S311
|
||||||
text = ' '.join(args)
|
|
||||||
else:
|
|
||||||
text = f'{message.from_user.first_name} {choice(imps)}.'
|
|
||||||
|
|
||||||
text += f'\n{remain} impostor(s) remain.'
|
text += f'\n{remain} impostor(s) remain.'
|
||||||
imposter_file = await get_imposter_img(text)
|
imposter_file = await get_imposter_img(text)
|
||||||
@@ -119,7 +120,7 @@ async def imposter_cmd(client: Client, message: Message):
|
|||||||
await client.send_photo(
|
await client.send_photo(
|
||||||
message.chat.id,
|
message.chat.id,
|
||||||
imposter_file,
|
imposter_file,
|
||||||
reply_to_message_id=ReplyCheck(message),
|
reply_to_message_id=reply_check(message),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -128,10 +129,7 @@ async def imp_animation(client: Client, message: Message):
|
|||||||
name = ' '.join(message.command[1:]) if len(message.command) > 1 else ''
|
name = ' '.join(message.command[1:]) if len(message.command) > 1 else ''
|
||||||
if not name:
|
if not name:
|
||||||
reply = message.reply_to_message
|
reply = message.reply_to_message
|
||||||
if reply:
|
name = reply.from_user.first_name if reply else message.from_user.first_name
|
||||||
name = reply.from_user.first_name
|
|
||||||
else:
|
|
||||||
name = message.from_user.first_name
|
|
||||||
cmd = message.command[0].lower()
|
cmd = message.command[0].lower()
|
||||||
|
|
||||||
text1 = await edit_or_reply(message, 'Uhmm... Something is wrong here!!')
|
text1 = await edit_or_reply(message, 'Uhmm... Something is wrong here!!')
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ async def timer_blankx(_, message: Message):
|
|||||||
)
|
)
|
||||||
j = 10
|
j = 10
|
||||||
k = j
|
k = j
|
||||||
for j in range(j):
|
for _j in range(j):
|
||||||
await message.edit_text(txt + str(k), parse_mode=enums.ParseMode.HTML)
|
await message.edit_text(txt + str(k), parse_mode=enums.ParseMode.HTML)
|
||||||
k = k + 10
|
k = k + 10
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|||||||
@@ -43,22 +43,22 @@ async def anime_search(client: Client, message: Message):
|
|||||||
|
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
||||||
averageScore = result['averageScore']
|
average_score = result['average_score']
|
||||||
try:
|
try:
|
||||||
coverImage_url = result['imageUrl']
|
cover_image_url = result['imageUrl']
|
||||||
coverImage = requests.get(url=coverImage_url).content
|
cover_image = requests.get(url=cover_image_url, timeout=10).content
|
||||||
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
||||||
await f.write(coverImage)
|
await f.write(cover_image)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
coverImage = None
|
cover_image = None
|
||||||
|
|
||||||
title = result['title']['english']
|
title = result['title']['english']
|
||||||
trailer = result['trailer']['id']
|
trailer = result['trailer']['id']
|
||||||
description = result['description']
|
description = result['description']
|
||||||
episodes = result['episodes']
|
episodes = result['episodes']
|
||||||
genres = ', '.join(result['genres'])
|
genres = ', '.join(result['genres'])
|
||||||
isAdult = result['isAdult']
|
is_adult = result['is_adult']
|
||||||
status = result['status']
|
status = result['status']
|
||||||
studios = ', '.join(result['studios'])
|
studios = ', '.join(result['studios'])
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ async def anime_search(client: Client, message: Message):
|
|||||||
[
|
[
|
||||||
InputMediaPhoto(
|
InputMediaPhoto(
|
||||||
'coverImage.jpg',
|
'coverImage.jpg',
|
||||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -81,7 +81,7 @@ async def anime_search(client: Client, message: Message):
|
|||||||
[
|
[
|
||||||
InputMediaPhoto(
|
InputMediaPhoto(
|
||||||
'coverImage.jpg',
|
'coverImage.jpg',
|
||||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Episodes:</b> <code>{episodes}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -109,22 +109,22 @@ async def manga_search(client: Client, message: Message):
|
|||||||
|
|
||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
||||||
averageScore = result['averageScore']
|
average_score = result['average_score']
|
||||||
try:
|
try:
|
||||||
coverImage_url = result['imageUrl']
|
cover_image_url = result['imageUrl']
|
||||||
coverImage = requests.get(url=coverImage_url).content
|
cover_image = requests.get(url=cover_image_url, timeout=10).content
|
||||||
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
||||||
await f.write(coverImage)
|
await f.write(cover_image)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
coverImage = None
|
cover_image = None
|
||||||
|
|
||||||
title = result['title']['english']
|
title = result['title']['english']
|
||||||
trailer = result['trailer']['id']
|
trailer = result['trailer']['id']
|
||||||
description = result['description']
|
description = result['description']
|
||||||
chapters = result['chapters']
|
chapters = result['chapters']
|
||||||
genres = ', '.join(result['genres'])
|
genres = ', '.join(result['genres'])
|
||||||
isAdult = result['isAdult']
|
is_adult = result['is_adult']
|
||||||
status = result['status']
|
status = result['status']
|
||||||
studios = ', '.join(result['studios'])
|
studios = ', '.join(result['studios'])
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ async def manga_search(client: Client, message: Message):
|
|||||||
[
|
[
|
||||||
InputMediaPhoto(
|
InputMediaPhoto(
|
||||||
'coverImage.jpg',
|
'coverImage.jpg',
|
||||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -147,7 +147,7 @@ async def manga_search(client: Client, message: Message):
|
|||||||
[
|
[
|
||||||
InputMediaPhoto(
|
InputMediaPhoto(
|
||||||
'coverImage.jpg',
|
'coverImage.jpg',
|
||||||
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{averageScore}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{isAdult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
caption=f"<b>Title:</b> <code>{title}</code>\n<b>Average Score:</b> <code>{average_score}</code>\n<b>Status:</b> <code>{status}</code>\n<b>Genres:</b> <code>{genres}</code>\n<b>Chapters:</b> <code>{chapters}</code>\n<b>Is Adult:</b> <code>{is_adult}</code>\n<b>Studios:</b> <code>{studios}</code>\n<b>Description:</b> <code>{description}</code>\n<b>Trailer:</b> <a href='https://youtu.be/{trailer}'>Click Here</a>",
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -176,13 +176,13 @@ async def character(client: Client, message: Message):
|
|||||||
result = response.json()
|
result = response.json()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
coverImage_url = result['image']['large']
|
cover_image_url = result['image']['large']
|
||||||
coverImage = requests.get(url=coverImage_url).content
|
cover_image = requests.get(url=cover_image_url, timeout=10).content
|
||||||
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
async with aiofiles.open('coverImage.jpg', mode='wb') as f:
|
||||||
await f.write(coverImage)
|
await f.write(cover_image)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
coverImage = None
|
cover_image = None
|
||||||
|
|
||||||
age = result['age']
|
age = result['age']
|
||||||
description = result['description']
|
description = result['description']
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ async def random():
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command(['arnd', 'arandom'], prefix) & filters.me)
|
@Client.on_message(filters.command(['arnd', 'arandom'], prefix) & filters.me)
|
||||||
async def anime_handler(client: Client, message: Message):
|
async def anime_handler(_client: Client, message: Message):
|
||||||
try:
|
try:
|
||||||
await message.edit('<b>Searching art</b>', parse_mode=enums.ParseMode.HTML)
|
await message.edit('<b>Searching art</b>', parse_mode=enums.ParseMode.HTML)
|
||||||
ra = await random()
|
ra = await random()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from utils.scripts import format_exc
|
|||||||
|
|
||||||
|
|
||||||
def get_neko_media(query):
|
def get_neko_media(query):
|
||||||
return requests.get(f'https://nekos.life/api/v2/img/{query}').json()['url']
|
return requests.get(f'https://nekos.life/api/v2/img/{query}', timeout=10).json()['url']
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command('neko', prefix) & filters.me)
|
@Client.on_message(filters.command('neko', prefix) & filters.me)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ async def aniquotes_handler(client: Client, message: Message):
|
|||||||
result = await client.get_inline_bot_results('@quotafbot', query)
|
result = await client.get_inline_bot_results('@quotafbot', query)
|
||||||
return await message.reply_inline_bot_result(
|
return await message.reply_inline_bot_result(
|
||||||
query_id=result.query_id,
|
query_id=result.query_id,
|
||||||
result_id=result.results[randint(1, 2)].id,
|
result_id=result.results[randint(1, 2)].id, # noqa: S311
|
||||||
reply_to_message_id=(message.reply_to_message.id if message.reply_to_message else None),
|
reply_to_message_id=(message.reply_to_message.id if message.reply_to_message else None),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def id_generator() -> str:
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.command(['bbox', 'blackbox'], prefix) & filters.me)
|
@Client.on_message(filters.command(['bbox', 'blackbox'], prefix) & filters.me)
|
||||||
async def blackbox(client, message):
|
async def blackbox(_client, message):
|
||||||
m = message
|
m = message
|
||||||
msg = await m.edit_text('🔍')
|
msg = await m.edit_text('🔍')
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ async def calc(_, message: Message):
|
|||||||
return
|
return
|
||||||
args = ' '.join(message.command[1:])
|
args = ' '.join(message.command[1:])
|
||||||
try:
|
try:
|
||||||
result = str(eval(args))
|
result = str(eval(args)) # noqa: S307
|
||||||
|
|
||||||
if len(result) > 4096:
|
if len(result) > 4096:
|
||||||
i = 0
|
for i, x in enumerate(range(0, len(result), 4096)):
|
||||||
for x in range(0, len(result), 4096):
|
|
||||||
if i == 0:
|
if i == 0:
|
||||||
await message.edit(
|
await message.edit(
|
||||||
f'<i>{args}</i><b>=</b><code>{result[x : x + 4000]}</code>',
|
f'<i>{args}</i><b>=</b><code>{result[x : x + 4000]}</code>',
|
||||||
@@ -23,7 +22,6 @@ async def calc(_, message: Message):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await message.reply(f'<code>{result[x : x + 4096]}</code>', parse_mode='HTML')
|
await message.reply(f'<code>{result[x : x + 4096]}</code>', parse_mode='HTML')
|
||||||
i += 1
|
|
||||||
await asyncio.sleep(0.18)
|
await asyncio.sleep(0.18)
|
||||||
else:
|
else:
|
||||||
await message.edit(f'<i>{args}</i><b>=</b><code>{result}</code>', parse_mode='HTML')
|
await message.edit(f'<i>{args}</i><b>=</b><code>{result}</code>', parse_mode='HTML')
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user