zarya/state/00_workstation.sh
2026-10-31 14:30:03 +03:00

80 lines
3.4 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -uo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
echo "## 0. Рабочая станция администратора (Operator Environment)"
echo "### Инфраструктурные SSH-хосты (~/.ssh/config):"
echo '```text'
if [[ -f ~/.ssh/config ]]; then
awk '/^Host (router|proxmox|vyos|10\.|fin21|ded|incserv)/, /^$/' ~/.ssh/config
else
echo "Файл ~/.ssh/config не найден"
fi
echo '```'
echo "### Рабочие алиасы и функции оператора (Active Workflow Aliases):"
echo '```bash'
if [[ -f ~/.bashrc ]] && grep -q '# >>> ATLAS C2 WORKFLOW >>>' ~/.bashrc; then
sed -n '/# >>> ATLAS C2 WORKFLOW >>>/,/# <<< ATLAS C2 WORKFLOW <<</p' ~/.bashrc | grep -v '>>>'
else
echo "# Маркер # >>> ATLAS C2 WORKFLOW >>> не найден в ~/.bashrc"
fi
echo '```'
echo "### Статус RAM-кэша секретов (/dev/shm/.atlas_secrets_cache):"
echo '```text'
if [[ -f /dev/shm/.atlas_secrets_cache ]]; then
stat -c "Размер: %s байт | Права: %a | Создан: %y" /dev/shm/.atlas_secrets_cache
else
echo "Кэш секретов в RAM отсутствует"
fi
echo '```'
echo "### Проверка Git Credential Helper (git.svoo.tech):"
echo '```text'
printf "protocol=https\nhost=git.svoo.tech\n" | git credential fill 2>&1 | awk -F= '/^username/ {print "Username:", $2} /^password/ {print "Password: [PRESENT in RAM]"}' || echo "Credential helper не вернул учетных данных"
echo '```'
echo "### Ядро, память, ZRAM и параметры Coredump:"
echo '```text'
echo -n "Kernel: "; uname -r
echo -n "Swapon: "; swapon --show 2>&1 || echo "swapon недоступен"
zramctl 2>&1 || echo "zramctl недоступен"
echo "Coredump config:"
cat /etc/systemd/coredump.conf.d/*.conf 2>/dev/null || grep -E "Storage|ProcessSizeMax" /etc/systemd/coredump.conf 2>/dev/null || echo "Дефолтная конфигурация coredump"
echo '```'
echo "### Токены безопасности и ключи в ssh-agent:"
echo '```text'
echo "Active SSH Agent keys:"
ssh-add -l 2>&1 || true
echo "YubiKey / FIDO2 Status:"
ykman info 2>/dev/null || echo "Токен YubiKey не обнаружен"
echo '```'
echo "### Зеркала пакетов Pacman (Mirrorlist):"
echo '```text'
grep -E "^Server|^\[" /etc/pacman.conf /etc/pacman.d/* 2>/dev/null | head -n 15 || echo "Нет данных о зеркалах"
echo '```'
echo "### Маршрутизация на хосте (Routing to C2):"
echo '```text'
ip route show | grep -E "10.0.|192.168." || echo "Маршруты к ЦОД не обнаружены"
echo '```'
echo "### Версии локальных инструментов:"
echo '```text'
echo -n "OpenTofu: "; tofu version 2>/dev/null | head -n1 || echo "not installed"
echo -n "Kubectl: "; kubectl version --client -o yaml 2>/dev/null | grep gitVersion | head -n1 || echo "not installed"
echo -n "Talosctl: "; talosctl version --client --short 2>/dev/null || echo "not installed"
echo '```'
echo "### Состояние локального Git-репозитория (SSOT Source):"
echo '```text'
git -C "${REPO_ROOT}" status -sb
echo "Последний коммит: $(git -C "${REPO_ROOT}" log -1 --format='%h - %s (%cr)')"
echo "Remote URL: $(git -C "${REPO_ROOT}" remote -v 2>/dev/null | head -n1 | awk '{print $1, $2}' || echo 'no remote')"
echo '```'
echo "---"