Skip to content

Commit 22c492b

Browse files
committed
Add local validation script for compose and config templates
1 parent 56b0acc commit 22c492b

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737

3838
Перед использованием замените `YOUR_SERVER_IP` на реальный IP/домен сервера.
3939

40+
41+
### Проверка конфигов
42+
```bash
43+
./scripts/validate.sh
44+
```
45+
46+
Скрипт проверяет YAML/JSON синтаксис, наличие обязательных файлов и запускает `docker compose config`, если Docker доступен в системе.
47+
4048
### Запуск
4149
```bash
4250
docker compose up -d

scripts/validate.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$ROOT_DIR"
6+
7+
echo "[1/4] Validate docker-compose YAML syntax"
8+
ruby -e 'require "yaml"; YAML.load_file("docker-compose.yml"); puts "docker-compose.yml: OK"'
9+
10+
echo "[2/4] Validate JSON configs"
11+
python - <<'PY'
12+
import json
13+
from pathlib import Path
14+
15+
files = [
16+
'v2ray/server-config.json',
17+
'client/v2ray-client.example.json',
18+
]
19+
20+
for f in files:
21+
json.loads(Path(f).read_text(encoding='utf-8'))
22+
print(f"{f}: OK")
23+
PY
24+
25+
echo "[3/4] Check required config files exist"
26+
required=(
27+
"docker-compose.yml"
28+
"wireguard/wg_confs/wg0.conf"
29+
"proxy/3proxy.cfg"
30+
"v2ray/server-config.json"
31+
"client/proxy.env.example"
32+
"client/proxychains.conf"
33+
"client/v2ray-client.example.json"
34+
)
35+
36+
for file in "${required[@]}"; do
37+
if [[ ! -f "$file" ]]; then
38+
echo "Missing file: $file" >&2
39+
exit 1
40+
fi
41+
echo "$file: OK"
42+
done
43+
44+
echo "[4/4] Docker Compose semantic validation (if docker exists)"
45+
if command -v docker >/dev/null 2>&1; then
46+
docker compose config >/dev/null
47+
echo "docker compose config: OK"
48+
else
49+
echo "docker not found: skip docker compose config"
50+
fi
51+
52+
echo "Validation completed"

0 commit comments

Comments
 (0)