-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
357 lines (308 loc) · 10.3 KB
/
Copy pathJustfile
File metadata and controls
357 lines (308 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# justfile - Task runner for Complete Linux Internet Repair Tool
# Install just: https://just.systems/
# Set shell to bash
set shell := ["bash", "-uc"]
# Default recipe (list all recipes)
default:
@just --list
# ============================================================================
# DEVELOPMENT
# ============================================================================
# Run all pre-commit checks
check: syntax-check test lint
# Check bash syntax for all scripts
syntax-check:
#!/usr/bin/env bash
set -euo pipefail
echo "🔍 Checking bash syntax..."
find . -name "*.sh" -type f -exec bash -n {} \;
bash -n network-repair
echo "✅ Syntax check passed"
# Run test suite
test:
#!/usr/bin/env bash
set -euo pipefail
echo "🧪 Running test suite..."
chmod +x tests/*.sh
./tests/run-tests.sh
# Run utility tests
test-utils:
#!/usr/bin/env bash
set -euo pipefail
echo "🧪 Running utility tests..."
chmod +x tests/test-utils.sh
./tests/test-utils.sh
# Lint shell scripts with ShellCheck (if available)
lint:
#!/usr/bin/env bash
set -euo pipefail
if command -v shellcheck >/dev/null 2>&1; then
echo "🔍 Running ShellCheck..."
find src -name "*.sh" -type f -exec shellcheck {} +
echo "✅ Lint passed"
else
echo "⚠️ ShellCheck not installed (optional)"
echo " Install: apt-get install shellcheck"
fi
# ============================================================================
# USAGE
# ============================================================================
# Run diagnostics (read-only, no root required)
diagnose:
./network-repair diagnose
# Run diagnostics with verbose output
diagnose-verbose:
./network-repair --verbose diagnose
# Run diagnostics for specific component
diagnose-dns:
./network-repair diagnose-dns
# Run diagnostics for network interfaces
diagnose-network:
./network-repair diagnose-network
# Run diagnostics for routing
diagnose-routing:
./network-repair diagnose-routing
# Show help
help:
./network-repair --help
# ============================================================================
# INSTALLATION
# ============================================================================
# Install system-wide (requires root)
install:
#!/usr/bin/env bash
set -euo pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "❌ Installation requires root privileges"
echo " Run: sudo just install"
exit 1
fi
./install.sh
# Uninstall (requires root)
uninstall:
#!/usr/bin/env bash
set -euo pipefail
if [[ ${EUID} -ne 0 ]]; then
echo "❌ Uninstallation requires root privileges"
echo " Run: sudo just uninstall"
exit 1
fi
if [[ -x /opt/network-repair/uninstall.sh ]]; then
/opt/network-repair/uninstall.sh
else
echo "❌ Tool not installed or uninstall script missing"
exit 1
fi
# ============================================================================
# DOCUMENTATION
# ============================================================================
# Generate documentation (markdown to man pages, if tools available)
docs:
#!/usr/bin/env bash
set -euo pipefail
if command -v pandoc >/dev/null 2>&1; then
echo "📚 Generating man pages..."
mkdir -p docs/man
pandoc README.md -s -t man -o docs/man/network-repair.1
echo "✅ Man page generated: docs/man/network-repair.1"
else
echo "⚠️ pandoc not installed (optional)"
echo " Install: apt-get install pandoc"
fi
# View README
readme:
less README.md
# View troubleshooting guide
troubleshooting:
less docs/troubleshooting.md
# View all documentation
docs-all:
#!/usr/bin/env bash
echo "📚 Available documentation:"
echo " - README.md"
echo " - CONTRIBUTING.md"
echo " - SECURITY.md"
echo " - CODE_OF_CONDUCT.md"
echo " - MAINTAINERS.md"
echo " - TPCF.md"
echo " - CHANGELOG.md"
echo " - docs/ARCHITECTURE.md"
echo " - docs/troubleshooting.md"
echo " - examples/basic-usage.md"
echo " - examples/advanced-usage.md"
echo " - RSR-COMPLIANCE.md"
# ============================================================================
# RELEASE
# ============================================================================
# Show current version
version:
@grep '^VERSION=' src/main.sh | cut -d'"' -f2
# Create release archive
archive VERSION:
#!/usr/bin/env bash
set -euo pipefail
echo "📦 Creating release archive for v{{VERSION}}..."
tar -czf "network-repair-{{VERSION}}.tar.gz" \
--exclude='.git*' \
--exclude='*.tar.gz' \
--exclude='.github' \
--transform "s,^,network-repair-{{VERSION}}/," \
.
sha256sum "network-repair-{{VERSION}}.tar.gz" > "network-repair-{{VERSION}}.tar.gz.sha256"
echo "✅ Created: network-repair-{{VERSION}}.tar.gz"
echo "✅ Checksum: network-repair-{{VERSION}}.tar.gz.sha256"
# ============================================================================
# VALIDATION
# ============================================================================
# Validate RSR compliance
validate-rsr:
#!/usr/bin/env bash
set -euo pipefail
echo "🔍 Validating RSR Compliance..."
echo ""
# Required files
echo "📋 Checking required files..."
required=(
"README.md"
"LICENSE"
"CHANGELOG.md"
"CONTRIBUTING.md"
"CODE_OF_CONDUCT.md"
"SECURITY.md"
"MAINTAINERS.md"
"TPCF.md"
".well-known/security.txt"
".well-known/ai.txt"
".well-known/humans.txt"
)
missing=0
for file in "${required[@]}"; do
if [[ -f "$file" ]]; then
echo " ✅ $file"
else
echo " ❌ $file (missing)"
missing=$((missing + 1))
fi
done
echo ""
echo "📊 RSR Compliance Summary:"
echo " Required files: $((${#required[@]} - missing))/${#required[@]}"
if [[ $missing -eq 0 ]]; then
echo " 🏆 RSR Level: Silver (100%)"
else
echo " ⚠️ Missing $missing required file(s)"
fi
exit $missing
# Validate .well-known files
validate-wellknown:
#!/usr/bin/env bash
set -euo pipefail
echo "🔍 Validating .well-known files..."
# Check security.txt
if [[ -f .well-known/security.txt ]]; then
if grep -q "Contact:" .well-known/security.txt && \
grep -q "Expires:" .well-known/security.txt; then
echo " ✅ security.txt (RFC 9116 compliant)"
else
echo " ⚠️ security.txt (missing required fields)"
fi
else
echo " ❌ security.txt (missing)"
fi
# Check ai.txt
if [[ -f .well-known/ai.txt ]]; then
echo " ✅ ai.txt"
else
echo " ❌ ai.txt (missing)"
fi
# Check humans.txt
if [[ -f .well-known/humans.txt ]]; then
echo " ✅ humans.txt"
else
echo " ❌ humans.txt (missing)"
fi
# Run all validation checks
validate: validate-rsr validate-wellknown check
# ============================================================================
# CLEANUP
# ============================================================================
# Clean build artifacts and temporary files
clean:
#!/usr/bin/env bash
echo "🧹 Cleaning..."
rm -f network-repair-*.tar.gz
rm -f network-repair-*.tar.gz.sha256
rm -rf docs/man
find . -name "*.log" -type f -delete 2>/dev/null || true
echo "✅ Clean complete"
# ============================================================================
# CONTINUOUS INTEGRATION
# ============================================================================
# Run CI checks (same as GitHub Actions)
ci: syntax-check test lint validate-rsr
@echo "✅ All CI checks passed"
# ============================================================================
# STATISTICS
# ============================================================================
# Show project statistics
stats:
#!/usr/bin/env bash
echo "📊 Project Statistics"
echo ""
echo "Files:"
echo " Shell scripts: $(find . -name "*.sh" -type f | wc -l)"
echo " Markdown docs: $(find . -name "*.md" -type f | wc -l)"
echo " Total files: $(find . -type f | wc -l)"
echo ""
echo "Lines of code:"
find . -name "*.sh" -type f -exec wc -l {} + | tail -1
echo ""
echo "Git:"
echo " Commits: $(git rev-list --count HEAD 2>/dev/null || echo 'N/A')"
echo " Branch: $(git branch --show-current 2>/dev/null || echo 'N/A')"
echo ""
echo "Version: $(grep '^VERSION=' src/main.sh | cut -d'"' -f2)"
# ============================================================================
# DEVELOPMENT HELPERS
# ============================================================================
# Watch files and run tests on change (requires entr)
watch:
#!/usr/bin/env bash
if command -v entr >/dev/null 2>&1; then
find src tests -name "*.sh" | entr just test
else
echo "❌ entr not installed"
echo " Install: apt-get install entr"
exit 1
fi
# Format shell scripts (requires shfmt)
format:
#!/usr/bin/env bash
if command -v shfmt >/dev/null 2>&1; then
echo "🎨 Formatting shell scripts..."
find src tests -name "*.sh" -exec shfmt -w -i 4 {} +
echo "✅ Formatting complete"
else
echo "⚠️ shfmt not installed (optional)"
echo " Install: go install mvdan.cc/sh/v3/cmd/shfmt@latest"
fi
# ============================================================================
# HELP
# ============================================================================
# Show comprehensive help
help-all:
@echo "Complete Linux Internet Repair Tool - justfile recipes"
@echo ""
@echo "📖 Usage: just <recipe>"
@echo ""
@just --list
@echo ""
@echo "💡 Quick start:"
@echo " just check - Run all checks before commit"
@echo " just diagnose - Run network diagnostics"
@echo " just test - Run test suite"
@echo " just validate - Validate RSR compliance"
@echo " sudo just install - Install system-wide"
@echo ""
@echo "📚 Documentation: just docs-all"
@echo "🔍 Statistics: just stats"